Skip to content

Commit

Permalink
Merge #2696: Fix example spend amount
Browse files Browse the repository at this point in the history
3a2d86e Fix example spend amount (Tobin C. Harding)

Pull request description:

  In the segwit signing example we are using the incorrect value when creating the signature - we should be using the utxo amount (input amount) not the spend amount (output spend amount).

  Close: #2680

ACKs for top commit:
  storopoli:
    ACK 3a2d86e
  apoelstra:
    ACK 3a2d86e
  sanket1729:
    ACK 3a2d86e

Tree-SHA512: dbd25c0adb2b0cd3ddd61893ce0c057edd7d62aad6a380b19b1e10ae1b8f0f22d81c15c3c7e2bb64a1740b1b6a7b096aaadab8040e507b73fef0bc2a1638d827
  • Loading branch information
apoelstra committed Apr 18, 2024
2 parents 7a8dafb + 3a2d86e commit 3aecf94
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion bitcoin/examples/sign-tx-segwit-v0.rs
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ fn main() {
let sighash_type = EcdsaSighashType::All;
let mut sighasher = SighashCache::new(&mut unsigned_tx);
let sighash = sighasher
.p2wpkh_signature_hash(input_index, &dummy_utxo.script_pubkey, SPEND_AMOUNT, sighash_type)
.p2wpkh_signature_hash(input_index, &dummy_utxo.script_pubkey, DUMMY_UTXO_AMOUNT, sighash_type)
.expect("failed to create sighash");

// Sign the sighash using the secp256k1 library (exported by rust-bitcoin).
Expand Down

0 comments on commit 3aecf94

Please sign in to comment.