Distinguish between bad-txns-inputs-missingorspent #29594

issue sanket1729 openend this issue on March 8, 2024
  1. sanket1729 commented at 8:18 am on March 8, 2024: contributor

    Please describe the feature you’d like to see added.

    I would like to fine grain error which informs whether the input is actually spent or if it is an orphan tx. I have logic that wants to do different things whether the parent is confirmed or not.

    Right now, the error code returned combines two scenarios where input is either missing or spent. In one scenario, I want to abandon the transaction because the input is already spent. In the other scenario, I want to resend the parent tx.

    Describe the solution you’d like

    Two different error code for the separate scenarios.

    Describe any alternatives you’ve considered

    Query bitcoin again for the parent tx state to check the state of transaction. But unfortunately, this is not applicable in my scenario because we are using bitcoind behind a Load balancer and I cannot guarantee that same bitcoind gets the request again. It would be great to have bitcoind itself return more detailed error code.

    I understand that my setup might not ideal and running stateful bitcoind with different mempools is probably not a good idea. But I feel that this finer error code is still valuable.

  2. sanket1729 added the label Feature on Mar 8, 2024
  3. glozow commented at 9:24 am on March 8, 2024: member

    An issue is that we don’t actually know if it’s missing or spent, we just don’t see the UTXO available. Knowing “spent” for certain would require querying whether the UTXO existed at some point in the past…

    I would like to fine grain error which informs whether the input is actually spent or if it is an orphan tx. I have logic that wants to do different things whether the parent is confirmed or not.

    Not sure if I’m misunderstanding the situation, but a few ideas

    • gettxspendingprevout tells you if something has a mempool conflict
    • If something is confirmed and bitcoind sees one of its outputs in the UTXO set (“txn-already-known” means “this tx already confirmed” if you want to try looking for that error).
    • The wallet has logic to see if its transactions have been conflicted by a block (see “confirmations” in rpc results).
    • Consider just resending the parent always? If it’s missing, problem solved. If it’s in mempool already, no harm done. If it’s confirmed and has an output available, “txn-already-known”. If it conflicts with something, “bad-txns-inputs-missingorspent”.
  4. sanket1729 commented at 9:29 am on March 8, 2024: contributor
    Thanks for the response. This resolves my issue
  5. sanket1729 closed this on Mar 8, 2024


github-metadata-mirror

This is a metadata mirror of the GitHub repository bitcoin/bitcoin. This site is not affiliated with GitHub. Content is generated from a GitHub metadata backup.
generated: 2024-12-21 15:12 UTC

This site is hosted by @0xB10C
More mirrored repositories can be found on mirror.b10c.me