node: extend node::TxBroadcast with a 3rd option
What changed, and why it matters
This commit adds a new placeholder option for broadcasting Bitcoin transactions more privately, but the option is not actually used anywhere yet. It is a non-functional change that prepares the code for a future feature. There is no security issue in this patch itself.
No security action required. Treat as routine refactoring/feature scaffolding. Review the eventual follow-up commits that wire up callers and implement the actual private broadcast behavior when they appear.
Security signals we found
No strong security signals were identified.
Evidence from the diff
The change extends the node::TxBroadcast enum with a third value, NO_MEMPOOL_PRIVATE_BROADCAST, intended to skip the mempool and send transactions only over dedicated privacy-network peer connections. The implementation in BroadcastTransaction() treats this new enum value as a no-op: it does not add the transaction to the mempool and does not initiate any broadcast. The commit message explicitly states this is a non-functional change, and no callers use the new option. A wallet logging string is also added for completeness.
Changed components
src/node/transaction.cppsrc/node/types.hsrc/wallet/wallet.cppInspect captured patch +13 / −2
diff --git a/src/node/transaction.cpp b/src/node/transaction.cpp
index 4f0ee6f7..a5a3a9d9 100644
--- a/src/node/transaction.cpp
+++ b/src/node/transaction.cpp
@@ -74,13 +74,14 @@ TransactionError BroadcastTransaction(NodeContext& node,
wtxid = mempool_tx->GetWitnessHash();
} else {
// Transaction is not already in the mempool.
- if (max_tx_fee > 0) {
+ const bool check_max_fee{max_tx_fee > 0};
+ if (check_max_fee || broadcast_method == TxBroadcast::NO_MEMPOOL_PRIVATE_BROADCAST) {
// First, call ATMP with test_accept and check the fee. If ATMP
// fails here, return error immediately.
const MempoolAcceptResult result = node.chainman->ProcessTransaction(tx, /*test_accept=*/ true);
if (result.m_result_type != MempoolAcceptResult::ResultType::VALID) {
return HandleATMPError(result.m_state, err_string);
- } else if (result.m_base_fees.value() > max_tx_fee) {
+ } else if (check_max_fee && result.m_base_fees.value() > max_tx_fee) {
return TransactionError::MAX_FEE_EXCEEDED;
}
}
@@ -104,6 +105,8 @@ TransactionError BroadcastTransaction(NodeContext& node,
node.mempool->AddUnbroadcastTx(txid);
}
break;
+ case TxBroadcast::NO_MEMPOOL_PRIVATE_BROADCAST:
+ break;
}
if (wait_callback && node.validation_signals) {
@@ -135,6 +138,8 @@ TransactionError BroadcastTransaction(NodeContext& node,
case TxBroadcast::MEMPOOL_AND_BROADCAST_TO_ALL:
node.peerman->InitiateTxBroadcastToAll(txid, wtxid);
break;
+ case TxBroadcast::NO_MEMPOOL_PRIVATE_BROADCAST:
+ break;
}
return TransactionError::OK;
diff --git a/src/node/types.h b/src/node/types.h
index 6c268762..bf11c2cb 100644
--- a/src/node/types.h
+++ b/src/node/types.h
@@ -108,6 +108,9 @@ enum class TxBroadcast : uint8_t {
MEMPOOL_AND_BROADCAST_TO_ALL,
/// Add the transaction to the mempool, but don't broadcast to anybody.
MEMPOOL_NO_BROADCAST,
+ /// Omit the mempool and directly send the transaction via a few dedicated connections to
+ /// peers on privacy networks.
+ NO_MEMPOOL_PRIVATE_BROADCAST,
};
} // namespace node
diff --git a/src/wallet/wallet.cpp b/src/wallet/wallet.cpp
index d7b749bc..769ded68 100644
--- a/src/wallet/wallet.cpp
+++ b/src/wallet/wallet.cpp
@@ -1984,6 +1984,9 @@ bool CWallet::SubmitTxMemoryPoolAndRelay(CWalletTx& wtx,
case node::TxBroadcast::MEMPOOL_NO_BROADCAST:
what = "to mempool without broadcast";
break;
+ case node::TxBroadcast::NO_MEMPOOL_PRIVATE_BROADCAST:
+ what = "for private broadcast without adding to the mempool";
+ break;
}
WalletLogPrintf("Submitting wtx %s %s\n", wtx.GetHash().ToString(), what);
// We must set TxStateInMempool here. Even though it will also be set later by the
Why this scored 14/100
Community notes
Notes can correct, qualify, or add evidence to the AI analysis. Every note shown here has been validated by a human moderator.
The AI analysis stands alone for now. Submit a note if you can add evidence or important context.