node: extend node::TxBroadcast with a 3rd option
Extend `node::TxBroadcast` with a 3rd option to not add the transaction to the mempool and broadcast privately. This is a non-functional change - `BroadcastTransaction()` will not do anything if the 3rd options is passed and is not used by any of its callers.
This commit is contained in:
3 files changed
+13
-2
No files matched your search
@@ -74,13 +74,14 @@ TransactionError BroadcastTransaction(NodeContext& node,
|
|||||||
wtxid = mempool_tx->GetWitnessHash();
|
wtxid = mempool_tx->GetWitnessHash();
|
||||||
} else {
|
} else {
|
||||||
// Transaction is not already in the mempool.
|
// 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
|
// First, call ATMP with test_accept and check the fee. If ATMP
|
||||||
// fails here, return error immediately.
|
// fails here, return error immediately.
|
||||||
const MempoolAcceptResult result = node.chainman->ProcessTransaction(tx, /*test_accept=*/ true);
|
const MempoolAcceptResult result = node.chainman->ProcessTransaction(tx, /*test_accept=*/ true);
|
||||||
if (result.m_result_type != MempoolAcceptResult::ResultType::VALID) {
|
if (result.m_result_type != MempoolAcceptResult::ResultType::VALID) {
|
||||||
return HandleATMPError(result.m_state, err_string);
|
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;
|
return TransactionError::MAX_FEE_EXCEEDED;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -104,6 +105,8 @@ TransactionError BroadcastTransaction(NodeContext& node,
|
|||||||
node.mempool->AddUnbroadcastTx(txid);
|
node.mempool->AddUnbroadcastTx(txid);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
case TxBroadcast::NO_MEMPOOL_PRIVATE_BROADCAST:
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (wait_callback && node.validation_signals) {
|
if (wait_callback && node.validation_signals) {
|
||||||
@@ -135,6 +138,8 @@ TransactionError BroadcastTransaction(NodeContext& node,
|
|||||||
case TxBroadcast::MEMPOOL_AND_BROADCAST_TO_ALL:
|
case TxBroadcast::MEMPOOL_AND_BROADCAST_TO_ALL:
|
||||||
node.peerman->InitiateTxBroadcastToAll(txid, wtxid);
|
node.peerman->InitiateTxBroadcastToAll(txid, wtxid);
|
||||||
break;
|
break;
|
||||||
|
case TxBroadcast::NO_MEMPOOL_PRIVATE_BROADCAST:
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
return TransactionError::OK;
|
return TransactionError::OK;
|
||||||
|
|||||||
@@ -108,6 +108,9 @@ enum class TxBroadcast : uint8_t {
|
|||||||
MEMPOOL_AND_BROADCAST_TO_ALL,
|
MEMPOOL_AND_BROADCAST_TO_ALL,
|
||||||
/// Add the transaction to the mempool, but don't broadcast to anybody.
|
/// Add the transaction to the mempool, but don't broadcast to anybody.
|
||||||
MEMPOOL_NO_BROADCAST,
|
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
|
} // namespace node
|
||||||
|
|||||||
@@ -1984,6 +1984,9 @@ bool CWallet::SubmitTxMemoryPoolAndRelay(CWalletTx& wtx,
|
|||||||
case node::TxBroadcast::MEMPOOL_NO_BROADCAST:
|
case node::TxBroadcast::MEMPOOL_NO_BROADCAST:
|
||||||
what = "to mempool without broadcast";
|
what = "to mempool without broadcast";
|
||||||
break;
|
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);
|
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
|
// We must set TxStateInMempool here. Even though it will also be set later by the
|
||||||
|
|||||||
Reference in new issue
Block a user