lbryio / lbry-sdk

The LBRY SDK for building decentralized, censorship resistant, monetized, digital content apps.
https://lbry.com
MIT License
7.2k stars 483 forks source link

invalid transaction: 0 output tx created, fails to broadcast #3713

Open tzarebczan opened 1 year ago

tzarebczan commented 1 year ago

This was from an abandon on a 0.0001 LBC playlist claim. [odysee@hub-lbrycrd2:~/lbcd] 127 $ ./lbcctl decoderawtransaction 0100000004a44bf825fab3e3c86667df14b6a2f9433ee6e4379ccbdbea7f058b61e90a4e9f000000006a47304402202c6c2149ac2bb399f9132c94f6edae72d9843870d9fbeb1b377ef44450daa44102201095162b4e6f36381ddc750cd03c577f96c4ce84401956b7c86794827599f4d1012103514ddae488e8ffac6ee4e779454039531acf6a21d9613ff975aba827126a3666ffffffff123fb7800f5d1b269f52c80c83454919db9f39780ccc19bc63ae14be03d0b84e010000006b483045022100dfc01f754d3a48941a381f37fdf18950e28bb487296a9e3bf5bf3f421e063223022040aa1cc5f55d9d6f33b226ad741998f28ee51e68b8e3c13ec4036ec713abc4ca012103514ddae488e8ffac6ee4e779454039531acf6a21d9613ff975aba827126a3666ffffffff182e6f3be8f5f7f15a6cd24266945587a91afe66a61cace19f843c832467d3e5010000006b483045022100c40f23f2fa4e8c79a5b1101b8603a3ef597e10e39079529b2a22aa59d560673d0220696a2e74e6b72b2c79e5de169416879df6618020d1c671b8900cb426e3d8bd62012103514ddae488e8ffac6ee4e779454039531acf6a21d9613ff975aba827126a3666ffffffffebccecb976905522ad51324434808a5172a14b518474130d226ceaf9e672bc01010000006b483045022100e04a388a7d00dc4aecc425b5b30b78b6cfdb23200214eedb619a860e9128e54b02206d45fc5bdad9a174cf5901bb644c0995548da9fc0460dd2623fe7be94bff6d59012103514ddae488e8ffac6ee4e779454039531acf6a21d9613ff975aba827126a3666ffffffff0000000000 { "txid": "774ac20462788a20cb2093ebbd457bc0dfecd3c63889a528056e698e57624ff3", "version": 1, "locktime": 0, "vin": [ { "txid": "9f4e0ae9618b057feadbcb9c37e4e63e43f9a2b614df6766c8e3b3fa25f84ba4", "vout": 0, "scriptSig": { "asm": "304402202c6c2149ac2bb399f9132c94f6edae72d9843870d9fbeb1b377ef44450daa44102201095162b4e6f36381ddc750cd03c577f96c4ce84401956b7c86794827599f4d101 03514ddae488e8ffac6ee4e779454039531acf6a21d9613ff975aba827126a3666", "hex": "47304402202c6c2149ac2bb399f9132c94f6edae72d9843870d9fbeb1b377ef44450daa44102201095162b4e6f36381ddc750cd03c577f96c4ce84401956b7c86794827599f4d1012103514ddae488e8ffac6ee4e779454039531acf6a21d9613ff975aba827126a3666" }, "sequence": 4294967295 }, { "txid": "4eb8d003be14ae63bc19cc0c78399fdb194945830cc8529f261b5d0f80b73f12", "vout": 1, "scriptSig": { "asm": "3045022100dfc01f754d3a48941a381f37fdf18950e28bb487296a9e3bf5bf3f421e063223022040aa1cc5f55d9d6f33b226ad741998f28ee51e68b8e3c13ec4036ec713abc4ca01 03514ddae488e8ffac6ee4e779454039531acf6a21d9613ff975aba827126a3666", "hex": "483045022100dfc01f754d3a48941a381f37fdf18950e28bb487296a9e3bf5bf3f421e063223022040aa1cc5f55d9d6f33b226ad741998f28ee51e68b8e3c13ec4036ec713abc4ca012103514ddae488e8ffac6ee4e779454039531acf6a21d9613ff975aba827126a3666" }, "sequence": 4294967295 }, { "txid": "e5d36724833c849fe1ac1ca666fe1aa98755946642d26c5af1f7f5e83b6f2e18", "vout": 1, "scriptSig": { "asm": "3045022100c40f23f2fa4e8c79a5b1101b8603a3ef597e10e39079529b2a22aa59d560673d0220696a2e74e6b72b2c79e5de169416879df6618020d1c671b8900cb426e3d8bd6201 03514ddae488e8ffac6ee4e779454039531acf6a21d9613ff975aba827126a3666", "hex": "483045022100c40f23f2fa4e8c79a5b1101b8603a3ef597e10e39079529b2a22aa59d560673d0220696a2e74e6b72b2c79e5de169416879df6618020d1c671b8900cb426e3d8bd62012103514ddae488e8ffac6ee4e779454039531acf6a21d9613ff975aba827126a3666" }, "sequence": 4294967295 }, { "txid": "01bc72e6f9ea6c220d137484514ba172518a8034443251ad22559076b9eccceb", "vout": 1, "scriptSig": { "asm": "3045022100e04a388a7d00dc4aecc425b5b30b78b6cfdb23200214eedb619a860e9128e54b02206d45fc5bdad9a174cf5901bb644c0995548da9fc0460dd2623fe7be94bff6d5901 03514ddae488e8ffac6ee4e779454039531acf6a21d9613ff975aba827126a3666", "hex": "483045022100e04a388a7d00dc4aecc425b5b30b78b6cfdb23200214eedb619a860e9128e54b02206d45fc5bdad9a174cf5901bb644c0995548da9fc0460dd2623fe7be94bff6d59012103514ddae488e8ffac6ee4e779454039531acf6a21d9613ff975aba827126a3666" }, "sequence": 4294967295 } ], "vout": [] }

moodyjon commented 1 year ago

I've been looking at this, and it seems this could happen when the account is low on funds. Transaction code will try to add more UTXOs to cover the TX fee, but it might still produce this kind of transaction.

I've been writing a test that exposes this. I started with lots of small UTXOs. Small UTXOs tend to cause if change_amount > DUST to be false. The problem I'm encountering is that fixing this can lead to a very costly transaction requiring dozens of the small UTXOs. The cost of the TX can be many times the nominal value of the claim being abandoned.

tzarebczan commented 1 year ago

Thank you for digging in! I think it's pretty rare, must be some strange edge case. This particular user had hundreds of utxos.

moodyjon commented 1 year ago

Question was raised at meeting -- Did lbrycrd allow transactions with no outputs?

Lbrycrd appears to disallow these: https://github.com/lbryio/lbrycrd/blob/71fc94b1dea1c7818f84a09832ec3db736481e0f/src/consensus/tx_verify.cpp#L169

As does lbcd: https://github.com/lbryio/lbcd/blob/master/blockchain/validate.go#L241

tzarebczan commented 1 year ago

No, it's an invalid tx and is not broadcast.