Skip to main content
added 52 characters in body
Source Link
karask
  • 2.5k
  • 1
  • 10
  • 20

Since it is a segwit address you should use

fromAddress2 = pub2.get_segwit_address()

Also, while taproot (segwit v1) requires the scriptPubKey when signing, segwit v0 requires the script code; i.e. a template that corresponds to the non-segwit equivalent. For example, for p2wpkh you would use as script code the p2pkh scriptPubKey.

So when signing the segwit input you shouldn't use the scriptPubKey but the p2pkh equivalent for that address. Example https://github.com/karask/python-bitcoin-utils/blob/master/examples/spend_p2wpkh_transaction.py demonstrates this.

I haven't tried these changes to your code yet, but will do with the first opportunity.

EDIT: Just tried the suggested changes it works.

PS. In the meantime, if you try it out yourself please use testmempoolaccept to test tx validity instead of just sending the tx to a node for processing. That will test tx validity without spending the outputs. If there is still an issue I can then test using the same UTXOs.

Since it is a segwit address you should use

fromAddress2 = pub2.get_segwit_address()

Also, while taproot (segwit v1) requires the scriptPubKey when signing, segwit v0 requires the script code; i.e. a template that corresponds to the non-segwit equivalent. For example, for p2wpkh you would use as script code the p2pkh scriptPubKey.

So when signing the segwit input you shouldn't use the scriptPubKey but the p2pkh equivalent for that address. Example https://github.com/karask/python-bitcoin-utils/blob/master/examples/spend_p2wpkh_transaction.py demonstrates this.

I haven't tried these changes to your code yet, but will do with the first opportunity.

PS. In the meantime, if you try it out yourself please use testmempoolaccept to test tx validity instead of just sending the tx to a node for processing. That will test tx validity without spending the outputs. If there is still an issue I can then test using the same UTXOs.

Since it is a segwit address you should use

fromAddress2 = pub2.get_segwit_address()

Also, while taproot (segwit v1) requires the scriptPubKey when signing, segwit v0 requires the script code; i.e. a template that corresponds to the non-segwit equivalent. For example, for p2wpkh you would use as script code the p2pkh scriptPubKey.

So when signing the segwit input you shouldn't use the scriptPubKey but the p2pkh equivalent for that address. Example https://github.com/karask/python-bitcoin-utils/blob/master/examples/spend_p2wpkh_transaction.py demonstrates this.

I haven't tried these changes to your code yet, but will do with the first opportunity.

EDIT: Just tried the suggested changes it works.

PS. In the meantime, if you try it out yourself please use testmempoolaccept to test tx validity instead of just sending the tx to a node for processing. That will test tx validity without spending the outputs. If there is still an issue I can then test using the same UTXOs.

Source Link
karask
  • 2.5k
  • 1
  • 10
  • 20

Since it is a segwit address you should use

fromAddress2 = pub2.get_segwit_address()

Also, while taproot (segwit v1) requires the scriptPubKey when signing, segwit v0 requires the script code; i.e. a template that corresponds to the non-segwit equivalent. For example, for p2wpkh you would use as script code the p2pkh scriptPubKey.

So when signing the segwit input you shouldn't use the scriptPubKey but the p2pkh equivalent for that address. Example https://github.com/karask/python-bitcoin-utils/blob/master/examples/spend_p2wpkh_transaction.py demonstrates this.

I haven't tried these changes to your code yet, but will do with the first opportunity.

PS. In the meantime, if you try it out yourself please use testmempoolaccept to test tx validity instead of just sending the tx to a node for processing. That will test tx validity without spending the outputs. If there is still an issue I can then test using the same UTXOs.