Skip to content

fix(create_tx): enforce single recipient for send_all#291

Open
1estart wants to merge 1 commit into
bitcoindevkit:masterfrom
1estart:fix/send-all-recipient-validation
Open

fix(create_tx): enforce single recipient for send_all#291
1estart wants to merge 1 commit into
bitcoindevkit:masterfrom
1estart:fix/send-all-recipient-validation

Conversation

@1estart

@1estart 1estart commented Jun 21, 2026

Copy link
Copy Markdown

Closes #290

Description

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, using idiomatic slice pattern matching (if let [recipient] = ...).

Also fixes a minor grammar issue in the error message ("drain to" → "drained to").

Notes to the reviewers

  • The fix mirrors the validation logic already present in the silent-payments create_tx branch of the same file, so behavior is now consistent between the two code paths.
  • I used if let [recipient] = recipients.as_slice() instead of recipients.len() == 1 + indexing, as it's more idiomatic Rust and eliminates the possibility of a panic on empty slices.
  • The grammar fix ("drain to" → "drained to") is applied in two places where the same typo was duplicated.
  • The integration test tests/send_all_validation.rs verifies the fix end-to-end: it sets up a wallet via wallet config, then calls create_tx --send_all with two recipients and asserts that the command fails with the expected error message.

Changelog notice

  • Fixed create_tx --send_all to reject multiple recipients instead of silently using only the first one

Checklists

All Submissions:

  • I've signed all my commits
  • I followed the contribution guidelines
  • I ran cargo fmt and cargo clippy before committing

New Features:

  • I've added tests for the new feature
  • I've added docs for the new feature
  • I've updated CHANGELOG.md

Bugfixes:

  • This pull request breaks the existing API
  • I've added tests to reproduce the issue which are now passing
  • I'm linking the issue being fixed by this PR

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, using
idiomatic slice pattern matching (`if let [recipient] = ...`).

Also fixes a minor grammar issue in the error message
("drain to" → "drained to").
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: No status

Development

Successfully merging this pull request may close these issues.

create_tx --send_all silently ignores all recipients except the first

1 participant