diff --git a/client/src/client.rs b/client/src/client.rs index edb71e30..3072f74b 100644 --- a/client/src/client.rs +++ b/client/src/client.rs @@ -1081,6 +1081,17 @@ pub trait RpcApi: Sized { self.call("sendrawtransaction", &[tx.raw_hex().into()]) } + /// Submit a package of raw transactions to the node. The package will be + /// validated according to consensus and mempool policy rules. If all + /// transactions pass, they will be accepted to mempool. + /// + /// This RPC is experimental and the interface may be unstable. + fn submit_package(&self, rawtxs: &[R]) -> Result { + let hexes: Vec = + rawtxs.to_vec().into_iter().map(|r| r.raw_hex().into()).collect(); + self.call("submitpackage", &[hexes.into()]) + } + fn estimate_smart_fee( &self, conf_target: u16, diff --git a/json/src/lib.rs b/json/src/lib.rs index f6b13675..82bb849f 100644 --- a/json/src/lib.rs +++ b/json/src/lib.rs @@ -845,6 +845,51 @@ pub struct TestMempoolAcceptResult { pub fees: Option, } +#[derive(Clone, PartialEq, Eq, Debug, Deserialize, Serialize)] +pub struct Fees { + /// Transaction fee. + #[serde(with = "bitcoin::amount::serde::as_btc")] + pub base: Amount, + + /// If the transaction was not already in the mempool, the effective feerate + /// in BTC per KvB. For example, the package feerate and/or feerate with + /// modified fees from prioritisetransaction. + #[serde(default, rename = "effective-feerate", with = "bitcoin::amount::serde::as_btc::opt")] + pub effective_feerate: Option, + + /// If effective-feerate is provided, the wtxids of the transactions whose + /// fees and vsizes are included in effective-feerate. + #[serde(rename = "effective-includes")] + pub effective_includes: Option>, +} + +#[derive(Clone, PartialEq, Eq, Debug, Deserialize, Serialize)] +pub struct TxResult { + pub txid: bitcoin::Txid, + + /// The wtxid of a different transaction with the same txid but different + /// witness found in the mempool. This means the submitted transaction was + /// ignored. + #[serde(rename = "other-wtxid")] + pub other_wtxid: Option, + + /// Virtual transaction size as defined in BIP 141. + pub vsize: u64, + + pub fees: Fees, +} + +#[derive(Clone, PartialEq, Eq, Debug, Deserialize, Serialize)] +pub struct SubmitPackageResult { + /// Transaction results keyed by wtxid. + #[serde(rename = "tx-results")] + pub tx_results: HashMap, + + /// List of txids of replaced transactions. + #[serde(rename = "replaced-transactions")] + pub replaced_transactions: Vec, +} + #[derive(Clone, PartialEq, Eq, Debug, Deserialize, Serialize)] pub struct TestMempoolAcceptResultFees { /// Transaction fee in BTC