]> Untitled Git - bdk-cli/commitdiff
fix(create_tx): enforce single recipient for send_all
authorArtemiy <artem.pospelov2018@yandex.ru>
Sun, 21 Jun 2026 07:11:17 +0000 (10:11 +0300)
committerArtemiy <artem.pospelov2018@yandex.ru>
Fri, 26 Jun 2026 05:10:33 +0000 (08:10 +0300)
Previously, passing multiple --to arguments with --send_all would
silently drain the wallet to only the first recipient, ignoring the
rest. This was inconsistent with the silent-payments create_tx, which
already validates the recipient count.

Now returns an error unless exactly one recipient is provided

CHANGELOG.md
src/handlers.rs

index 4e66f84ccd820b3e34117c37b3fe2155b9a06efd..3fc8b4fed2a23cf9bc88a6596cbcbb945779ab45 100644 (file)
@@ -4,6 +4,7 @@ Changelog info is also documented on the [GitHub releases](https://github.com/bi
 page. See [DEVELOPMENT_CYCLE.md](DEVELOPMENT_CYCLE.md) for more details.
 
 ## [Unreleased]
+ - Fixed `create_tx --send_all` to reject multiple recipients instead of silently using only the first one
 
 ## [3.0.0]
 
index 15a4d5ac3b9ad4869d9d623a874104308e8f1e1e..398f612a36ff8992bf339b61ec6926b7a3211ac4 100644 (file)
@@ -540,7 +540,13 @@ pub fn handle_offline_wallet_subcommand(
             let mut tx_builder = wallet.build_tx();
 
             if send_all {
-                tx_builder.drain_wallet().drain_to(recipients[0].0.clone());
+                if recipients.len() == 1 {
+                    tx_builder.drain_wallet().drain_to(recipients[0].0.clone());
+                } else {
+                    return Err(Error::Generic(
+                        "Wallet can only be drained to a single output".to_string(),
+                    ));
+                }
             } else {
                 let recipients = recipients
                     .into_iter()