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
This commit is contained in:
Tobin C. Harding 2024-04-18 09:16:17 +10:00
parent 7a8dafb748
commit 3a2d86e0c6
No known key found for this signature in database
GPG Key ID: 40BF9E4C269D6607
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).