@@ -39,6 +39,32 @@ use crate::queryable;
39
39
/// crate-specific Error type;
40
40
pub type Result < T > = result:: Result < T , Error > ;
41
41
42
+ #[ derive( Debug , Serialize , Deserialize ) ]
43
+ pub struct PackageSubmissionFees {
44
+ pub base : f64 ,
45
+ #[ serde( rename = "effective-feerate" , skip_serializing_if = "Option::is_none" ) ]
46
+ pub effective_feerate : Option < f64 > ,
47
+ #[ serde( rename = "effective-includes" , skip_serializing_if = "Option::is_none" ) ]
48
+ pub effective_includes : Option < Vec < String > > ,
49
+ }
50
+
51
+ #[ derive( Debug , Serialize , Deserialize ) ]
52
+ pub struct PackageTransactionResult {
53
+ pub txid : String ,
54
+ #[ serde( rename = "other-wtxid" , skip_serializing_if = "Option::is_none" ) ]
55
+ pub other_wtxid : Option < String > ,
56
+ pub vsize : u32 ,
57
+ pub fees : PackageSubmissionFees ,
58
+ }
59
+
60
+ #[ derive( Debug , Serialize , Deserialize ) ]
61
+ pub struct PackageSubmissionResult {
62
+ #[ serde( rename = "tx-results" ) ]
63
+ pub tx_results : HashMap < String , PackageTransactionResult > ,
64
+ #[ serde( rename = "replaced-transactions" , skip_serializing_if = "Option::is_none" ) ]
65
+ pub replaced_transactions : Option < Vec < String > > ,
66
+ }
67
+
42
68
/// Outpoint that serializes and deserializes as a map, instead of a string,
43
69
/// for use as RPC arguments
44
70
#[ derive( Clone , Debug , Serialize , Deserialize ) ]
@@ -1140,6 +1166,15 @@ pub trait RpcApi: Sized {
1140
1166
self . call ( "sendrawtransaction" , & [ tx. raw_hex ( ) . into ( ) ] ) . await
1141
1167
}
1142
1168
1169
+ /// Implement submitpackage here
1170
+ async fn submit_package < R : RawTx > ( & self , raw_txs : Vec < R > ) -> Result < PackageSubmissionResult > {
1171
+ // Convert the raw transactions to their hex representations
1172
+ let hex_txs: Vec < String > = raw_txs. into_iter ( ) . map ( |tx| tx. raw_hex ( ) . into ( ) ) . collect ( ) ;
1173
+
1174
+ // Make the RPC call with the array of hex-encoded transactions
1175
+ self . call ( "submitpackage" , & [ hex_txs. into ( ) ] ) . await
1176
+ }
1177
+
1143
1178
async fn estimate_smart_fee (
1144
1179
& self ,
1145
1180
conf_target : u16 ,
0 commit comments