Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
vincenzopalazzo opened this issue Mar 25, 2024 · 0 comments · May be fixed by #7296
Open

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

vincenzopalazzo opened this issue Mar 25, 2024 · 0 comments · May be fixed by #7296
Assignees
Labels

Comments

@vincenzopalazzo
Copy link
Collaborator

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\"})
@vincenzopalazzo vincenzopalazzo self-assigned this May 7, 2024
vincenzopalazzo added a commit to vincenzopalazzo/lightning that referenced this issue May 7, 2024
Working to fix the following issue

 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\"})

The problem is that my database is marking the ouputs with
state AVAILABLE but they are spent, so we should look at the
spend height and just mark with a spent status, but due that
we can have other kind of status inside the database, it is better
that we make a double check with an external explorer.

This PR add the necessary RPC methods to fix the issue.

Link: ElementsProject#7172
Signed-off-by: Vincenzo Palazzo <vincenzopalazzodev@gmail.com>
vincenzopalazzo added a commit to vincenzopalazzo/lightning that referenced this issue May 8, 2024
This PR should be title "Never assume that some shit works". Thanks for @niftynei that wake up me and said "Hey this is a DB shit", and thanks to @rustyrussell to waste 20 minutes debugging my problem.

But now, back to the patch description

----

Working to fix the following issue

```
 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\"})
```

The issue is that my database is incorrectly marking outputs as AVAILABLE when they have actually been spent. Therefore, we should verify the spend height and appropriately label them as spent. This change will help ensure that we correctly identify the status of each UTXO. Is it certain that the UTXO is spent? Is the current status incorrect? There might also be a chance that the status is correct. To confirm, we should double-check against an external explorer.

To avoid adding an extra bitcoin core call just for this, I am adding a new dangerous dev method that will help to fix this problem, and I implemented the recovery strategy in folgore [1]

This PR adds the necessary RPC methods to fix the issue.

[1] coffee-tools/folgore@6215861

Link: ElementsProject#7172
Co-Developed-by: Rusty Russell <rusty@rustcorp.com.au>
Co-Developer-by: @niftynei
Signed-off-by: Vincenzo Palazzo <vincenzopalazzodev@gmail.com>
vincenzopalazzo added a commit to vincenzopalazzo/lightning that referenced this issue May 17, 2024
This PR should be title "Never assume that some shit works". Thanks for @niftynei that wake up me and said "Hey this is a DB shit", and thanks to @rustyrussell to waste 20 minutes debugging my problem.

But now, back to the patch description

----

Working to fix the following issue

```
 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\"})
```

The issue is that my database is incorrectly marking outputs as AVAILABLE when they have actually been spent. Therefore, we should verify the spend height and appropriately label them as spent. This change will help ensure that we correctly identify the status of each UTXO. Is it certain that the UTXO is spent? Is the current status incorrect? There might also be a chance that the status is correct. To confirm, we should double-check against an external explorer.

To avoid adding an extra bitcoin core call just for this, I am adding a new dangerous dev method that will help to fix this problem, and I implemented the recovery strategy in folgore [1]

This PR adds the necessary RPC methods to fix the issue.

[1] coffee-tools/folgore@6215861

Link: ElementsProject#7172
Co-Developed-by: Rusty Russell <rusty@rustcorp.com.au>
Co-Developer-by: @niftynei
Signed-off-by: Vincenzo Palazzo <vincenzopalazzodev@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant