diff --git a/client/examples/test_against_node.rs b/client/examples/test_against_node.rs index bedaaa85..3e3cdff8 100644 --- a/client/examples/test_against_node.rs +++ b/client/examples/test_against_node.rs @@ -37,7 +37,8 @@ async fn main_result() -> Result<(), Error> { let bitcoin_block: bitcoin::Block = rpc.get_by_id(&best_block_hash).await?; println!("best block hash by `get`: {}", bitcoin_block.header.prev_blockhash); - let bitcoin_tx: bitcoin::Transaction = rpc.get_by_id(&bitcoin_block.txdata[0].compute_txid()).await?; + let bitcoin_tx: bitcoin::Transaction = + rpc.get_by_id(&bitcoin_block.txdata[0].compute_txid()).await?; println!("tx by `get`: {}", bitcoin_tx.compute_txid()); Ok(()) diff --git a/client/src/client.rs b/client/src/client.rs index aa7701af..10f1c110 100644 --- a/client/src/client.rs +++ b/client/src/client.rs @@ -39,6 +39,32 @@ use crate::queryable; /// crate-specific Error type; pub type Result = result::Result; +#[derive(Debug, Serialize, Deserialize)] +pub struct PackageSubmissionFees { + pub base: f64, + #[serde(rename = "effective-feerate", skip_serializing_if = "Option::is_none")] + pub effective_feerate: Option, + #[serde(rename = "effective-includes", skip_serializing_if = "Option::is_none")] + pub effective_includes: Option>, +} + +#[derive(Debug, Serialize, Deserialize)] +pub struct PackageTransactionResult { + pub txid: String, + #[serde(rename = "other-wtxid", skip_serializing_if = "Option::is_none")] + pub other_wtxid: Option, + pub vsize: u32, + pub fees: PackageSubmissionFees, +} + +#[derive(Debug, Serialize, Deserialize)] +pub struct PackageSubmissionResult { + #[serde(rename = "tx-results")] + pub tx_results: HashMap, + #[serde(rename = "replaced-transactions", skip_serializing_if = "Option::is_none")] + pub replaced_transactions: Option>, +} + /// Outpoint that serializes and deserializes as a map, instead of a string, /// for use as RPC arguments #[derive(Clone, Debug, Serialize, Deserialize)] @@ -916,6 +942,12 @@ pub trait RpcApi: Sized { self.call("testmempoolaccept", &[hexes.into()]).await } + async 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()]).await + } + async fn stop(&self) -> Result { self.call("stop", &[]).await }