Skip to content

On-chain Tx Improvement #10

@pingu-73

Description

@pingu-73

Overview

Enhance the on-chain Bitcoin transaction functionality with better UTXO selection algorithms and Replace-by-Fee (RBF) support.

Current State

  • basic P2WPKH tx building and signing
  • multi-source fee estimation with fallback
  • dust threshold and minimum relay fee handling (NOTE: Implemented but haven't tested)
  • simple largest first UTXO selection
  • RBF flag enabled but no bumping logic

TODO

  • Improve UTXO Selection Algorithm

  • File: backend/src/services/onchain/utxo_manager.rs

  • currently using largest first selection, which can:

    • Create unnecessary change outputs
    • Reduce privacy by consolidating UTXOs
    • Lead to suboptimal fee efficiency
  • Sub-Tasks

    • Implement Branch and Bound algorithm for exact matches
    • Add privacy-focused selection (avoid address reuse patterns)
    • Implement coin selection strategies (smallest-first for small payments)
    • Add tests comparing selection algorithms
  • Ref:


  • Implement RBF (Replace by Fee) Support

  • File: backend/src/services/onchain/transaction_builder.rs, backend/src/api/wallet.rs

  • currently setting ENABLE_RBF_NO_LOCKTIME but missing:

    • Fee bumping logic
    • API endpoints for RBF
    • Tx replacement validation
  • Sub-Tasks

    • Add bump_fee() method to TransactionBuilder
    • Implement fee rate increase validation (BIP 125 rules)
    • Add API endpoint /api/wallet/bump-fee
    • Handle mempool conflict detection
    • Add RBF status tracking in transaction history
  • Ref:

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions