MCPcopy Create free account
hub / github.com/ElementsProject/elements / witness_script

Function witness_script

test/functional/test_framework/blocktools.py:224–237  ·  view source on GitHub ↗

Create a scriptPubKey for a pay-to-witness TxOut. This is either a P2WPKH output for the given pubkey, or a P2WSH output of a 1-of-1 multisig for the given pubkey. Returns the hex encoding of the scriptPubKey.

(use_p2wsh, pubkey)

Source from the content-addressed store, hash-verified

222 return count
223
224def witness_script(use_p2wsh, pubkey):
225 """Create a scriptPubKey for a pay-to-witness TxOut.
226
227 This is either a P2WPKH output for the given pubkey, or a P2WSH output of a
228 1-of-1 multisig for the given pubkey. Returns the hex encoding of the
229 scriptPubKey."""
230 if not use_p2wsh:
231 # P2WPKH instead
232 pkscript = key_to_p2wpkh_script(pubkey)
233 else:
234 # 1-of-1 multisig
235 witness_script = keys_to_multisig_script([pubkey])
236 pkscript = script_to_p2wsh_script(witness_script)
237 return pkscript.hex()
238
239def create_witness_tx(node, use_p2wsh, utxo, pubkey, encode_p2sh, amount):
240 """Return a transaction (in hex) that spends the given utxo to a segwit output.

Callers 2

run_testMethod · 0.90
create_witness_txFunction · 0.70

Calls 4

key_to_p2wpkh_scriptFunction · 0.85
keys_to_multisig_scriptFunction · 0.85
script_to_p2wsh_scriptFunction · 0.85
hexMethod · 0.80

Tested by

no test coverage detected