Skip to content

Validate dispense BTC quantity#3429

Open
caydyan wants to merge 1 commit into
CounterpartyXCP:developfrom
caydyan:fix-dispense-quantity-validation-develop
Open

Validate dispense BTC quantity#3429
caydyan wants to merge 1 commit into
CounterpartyXCP:developfrom
caydyan:fix-dispense-quantity-validation-develop

Conversation

@caydyan

@caydyan caydyan commented Jun 10, 2026

Copy link
Copy Markdown

Supersedes #3387 with the same fix rebased onto the current develop branch.

dispense.compose() did not validate the BTC quantity before checking open dispensers. A negative quantity could bypass the "not enough BTC" guard because must_give becomes negative rather than zero, then the composer returns a destination output with a negative amount.

This PR rejects non-integer and non-positive dispense quantities at the compose validation boundary.

Changes:

  • Requires dispense quantity to be an integer.
  • Rejects zero or negative dispense quantity.
  • Adds regression coverage for negative and non-integer quantities.

Tests:

  • python -m pytest counterpartycore/test/units/messages/dispense_test.py::test_compose counterpartycore/test/units/api/compose_test.py::test_compose_dispense -q
  • python -m pytest counterpartycore/test/units/messages/dispense_test.py -q
  • python -m ruff check counterpartycore/lib/messages/dispense.py counterpartycore/test/units/messages/dispense_test.py
  • python -m ruff format --check counterpartycore/lib/messages/dispense.py counterpartycore/test/units/messages/dispense_test.py
  • git diff --check

Bounty payment address (BTC): bc1qev5ant33v5y89qqjvcf4mh9hlax5svqf5xd7gc

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