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

[RFC]: make dev-rescan-outputs safe to use #7296

Draft
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

vincenzopalazzo
Copy link
Collaborator

@vincenzopalazzo vincenzopalazzo commented 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 issue", and thanks to @rustyrussell to waste 20 minutes debugging my problem.

But now, back to the patch description (see commits for full history)


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.

Fixes: #7172

[1] coffee-tools/folgore@6215861
Co-Developed-by: Rusty Russell rusty@rustcorp.com.au
Co-Developer-by: @niftynei

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 vincenzopalazzo force-pushed the macros/wallet-fix-dev-rescan-ouputs branch from 6e2ab02 to 15b0f16 Compare May 17, 2024 08:14
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

bitcoind: bad-txns-inputs-missingorspent on sendrawtransaction
1 participant