Skip to content

Commit 5e09bbd

Browse files
committed
Test sendmany
`sendmany` has a new verbose return type in v18. The client macro sends the amount of sats but the RPC takes BTC. Add the verbose struct to v18 and model. Update the client macro. Add a verbose client macro, test and update the types table.
1 parent c7ea6e4 commit 5e09bbd

File tree

29 files changed

+217
-71
lines changed

29 files changed

+217
-71
lines changed

client/src/client_sync/v17/wallet.rs

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -560,7 +560,11 @@ macro_rules! impl_client_v17__send_many {
560560
impl Client {
561561
pub fn send_many(&self, amounts: BTreeMap<Address, Amount>) -> Result<SendMany> {
562562
let dummy = ""; // Must be set to "" for backwards compatibility.
563-
self.call("sendmany", &[into_json(dummy)?, into_json(amounts)?])
563+
let amount_btc: BTreeMap<String, f64> = amounts
564+
.into_iter()
565+
.map(|(addr, amount)| (addr.to_string(), amount.to_btc()))
566+
.collect();
567+
self.call("sendmany", &[into_json(dummy)?, into_json(amount_btc)?])
564568
}
565569
}
566570
};

client/src/client_sync/v21/mod.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -172,6 +172,7 @@ crate::impl_client_v17__remove_pruned_funds!();
172172
crate::impl_client_v17__rescan_blockchain!();
173173
crate::impl_client_v21__send!();
174174
crate::impl_client_v17__send_many!();
175+
crate::impl_client_v21__send_many_verbose!();
175176
crate::impl_client_v17__send_to_address!();
176177
crate::impl_client_v17__set_hd_seed!();
177178
crate::impl_client_v17__set_tx_fee!();

client/src/client_sync/v21/wallet.rs

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -98,6 +98,48 @@ macro_rules! impl_client_v21__send {
9898
};
9999
}
100100

101+
/// Implements Bitcoin Core JSON-RPC API method `sendmany` with `verbose=true` (v21+).
102+
#[macro_export]
103+
macro_rules! impl_client_v21__send_many_verbose {
104+
() => {
105+
impl Client {
106+
pub fn send_many_verbose(
107+
&self,
108+
amounts: BTreeMap<Address, Amount>,
109+
) -> Result<SendManyVerbose> {
110+
let dummy = ""; // Backwards compatibility dummy.
111+
let amount_btc: BTreeMap<String, f64> = amounts
112+
.into_iter()
113+
.map(|(addr, amount)| (addr.to_string(), amount.to_btc()))
114+
.collect();
115+
let minconf = 1u64;
116+
let comment = "";
117+
let subtract_fee_from: Vec<String> = Vec::new();
118+
let replaceable = true;
119+
let conf_target = 1u64;
120+
let estimate_mode = "unset";
121+
let fee_rate = serde_json::Value::Null;
122+
let verbose = true;
123+
self.call(
124+
"sendmany",
125+
&[
126+
into_json(dummy)?,
127+
into_json(amount_btc)?,
128+
minconf.into(),
129+
comment.into(),
130+
into_json(subtract_fee_from)?,
131+
replaceable.into(),
132+
conf_target.into(),
133+
estimate_mode.into(),
134+
fee_rate,
135+
verbose.into(),
136+
],
137+
)
138+
}
139+
}
140+
};
141+
}
142+
101143
/// Implements Bitcoin Core JSON-RPC API method `unloadwallet`.
102144
#[macro_export]
103145
macro_rules! impl_client_v21__unload_wallet {

client/src/client_sync/v22/mod.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -174,6 +174,7 @@ crate::impl_client_v17__remove_pruned_funds!();
174174
crate::impl_client_v17__rescan_blockchain!();
175175
crate::impl_client_v21__send!();
176176
crate::impl_client_v17__send_many!();
177+
crate::impl_client_v21__send_many_verbose!();
177178
crate::impl_client_v17__send_to_address!();
178179
crate::impl_client_v17__set_hd_seed!();
179180
crate::impl_client_v17__set_tx_fee!();

client/src/client_sync/v23/mod.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -179,6 +179,7 @@ crate::impl_client_v17__rescan_blockchain!();
179179
crate::impl_client_v23__restore_wallet!();
180180
crate::impl_client_v21__send!();
181181
crate::impl_client_v17__send_many!();
182+
crate::impl_client_v21__send_many_verbose!();
182183
crate::impl_client_v17__send_to_address!();
183184
crate::impl_client_v17__set_hd_seed!();
184185
crate::impl_client_v17__set_tx_fee!();

client/src/client_sync/v24/mod.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -182,6 +182,7 @@ crate::impl_client_v23__restore_wallet!();
182182
crate::impl_client_v21__send!();
183183
crate::impl_client_v24__send_all!();
184184
crate::impl_client_v17__send_many!();
185+
crate::impl_client_v21__send_many_verbose!();
185186
crate::impl_client_v17__send_to_address!();
186187
crate::impl_client_v17__set_hd_seed!();
187188
crate::impl_client_v17__set_tx_fee!();

client/src/client_sync/v25/mod.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -183,6 +183,7 @@ crate::impl_client_v23__restore_wallet!();
183183
crate::impl_client_v21__send!();
184184
crate::impl_client_v24__send_all!();
185185
crate::impl_client_v17__send_many!();
186+
crate::impl_client_v21__send_many_verbose!();
186187
crate::impl_client_v17__send_to_address!();
187188
crate::impl_client_v17__set_hd_seed!();
188189
crate::impl_client_v17__set_tx_fee!();

client/src/client_sync/v26/mod.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -192,6 +192,7 @@ crate::impl_client_v23__restore_wallet!();
192192
crate::impl_client_v21__send!();
193193
crate::impl_client_v24__send_all!();
194194
crate::impl_client_v17__send_many!();
195+
crate::impl_client_v21__send_many_verbose!();
195196
crate::impl_client_v17__send_to_address!();
196197
crate::impl_client_v17__set_hd_seed!();
197198
crate::impl_client_v17__set_tx_fee!();

client/src/client_sync/v27/mod.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -186,6 +186,7 @@ crate::impl_client_v23__restore_wallet!();
186186
crate::impl_client_v21__send!();
187187
crate::impl_client_v24__send_all!();
188188
crate::impl_client_v17__send_many!();
189+
crate::impl_client_v21__send_many_verbose!();
189190
crate::impl_client_v17__send_to_address!();
190191
crate::impl_client_v17__set_hd_seed!();
191192
crate::impl_client_v17__set_tx_fee!();

client/src/client_sync/v28/mod.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -191,6 +191,7 @@ crate::impl_client_v23__restore_wallet!();
191191
crate::impl_client_v21__send!();
192192
crate::impl_client_v24__send_all!();
193193
crate::impl_client_v17__send_many!();
194+
crate::impl_client_v21__send_many_verbose!();
194195
crate::impl_client_v17__send_to_address!();
195196
crate::impl_client_v17__set_hd_seed!();
196197
crate::impl_client_v17__set_tx_fee!();

0 commit comments

Comments
 (0)