3

I need some help understanding a finer point of BIP21 URIs. Is there a required order for the parameters? I'm not very experienced with the concept of ABNF grammar, so I'm having trouble understanding.

For example, I know this is valid.

bitcoin:175tWpb8K1S7NmH4Zx6rewF9WQrcZv245W?amount=20.3&label=Luke-Jr

And I know this valid:

bitcoin:175tWpb8K1S7NmH4Zx6rewF9WQrcZv245W?amount=20.3&label=Luke-Jr&optionalparam=blahblahblah

But is this valid?

bitcoin:175tWpb8K1S7NmH4Zx6rewF9WQrcZv245W?optionalparam=blahblahblah&amount=20.3&label=Luke-Jr

Very specifically, must the order of parameters always be amount, label, message, and then optional params? Or is it OK to include optional params before the amount?

1 Answer 1

2

The ABNF in BIP21 indicates that the bitcoinparam can be in any order.

bitcoinurn     = "bitcoin:" bitcoinaddress [ "?" bitcoinparams ]
bitcoinaddress = *base58
bitcoinparams  = bitcoinparam [ "&" bitcoinparams ]
bitcoinparam   = [ amountparam / labelparam / messageparam / otherparam / reqparam ]

The third item in this list shows that ordering is not important. Any valid bitcoinparam can be first in the RHS expression. You can then prepend any other bitcoinparam using the same rule. Repeat as needed.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.