Create a scriptPubKey for a pay-to-wtiness 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)
| 169 | return count |
| 170 | |
| 171 | def witness_script(use_p2wsh, pubkey): |
| 172 | """Create a scriptPubKey for a pay-to-wtiness TxOut. |
| 173 | |
| 174 | This is either a P2WPKH output for the given pubkey, or a P2WSH output of a |
| 175 | 1-of-1 multisig for the given pubkey. Returns the hex encoding of the |
| 176 | scriptPubKey.""" |
| 177 | if not use_p2wsh: |
| 178 | # P2WPKH instead |
| 179 | pubkeyhash = hash160(hex_str_to_bytes(pubkey)) |
| 180 | pkscript = CScript([OP_0, pubkeyhash]) |
| 181 | else: |
| 182 | # 1-of-1 multisig |
| 183 | witness_program = CScript([OP_1, hex_str_to_bytes(pubkey), OP_1, OP_CHECKMULTISIG]) |
| 184 | scripthash = sha256(witness_program) |
| 185 | pkscript = CScript([OP_0, scripthash]) |
| 186 | return bytes_to_hex_str(pkscript) |
| 187 | |
| 188 | def create_witness_tx(node, use_p2wsh, utxo, pubkey, encode_p2sh, amount): |
| 189 | """Return a transaction (in hex) that spends the given utxo to a segwit output. |
no test coverage detected