Skip to content

Commit e28f58b

Browse files
committed
Add submitpackage
1 parent 7bd815f commit e28f58b

File tree

2 files changed

+56
-0
lines changed

2 files changed

+56
-0
lines changed

client/src/client.rs

+11
Original file line numberDiff line numberDiff line change
@@ -1081,6 +1081,17 @@ pub trait RpcApi: Sized {
10811081
self.call("sendrawtransaction", &[tx.raw_hex().into()])
10821082
}
10831083

1084+
/// Submit a package of raw transactions to the node. The package will be
1085+
/// validated according to consensus and mempool policy rules. If all
1086+
/// transactions pass, they will be accepted to mempool.
1087+
///
1088+
/// This RPC is experimental and the interface may be unstable.
1089+
fn submit_package<R: RawTx>(&self, rawtxs: &[R]) -> Result<json::SubmitPackageResult> {
1090+
let hexes: Vec<serde_json::Value> =
1091+
rawtxs.to_vec().into_iter().map(|r| r.raw_hex().into()).collect();
1092+
self.call("submitpackage", &[hexes.into()])
1093+
}
1094+
10841095
fn estimate_smart_fee(
10851096
&self,
10861097
conf_target: u16,

json/src/lib.rs

+45
Original file line numberDiff line numberDiff line change
@@ -845,6 +845,51 @@ pub struct TestMempoolAcceptResult {
845845
pub fees: Option<TestMempoolAcceptResultFees>,
846846
}
847847

848+
#[derive(Clone, PartialEq, Eq, Debug, Deserialize, Serialize)]
849+
pub struct Fees {
850+
/// Transaction fee.
851+
#[serde(with = "bitcoin::amount::serde::as_btc")]
852+
pub base: Amount,
853+
854+
/// If the transaction was not already in the mempool, the effective feerate
855+
/// in BTC per KvB. For example, the package feerate and/or feerate with
856+
/// modified fees from prioritisetransaction.
857+
#[serde(default, rename = "effective-feerate", with = "bitcoin::amount::serde::as_btc::opt")]
858+
pub effective_feerate: Option<Amount>,
859+
860+
/// If effective-feerate is provided, the wtxids of the transactions whose
861+
/// fees and vsizes are included in effective-feerate.
862+
#[serde(rename = "effective-includes")]
863+
pub effective_includes: Option<Vec<bitcoin::Wtxid>>,
864+
}
865+
866+
#[derive(Clone, PartialEq, Eq, Debug, Deserialize, Serialize)]
867+
pub struct TxResult {
868+
pub txid: bitcoin::Txid,
869+
870+
/// The wtxid of a different transaction with the same txid but different
871+
/// witness found in the mempool. This means the submitted transaction was
872+
/// ignored.
873+
#[serde(rename = "other-wtxid")]
874+
pub other_wtxid: Option<bitcoin::Wtxid>,
875+
876+
/// Virtual transaction size as defined in BIP 141.
877+
pub vsize: u64,
878+
879+
pub fees: Fees,
880+
}
881+
882+
#[derive(Clone, PartialEq, Eq, Debug, Deserialize, Serialize)]
883+
pub struct SubmitPackageResult {
884+
/// Transaction results keyed by wtxid.
885+
#[serde(rename = "tx-results")]
886+
pub tx_results: HashMap<bitcoin::Wtxid, TxResult>,
887+
888+
/// List of txids of replaced transactions.
889+
#[serde(rename = "replaced-transactions")]
890+
pub replaced_transactions: Vec<bitcoin::Txid>,
891+
}
892+
848893
#[derive(Clone, PartialEq, Eq, Debug, Deserialize, Serialize)]
849894
pub struct TestMempoolAcceptResultFees {
850895
/// Transaction fee in BTC

0 commit comments

Comments
 (0)