ElementsProject / libwally-core

Useful primitives for wallets
Other
284 stars 136 forks source link

Finalizing a psbt with 4 inputs creates an invalid hex transaction #251

Open Fonta1n3 opened 3 years ago

Fonta1n3 commented 3 years ago

Hi,

I have a 2 of 3 segwit multisig wallet. When I create a psbt with 4 inputs and finalize it with Libwally 0.8.0 the raw hex gets rejected by Bitcoin Core bitcoin-cli testmempoolaccept with an error: bad-witness-nonstandard

It seems to work just fine with 3 inputs or less though.

This is a mainnet wallet and I do not want to lose privacy by sharing the data. I will attempt to create a testnet tx and share the details here later.

jgriffiths commented 3 years ago

Hi @Fonta1n3 its more likely to be one specific input that isn't working rather than the number of inputs to the PSBT. If you find the input that causes it to fail, please update here with the type of input, it may be one that wally doesn't know how to finalise.

Fonta1n3 commented 3 years ago

hmm well all my inputs are native segwit 2/3 multisig... I will have to dedicate some more time to trying to replicate it and will try and provide more detail.

Fonta1n3 commented 3 years ago

This is still plaguing me.

In addition to greater then three p2wsh musig inputs finalizing into an invalid hex transaction I have the below issues:

I get all kinds of odd behavior around finalizing psbt's with Libwally.

Sometimes it can convert the psbt to hex, sometimes it can't (for the same psbt which has all sigs), sometimes it recognizes as complete and sometimes it does not, again for the same psbt.

jgriffiths commented 3 years ago

@Fonta1n3 please attach one or more testnet/regtest examples and the specific incorrect behaviour you see with each.

Fonta1n3 commented 3 years ago

@Fonta1n3 please attach one or more testnet/regtest examples and the specific incorrect behaviour you see with each.

I have tried to replicate on testnet many times with no luck.

jgriffiths commented 3 years ago

@Fonta1n3 If you have a mainnet example that errors on finalise with wally but does finalise with core, once you have finalized and broadcast it, you can PGP email it to me at my email after verifying it does not contain any key material/secret data in extended fields.

If that is not acceptable to you, are you able to step through the finalisation of one of these examples in gdb and find the line that is failing (returning an error code)?

For the cases where wally finalises the psbt but the tx is invalid, again if you PGP email me the psbt after the inputs have been spent I can probably debug this. Otherwise/and if you can PGP email me the invalid hex tx that results I can try to debug that (this would be easier with the successful tx finalized by core to compare to).

For your privacy please do not post mainnet examples here on github or email them unencrypted.