karask / python-bitcoin-utils

Library to interact with the Bitcoin network. Ideal for low-level learning and experimenting.
MIT License
271 stars 102 forks source link

Example of P2SH-P2WSH spending #50

Closed jainanubha closed 1 year ago

jainanubha commented 1 year ago

To lock a P2SH-P2WSH transaction, I have used following scripts:

p2wsh witness script - Script(['OP_2', private_key1.get_public_key().to_hex(), private_key2.get_public_key().to_hex(),'OP_2', 'OP_CHECKMULTISIG'])"

P2Sh script - OP_0, 'OP_HASH160', sha256(p2wsh witness script), 'OP_EQUAL'

Please provide an example for spending the same.

YashvirGaming commented 1 year ago

12 seeds phrases ?

karask commented 1 year ago

@jainanubha I added two examples for this. One to send to a P2SH-P2WSH and one to spend it.

@YashvirGaming Not related to this issue but you can consult the test_keys.py file that contains an example on how to get keys from a mnemonic. I will add an example next time I spend some time with the library.