Skip to content

Reject BIP21 amounts that are not decimal BTC - #22

Open
SashaMIT wants to merge 1 commit into
bitcoinjs:masterfrom
SashaMIT:codered-bip21-decimal-amount
Open

SashaMIT wants to merge 1 commit into
bitcoinjs:masterfrom
SashaMIT:codered-bip21-decimal-amount

Conversation

@SashaMIT

Copy link
Copy Markdown

Summary

decode() converted amount with Number(). amount=0x10 became 16. BIP21 amounts are decimal BTC. A decimal string is required before the conversion. 0, 1.00, 20.3, and 0.200000 still decode.

Test plan

  • Before the change, decode("bitcoin:addr?amount=0x10").options.amount was 16
  • Fixture amount=0x10 throws Invalid amount
  • npx tape test/*.js (55 tests OK)

Made with Cursor

decode() used Number(), so amount=0x10 became 16. Require a decimal string before converting.
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.

1 participant