Merge rust-bitcoin/rust-bitcoin#2696: Fix example spend amount

3a2d86e0c6 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 3a2d86e0c6
  apoelstra:
    ACK 3a2d86e0c6
  sanket1729:
    ACK 3a2d86e0c6

Tree-SHA512: dbd25c0adb2b0cd3ddd61893ce0c057edd7d62aad6a380b19b1e10ae1b8f0f22d81c15c3c7e2bb64a1740b1b6a7b096aaadab8040e507b73fef0bc2a1638d827
This commit is contained in:
Andrew Poelstra 2024-04-18 19:07:41 +00:00
commit 3aecf94205
No known key found for this signature in database
GPG Key ID: C588D63CE41B97C1
1 changed files with 1 additions and 1 deletions

View File

@ -61,7 +61,7 @@ fn main() {
let sighash_type = EcdsaSighashType::All; let sighash_type = EcdsaSighashType::All;
let mut sighasher = SighashCache::new(&mut unsigned_tx); let mut sighasher = SighashCache::new(&mut unsigned_tx);
let sighash = sighasher 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"); .expect("failed to create sighash");
// Sign the sighash using the secp256k1 library (exported by rust-bitcoin). // Sign the sighash using the secp256k1 library (exported by rust-bitcoin).