Skip to content

Preserve strict amount drafts and validate Core transaction boundaries - #1

Merged
droplister merged 5 commits into
masterfrom
codex/amount-contract
Sep 8, 2026
Merged

droplister merged 5 commits into
masterfrom
codex/amount-contract

Conversation

@droplister

@droplister droplister commented Sep 7, 2026 •

Copy link
Copy Markdown
Member

Strict amounts now preserve a user's full draft and expose exact raw units only for valid ASCII decimals. The new dependency-free /amounts entry 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.

@droplister
droplister merged commit 5d97fe7 into master Sep 8, 2026
1 check passed
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