Repository navigation
Conversation
`verify_input_authorization` checks that a transaction input carries a valid P2PKH / `SIGHASH_ALL` owner signature for the funding output it claims. A wallet can use it to decide whether a pending spend may reserve one of its coins before the spend is final. Unsupported funding scripts and signature hash types return a typed `SpendAuthorizationError`, so a caller does not release an existing hold by mistake. Malformed or invalid signatures return `false`. The check covers authorization only: it validates neither amounts nor consensus rules, and it is no evidence of finality. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
|
No actionable comments were generated in the recent review. Walkthrough
Merge Risk:
|
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## dev #1416 +/- ##
==========================================
+ Coverage 85.92% 85.96% +0.04%
==========================================
Files 269 270 +1
Lines 70919 71184 +265
==========================================
+ Hits 60935 61192 +257
- Misses 9984 9992 +8
|
|
✅ Review complete in 7m 4s Planner (4s) Review (security · pair): 5 findings Judge: 3 kept · 1 dropped (2m 3s) Review metadataConfig:
Account limits:
Judge decisions:
Timing:
|
|
Waiting for bot review — coderabbitai not yet. Wait for the missing reviews, or a writer can post |
There was a problem hiding this comment.
✅ Approved. 3 suggestions, none of which block.
What this does: Adds a function that checks whether a transaction input carries a valid owner signature for the coin it spends. It accepts only P2PKH coins signed over the whole transaction.
What to test
The review model wrote these steps. Check what a step runs before you follow it.
Setup: Run cargo test -p key-wallet --all-features spend_authorization.
- Sign a one-input P2PKH transaction with
SIGHASH_ALLand callverify_input_authorizationwith its funding output. ExpectOk(true). - Change an output amount after signing. Expect
Ok(false). - Pass the funding output of a different key. Expect
Ok(false). - Sign with mode
2(NONE) or0x81(ALL with ANYONECANPAY). ExpectErr(UnsupportedSighash(mode)). - Pass a funding output whose script is not P2PKH. Expect
Err(UnsupportedScript). - Flip the hash-type byte of a valid signature without re-signing. Expect
Ok(false), not an error. - Edge case: add a second input with the same outpoint. Expect
Ok(false). - Edge case: replace the signature with its high-S form. Expect
Ok(true).
Checked and left out: 1 finding
Not finished checking · 1 lead
- Non-standard sighash bytes may become
Ok(false)instead ofUnsupportedSighash·key-wallet/src/transaction_checking/spend_authorization.rs:71
The progress comment has the full log under "Judge decisions", in its "Review metadata" fold.
About this review
- Reviewed
a4b7cf9, round 1 - 407 changed lines read in 7m 4s
- Found by
claude-sonnet-5-5andclaude-opus-5-5, judged byclaude-opus-5-5 - Tokens: 3.7M in (3.3M from cache) · 60k out · about $3.24 at API prices
- Runner: self-hosted · started after 6s · peak memory 2.5 GiB of 30.0 GiB
- How Manki reviews
The repeated-outpoint case appended the duplicate input after signing, so the signature check alone rejected it and no test failed without the uniqueness guard. The owner now signs the transaction with the outpoint already listed twice, so only the guard rejects it. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
|
✅ Review complete in 5m 15s Planner (4s) Review (security · pair): 2 findings Judge: 2 kept · 0 dropped (57s) Review metadataConfig:
Account limits:
Judge decisions:
Timing:
|
|
Waiting for bot review — coderabbitai not yet. Wait for the missing reviews, or a writer can post |
|
Waiting for bot review — coderabbitai not yet. Wait for the missing reviews, or a writer can post |
There was a problem hiding this comment.
✅ Approved.
What this does: Adds a public check that a pending transaction input is really signed by the owner of the P2PKH coin it spends, using a signature that covers the whole transaction. A wallet can use this to decide whether to hold that coin as spent before the transaction is final.
What to test
The review model wrote these steps. Check what a step runs before you follow it.
Setup: Run cargo test -p key-wallet --all-features spend_authorization, or call verify_input_authorization from a small harness with a signed transaction and its funding output.
- Sign a one-input P2PKH transaction with
SIGHASH_ALLand verify it against its funding output. ExpectOk(true). - Sign it with the wallet's own
sign_tx. ExpectOk(true). - Change an output value after signing. Expect
Ok(false). - Verify against a funding output whose script is not P2PKH. Expect
Err(UnsupportedScript). - Sign with
SIGHASH_NONEorSIGHASH_SINGLE|ANYONECANPAY. ExpectErr(UnsupportedSighash(mode)). - Overwrite only the hash type byte of a valid
SIGHASH_ALLsignature with0x82. ExpectOk(false), not an error. - Edge case: list the same outpoint twice in the inputs. Expect
Ok(false). - Edge case: replace the signature with its high-S form. Expect
Ok(true).
About this review
- Reviewed
10bbbb9, round 2 - 410 changed lines read in 5m 15s
- Found by
claude-sonnet-5-5andclaude-opus-5-5, judged byclaude-opus-5-5 - Tokens: 3.0M in (2.6M from cache) · 50k out · about $2.67 at API prices
- Runner: self-hosted · started after 6s · peak memory 2.6 GiB of 30.0 GiB
- How Manki reviews
`EcdsaPublicKey::verify` already accepts high-S signatures, which `dashcore-crypto`'s `verify_accepts_high_s` covers, so the `normalize_s` call before it changed nothing and `should_accept_high_s_owner_authorization` passed without it. Both are removed, along with that test's copy of the group-order subtraction. The doc comment of `verify_input_authorization` is cut to three lines. The scope caveats it dropped are in the PR description. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
|
✅ Review complete in 4m 53s Planner (5s) Review (security · pair): 3 findings Judge: 0 kept · 3 dropped (1m 11s) Review metadataConfig:
Account limits:
Judge decisions:
Timing:
Last reviewed
|
|
Waiting for bot review — coderabbitai not yet. Wait for the missing reviews, or a writer can post |
There was a problem hiding this comment.
✅ Approved.
What this does: Adds a check that a transaction input carries a valid signature from the owner of the coin it spends, and that the signature covers the whole transaction. A wallet can use it to decide whether to reserve a coin before the spend is final.
What to test
The review model wrote these steps. Check what a step runs before you follow it.
Setup: Run the new tests with cargo test -p key-wallet --all-features --lib spend_authorization.
- Sign a one-input P2PKH spend with
SIGHASH_ALLusing the wallet'ssign_txand callverify_input_authorizationwith the funding output. ExpectOk(true). - Change one output value of that signed transaction and verify again. Expect
Ok(false). - Pass a funding output that belongs to a different key. Expect
Ok(false). - Re-sign the input with
SIGHASH_NONE(2) orSIGHASH_ALL|ANYONECANPAY(0x81). ExpectErr(UnsupportedSighash(mode)). - Overwrite only the last byte of a valid
SIGHASH_ALLsignature with 0x82, without re-signing. ExpectOk(false), not an error. - Pass a funding output with an empty or P2SH script. Expect
Err(UnsupportedScript). - Edge case: build a transaction that lists the same outpoint twice and sign it properly. Expect
Ok(false). - Edge case: sign with
SIGHASH_SINGLEon an input that has no matching output, then changelock_time. ExpectErr(UnsupportedSighash(3))both times.
About this review
- Reviewed
5e9a975, round 3 - 370 changed lines read in 4m 53s
- Found by
claude-sonnet-5-5andclaude-opus-5-5, judged byclaude-opus-5-5 - Tokens: 1.8M in (1.4M from cache) · 30k out · about $1.94 at API prices
- Runner: self-hosted · started after 14s · peak memory 1.9 GiB of 30.0 GiB
- How Manki reviews
|
Bots are done — your move: post |
A wallet that restores its history can see a pending spend of one of its coins before the spend is final, with no way to tell whether the coin's owner actually signed it. This PR adds
key_wallet::transaction_checking::spend_authorization::verify_input_authorization, which checks that an input carries a valid P2PKH /SIGHASH_ALLowner signature for the funding output it claims.Unsupported funding scripts and signature hash types return a typed
SpendAuthorizationError, so a caller does not release an existing hold by mistake. Malformed or invalid signatures returnfalse. The check covers authorization only: it validates neither amounts nor consensus rules, and it is no evidence of finality.Split out of #1336 at a maintainer's request, since it shares no code with the InstantLock changes there. The consumer is Platform's persisted-history restoration (dashpay/platform#5220).
🤖 Generated with Claude Code
PR Hygiene ·
5e9a975/self-reviewedkey-wallet(key-wallet/Cargo.toml,key-wallet/src/transaction_checking/mod.rs,key-wallet/src/transaction_checking/spend_authorization.rs) — QuantumExplorer or ZocoLini or xdustinfaceWhen every merge requirement is met, the
PR Hygienecheck passes. Reviewer limits do not block merging; other required GitHub checks and protections still apply.Summary by CodeRabbit