Skip to content

Can't build a fee bump transaction if spending a P2A output #325

@PeteClubSeven

Description

@PeteClubSeven

Describe the bug
In Bark we create TRUC transactions using ephemeral anchors to perform unilateral exits. The parent transaction in the TRUC originates outside of the wallet and we use BDK's tx builder to create a child transaction that spends the P2A output. Currently the fee system can't calculate the effective fee rate of the TRUC package and that is fine, we work around it by looping and calculating an absolute fee based on the generated child transaction.

The problem we do have is that if we wish to RBF the child transaction from the same users wallet we are unable to use build_fee_bump because the P2A spend input doesn't originate from the users wallet. Unfortunately I can't find a method to remove the unconfirmed TRUC child from the wallet to then generate a new one and reuse the existing UTXOs. This puts us in a situation where we have to recommend users keep multiple UTXOs spare for the purpose of fee bumping which isn't necessarily ideal in an emergency unilateral exit situation.

To Reproduce

  1. Create a transaction with a ephemeral anchor output outside the wallet
  2. Use build_tx to start building a new transaction with the wallet
  3. Use add_foreign_utxo to add the P2A spend as an input into the child transaction
  4. Finish creating the transaction and persist it in the wallet
  5. Use build_fee_bump to create an RBF transaction with the TX ID of the newly created child transaction
  6. Notice that an error is returned because the origin of the P2A spend input isn't the wallet itself

Expected behavior
If I use a foreign UTXO when building a transaction I should be able to use build_fee_bump to RBF the newly built transaction. Having some way to specify an input as foreign to bypass the UTXO checks would be ideal, alternatively if I could remove the unconfirmed transaction from the history of the wallet entirely that would also be helpful.

Build environment

  • BDK tag/commit: v2.1.0
  • OS+version: MacOS 15.5
  • Rust/Cargo version 1.88
  • Rust/Cargo target: aarch64-apple-darwin

Which backend(s) are relevant (if any)?

  • Electrum
  • Esplora
  • Bitcoin Core RPC
  • None / not backend-related (e.g. bdk_chain, bdk_core)
  • Other (please specify): ____

Is this blocking production use?

  • Yes
  • No

Project or organization (optional)
Second

Additional context
Some logs showing the error:

Attempting to bump the fee of wallet tx b7572a182ccf392634a5178010cfd4e48bee7ccb72b58a0e8d086c5e87810e7e for exit 48a0caba9f5ec585d1c26e5c9edf3c36cf26e7f66b7254e044e33f1ed85233e4

Error creating signed P2A CPFP: Failed to bump wallet tx b7572a182ccf392634a5178010cfd4e48bee7ccb72b58a0e8d086c5e87810e7e: UTXO not found in the internal database with txid: 48a0caba9f5ec585d1c26e5c9edf3c36cf26e7f66b7254e044e33f1ed85233e4, vout: 1

Links to our code:

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    Status

    Discussion

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions