Skip to content

FIX manual transaction prioritization to submit missing transactions … - #310

Open
sh1vam31 wants to merge 1 commit into
dmnd-pool:masterfrom
sh1vam31:fix-manual-prioritization-invalid-txs
Open

sh1vam31 wants to merge 1 commit into
dmnd-pool:masterfrom
sh1vam31:fix-manual-prioritization-invalid-txs

Conversation

@sh1vam31

@sh1vam31 sh1vam31 commented Nov 7, 2026

Copy link
Copy Markdown

Fixes: #295

Summary

Previously, manual transaction prioritisation (POST /api/tx/prioritize/:txid/:fee_delta) applied the fee delta in Bitcoin Core and recorded it immediately. It did not check whether the transaction was actually in the node's mempool. If an invalid or missing transaction was prioritised, Bitcoin Core kept the fee delta, but the transaction could not be mined.

Following the pattern established in #294, this PR verifies that manually prioritised transactions exist in the mempool. If a transaction is missing, it is fetched from mempool.space and submitted to the node. If submission fails, the fee delta is restored, and the transaction is recorded in the BAD_TRANSACTIONS cache.

Key Changes

  1. Mempool Verification:
    • In src/api/routes.rs, added ensure_prioritized_transaction_in_mempool to verify in_mempool via get_prioritised_transactions() after applying the fee delta.
  2. Fallback Fetch and Submission:
    • If the transaction is not in the mempool, the client fetches the raw transaction hex from mempool.space and submits it via rpc.submit_transaction().
  3. Failure Restoration and Bad Transaction Caching:
    • If fetching or submission fails, the client:
      • Reverses the fee delta in Bitcoin Core (prioritise_transaction(&txid, -fee_delta)).
      • Records the transaction in BAD_TRANSACTIONS.
      • Clears the node view cache and returns 400 Bad Request.
  4. PrioritizingTxs Configuration:
    • Added constructors to PrioritizingTxs to cleanly support test and custom mempool.space endpoints.
  5. Unit Tests:
    • Added manual_prioritization_of_invalid_tx_not_in_mempool_restores_and_records_bad_tx.
    • Added manual_prioritization_fetches_and_submits_missing_mempool_transaction.
    • Updated existing test mock to handle getprioritisedtransactions.

Verification

  • cargo test --lib api::routes (14/14 passed)
  • rustfmt --edition 2021 src/lib.rs src/main.rs src/api/mod.rs src/api/routes.rs
  • cargo clippy --lib --bin dmnd-client --all-features -- -D warnings (clean, zero warnings)

@sh1vam31

Copy link
Copy Markdown
Author

Hi @lorbax, @Fi3
Ready for review.
This implements the missing mempool check, mempool.space fallback submission, and bad transaction cache restoration for manual prioritisation, as described in #295. All tests and clippy checks pass. Thank you.

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.

manual prioritization of invalid txs

1 participant