Adds support for the segwit transaction structure and signing of P2WPKH segwit inputs.
New functions:
sign_segwit_struct(tx, i, priv, hashcode=SIGHASH_ALL, segwit=False, amount=0): Signs input i for a segwit transaction structure. Signes the input as a legacy P2PKH if segwit==False; or as a P2WPKH input if segwit==True.
mk_p2wpkh_script(pubkey): Creates a P2WPKH script using pubkey.
Also adds the following new internal functions used by sign_segwit_struct():
mk_p2wpkh_scriptcode(pubkey); mk_p2wpkh_redeemscript(pubkey); pubkey_to_hash(pubkey); signature_form_segwit(tx, i, scriptCode, amount, hashcode=SIGHASH_ALL); mk_hashOutputs(out, hashcode=SIGHASH_ALL); mk_hashInputs(inp, hashcode=SIGHASH_ALL); serialize_signature_form_segwit(txobj).
The example from the README using legacy transactio structure still works as expected.
This is only thought of as a first start to implement segwit and so many bugs are expected and more rigorous testing is necessary and implementation of other segwit types.
Adds support for the segwit transaction structure and signing of P2WPKH segwit inputs.
New functions:
sign_segwit_struct(tx, i, priv, hashcode=SIGHASH_ALL, segwit=False, amount=0): Signs input i for a segwit transaction structure. Signes the input as a legacy P2PKH if segwit==False; or as a P2WPKH input if segwit==True.
mk_p2wpkh_script(pubkey): Creates a P2WPKH script using pubkey.
Also adds the following new internal functions used by sign_segwit_struct(): mk_p2wpkh_scriptcode(pubkey); mk_p2wpkh_redeemscript(pubkey); pubkey_to_hash(pubkey); signature_form_segwit(tx, i, scriptCode, amount, hashcode=SIGHASH_ALL); mk_hashOutputs(out, hashcode=SIGHASH_ALL); mk_hashInputs(inp, hashcode=SIGHASH_ALL); serialize_signature_form_segwit(txobj).
Example usage:
The example from the README using legacy transactio structure still works as expected.
This is only thought of as a first start to implement segwit and so many bugs are expected and more rigorous testing is necessary and implementation of other segwit types.