Skip to content

Commit e311d27

Browse files
committed
fix misuse of the term redeemScript in p2wsh example
1 parent 03f2ce2 commit e311d27

File tree

1 file changed

+6
-6
lines changed

1 file changed

+6
-6
lines changed

examples/spend-p2wsh-txout.py

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -33,14 +33,14 @@
3333

3434
# Create a witnessScript and corresponding redeemScript. Similar to a scriptPubKey
3535
# the redeemScript must be satisfied for the funds to be spent.
36-
txin_witnessScript = CScript([seckey.pub, OP_CHECKSIG])
37-
txin_scriptHash = hashlib.sha256(txin_witnessScript).digest()
38-
txin_redeemScript = CScript([OP_0, txin_scriptHash])
36+
txin_redeemScript = CScript([seckey.pub, OP_CHECKSIG])
37+
txin_scriptHash = hashlib.sha256(txin_redeemScript).digest()
38+
txin_scriptPubKey = CScript([OP_0, txin_scriptHash])
3939

4040

4141
# Convert the P2WSH scriptPubKey to a base58 Bitcoin address and print it.
4242
# You'll need to send some funds to it to create a txout to spend.
43-
txin_p2wsh_address = P2WSHBitcoinAddress.from_scriptPubKey(txin_redeemScript)
43+
txin_p2wsh_address = P2WSHBitcoinAddress.from_scriptPubKey(txin_scriptPubKey)
4444
print('Pay to:', str(txin_p2wsh_address))
4545

4646
# Same as the txid:vout the createrawtransaction RPC call requires
@@ -71,7 +71,7 @@
7171

7272
# Calculate the signature hash for that transaction. Note how the script we use
7373
# is the witnessScript, not the redeemScript.
74-
sighash = SignatureHash(script=txin_witnessScript, txTo=tx, inIdx=0,
74+
sighash = SignatureHash(script=txin_redeemScript, txTo=tx, inIdx=0,
7575
hashtype=SIGHASH_ALL, amount=amount, sigversion=SIGVERSION_WITNESS_V0)
7676

7777
# Now sign it. We have to append the type of signature we want to the end, in
@@ -80,7 +80,7 @@
8080

8181

8282
# # Construct a witness for this P2WSH transaction and add to tx.
83-
witness = CScriptWitness([sig, txin_witnessScript])
83+
witness = CScriptWitness([sig, txin_redeemScript])
8484
tx.wit = CTxWitness([CTxInWitness(witness)])
8585

8686
# TODO: upgrade VerifyScript to support Segregated Witness and place verify the witness program here.

0 commit comments

Comments
 (0)