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)
| 222 | return count |
| 223 | |
| 224 | def 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 | |
| 239 | def 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. |
no test coverage detected