Return a transaction (in hex) that spends the given utxo to a segwit output. Optionally wrap the segwit output using P2SH.
(node, use_p2wsh, utxo, pubkey, encode_p2sh, amount)
| 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. |
| 241 | |
| 242 | Optionally wrap the segwit output using P2SH.""" |
| 243 | if use_p2wsh: |
| 244 | program = keys_to_multisig_script([pubkey]) |
| 245 | addr = script_to_p2sh_p2wsh(program) if encode_p2sh else script_to_p2wsh(program) |
| 246 | else: |
| 247 | addr = key_to_p2sh_p2wpkh(pubkey) if encode_p2sh else key_to_p2wpkh(pubkey) |
| 248 | if not encode_p2sh: |
| 249 | assert_equal(node.getaddressinfo(addr)['scriptPubKey'], witness_script(use_p2wsh, pubkey)) |
| 250 | if "amount" not in utxo: |
| 251 | utxo["amount"] = node.gettxout(utxo["txid"], utxo["vout"])["value"] |
| 252 | return node.createrawtransaction([utxo], [{addr: amount}, {"fee": utxo["amount"]-amount}]) |
| 253 | |
| 254 | def send_to_witness(use_p2wsh, node, utxo, pubkey, encode_p2sh, amount, sign=True, insert_redeem_script=""): |
| 255 | """Create a transaction spending a given utxo to a segwit output. |
no test coverage detected