Skip to content

Shuffle change output on hardware wallet and Bitcoin Cash sends - #3432

Merged
OmarHatem28 merged 3 commits into
cake-tech:devfrom
bc1cindy:fix/hw-change-ordering-shuffle
Jul 26, 2026
Merged

OmarHatem28 merged 3 commits into
cake-tech:devfrom
bc1cindy:fix/hw-change-ordering-shuffle

Conversation

@bc1cindy

@bc1cindy bc1cindy commented Jul 22, 2026 •

Copy link
Copy Markdown
Contributor

Change was still placed deterministically last on the remaining send paths (hardware wallet BTC/LTC, and Bitcoin Cash), a position fingerprint. The software + RBF paths were already covered by #3420; this finishes the rest.

  • HW (BTC/LTC): add orderOutputs and apply it before building the PSBT / signing — the outputOrdering param was plumbed but ignored.
  • Bitcoin Cash: switch ForkedTransactionBuilder to outputOrdering: shuffle.

Change is found by isChange, not position.

closes #3376

related to payjoin/rust-payjoin#1597 (comment)

bc1cindy added 2 commits July 22, 2026 10:15
Hardware wallet BTC/LTC sends passed outputs to the PSBT/device in the
given order (change last), a position fingerprint. The outputOrdering
param was plumbed but ignored. Add orderOutputs() and apply it in both
buildHardwareWalletTransaction paths; set the send call site to shuffle.

Refs cake-tech#3376 (the software send + RBF paths were covered by cake-tech#3420).
The BCH send path built via ForkedTransactionBuilder with
outputOrdering: none, leaving change deterministically last. The builder
shuffles natively and change is found by isChange, not position, so flip
it to shuffle (matches the BTC software path from cake-tech#3420).

Refs cake-tech#3376.
Comment thread cw_bitcoin/lib/electrum_wallet.dart Resolved

@OmarHatem28 OmarHatem28 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you 🙏

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Bitcoin sends place change output deterministically last

2 participants