From 49ec98371ee049f41d2fa5a9ca24c391ebfe6169 Mon Sep 17 00:00:00 2001 From: "Tobin C. Harding" Date: Thu, 18 Apr 2024 09:20:16 +1000 Subject: [PATCH] Fix example spend amount 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). Also fixed in `rust-bitcoin` PR #2696. --- cookbook/src/tx_segwit-v0.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cookbook/src/tx_segwit-v0.md b/cookbook/src/tx_segwit-v0.md index 12a3993..0c683ff 100644 --- a/cookbook/src/tx_segwit-v0.md +++ b/cookbook/src/tx_segwit-v0.md @@ -204,7 +204,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).