From 3a2d86e0c6f110d700624e3a84fd076a19c25b29 Mon Sep 17 00:00:00 2001 From: "Tobin C. Harding" Date: Thu, 18 Apr 2024 09:16:17 +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). Close: #2680 --- bitcoin/examples/sign-tx-segwit-v0.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/bitcoin/examples/sign-tx-segwit-v0.rs b/bitcoin/examples/sign-tx-segwit-v0.rs index 6a8879d3..288eb66b 100644 --- a/bitcoin/examples/sign-tx-segwit-v0.rs +++ b/bitcoin/examples/sign-tx-segwit-v0.rs @@ -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).