Skip to content

Should we be opinionated about the actual amount value #11

Closed as not planned

Description

@benalleng

Should bitcoin_uri care about the amount presented?

Current behavior

parsing an amount in a uri where the amount is greater than max money does not produce an error.

Expected behavior

I might expect an error to crop up here but I am not totally sure if this is something we need to handle on the payjoin side or if this should be the wallet implementer's problem

Steps to reproduce

    #[test]
    fn test_fuzz_crash() {
        let uri = "bitcoin:12c6DSiU4Rq3P4ZxziKxzrL5LmMBrzjrJX?pj=HTTPS://example.com&pjos=0&amount=21000001";
        let pjuri = Uri::try_from(uri)
            .expect("Invalid uri")
            .assume_checked();
        assert!(pjuri.amount > Some(bitcoin::amount::Amount::MAX_MONEY))
    }

Relevant log output

Found during a fuzzing session.

bitcoin:12c6DSiU4Rq3P4ZxziKxzrL5LmMBrzjrJX?label=&label=0.%2E&pj=HTTPS://I%230l0&pjoszrL5LmMbiTcXnt=.p0101101&amount=100101101&amo5nt=.11000

Activity

  1. xstoicunicornx commented on Apr 15, 2026

    @xstoicunicornx

    Just my two cents, I would say bitcoin_uri should not care about amount. Validating the amount in pj uri is something the wallet implementation must do regardless to ensure user has sufficient funds, and user funds will naturally be within MAX_MONEY bounds.

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions