Repository navigation
Preserve strict amount drafts and validate Core transaction boundaries - #1
Merged
Merged
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Strict amounts now preserve a user's full draft and expose exact raw units only for valid ASCII decimals. The new dependency-free
/amountsentry and versioned language-neutral vectors cover indivisible/divisible amounts, malformed sequential edits, unsafe numbers, and Core integer bounds without silently stripping or rounding text.Compose and quote transport now validate numeric parameters against field types traced to Counterparty Core 67e10db3, preserving legitimate fractional fee rates, commission fractions, text, and booleans. Invalid raw quantities fail before fee lookup, network, or signing. Existing intentional arithmetic and rounding helpers retain their behavior.
The compose pipeline also binds Core's raw transaction to its PSBT and the provider's signed result, compares exact Bitcoin envelope fields, and verifies PSBT parent hashes/prevout amounts from transaction bytes. This does not independently decode every Counterparty message or replace the wallet's approval and signature checks; coverage and remaining responsibilities are documented.
Validation: 263 tests across 25 files, TypeScript/Biome check (7 existing warnings), ESM/declaration build, and git diff --check pass. Tests use mocked transport, pinned Core fixture provenance, and test-only signing keys; no live transactions were composed, signed, or broadcast.
The amount entry supports ESM and standalone CommonJS with matching declarations for backend consumers. useCompose exposes stable error codes and original diagnostics so apps can translate failures without parsing English text. The two integer-encoded Core commission/fee fractions fail with amount_precision if Core float-times-UNIT truncation would change the exact requested fraction (for example 0.29); miner fee rates remain independent decimal fields.