ElementsProject / lightning

Core Lightning — Lightning Network implementation focusing on spec compliance and performance
Other
2.8k stars 889 forks source link

bitcoind: bad-txns-inputs-missingorspent on sendrawtransaction #7172

Open vincenzopalazzo opened 4 months ago

vincenzopalazzo commented 4 months ago

I did not debug how this is possible but it is better to store this error somewhere


 error: {\\\"code\\\":-25,\\\"message\\\":\\\"bad-txns-inputs-missingorspent\\\"}\") })
2024-03-25T14:05:44.178Z DEBUG   lightningd: Expected error broadcasting tx 020000000001018c9e9f69341019c959b5526231e2bd52bd1e7227a3b72fa40e095ed283b7ddbb0000000000cae9f0800199c20000000000002200203251c1d74d76a6a487afca13913bc09fb3cc766e12efe938c049a1c432316bcf040047304402201a96b84a9e234172ade0f055be867097ac480c2d21f8163f449bde67266dda15022060fe38faed61d573db32ab5d48a3a9eff1f9e27f7adc51e86cb7b22878aad66a014730440220764c985c44e8ae0e303c46588090dea100c997b42ba9bdec7fa66bc68f5cc1fe02205200f62950b4ac4d8a297a97bb30fdc92edd43f5fccaf35b31a46e6963f42f4d0147522102b7c0c24f0a4ed6880289c17132f63c7a9ace2db1dfbc0baaf03a19916cfc867e210382323ae01328ab397c250a3120567531e76970a8c88795cac03e488dafe81b4252ae8ea0b720: [400] Unknown error (sendrawtransaction RPC error: {\"code\":-25,\"message\":\"bad-txns-inputs-missingorspent\"})
cdecker commented 1 month ago

It literally says that this failure is expected because we are sending a conflicting commitment tx to the peers close.

vincenzopalazzo commented 1 month ago

Well not quite, this problem was because the wallet of cln is tracking spent tx and it is putting inside the funding transaction.

So this is a bug of our dev- commands that need to be fixed somehow, I think I provided some idea in here https://github.com/vincenzopalazzo/lightning/commit/6e2ab0217eb2e6ffd37297cffedf59e2d8b3a083

vincenzopalazzo commented 1 month ago

Sorry if I reopen this again @cdecker but my node fall in this state again, so I think we need to look at https://github.com/ElementsProject/lightning/pull/7296

northben commented 2 weeks ago

I believe I have the same issue. I see log messages like

lightningd: Expected error broadcasting tx 02000000000102e2fed46a...b268c6fd0c00: error code: -25\nerror message:\nbad-txns-inputs-missingorspent

and I have some channels with active HTLCs that are being force closed.

vincenzopalazzo commented 2 weeks ago

I have experience in debugging this issue, could you shoot me an email with your description of the problem?

Because if also you fall in this case we should do something about it

northben commented 2 weeks ago

alright I believe I've figured this out. I was using clboss on my node, and has set these channels to be unmanaged by clboss.

lightning-cli clboss-unmanage <the_node_id> lnfee

I just happened to run lightning-cli listpeerchannels and found a HTLC with state: Waiting for the htlc_accepted hook of plugin clboss

I disabled the clboss plugin completely and the HTLC state is now SENT_REMOVE_HTLC.

I'm not sure if I had misconfigured clboss somehow but I'm going to be extremely careful before I enable it again, and also learned to watch the htlc status in listpeerchannels.

Thank you everyone for building on Bitcoin!