Skip to content

create_tx --send_all silently ignores all recipients except the first #290

@va-an

Description

@va-an

In handlers.rs, create_tx's send_all branch uses only recipients[0] and silently drops the rest:

            if send_all {
                tx_builder.drain_wallet().drain_to(recipients[0].0.clone());

No check that exactly one recipient was given. Passing multiple --to with --send_all drains everything to the first one, no error - although send_all is meant for a single recipient (doc: "Requires only one recipient with value 0").

Notably the silent-payments create_tx in the same file already does the right check:

            if send_all {
                if sp_recipients.len() == 1 && maybe_recipients.is_none() {
                    tx_builder
                        .drain_wallet()
                        .drain_to(sp_recipients[0].get_placeholder_p2tr_spk());
                } 

So the regular create_tx is just inconsistent with the SP one.

Fix: in the regular create_tx send_all branch, error out unless exactly one recipient was provided (mirror the SP-create_tx check), instead of indexing recipients[0].

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    Status
    No status

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions