Skip to content

Commit 08b7c61

Browse files
committed
private broadcast: enforce sending to unique node ids
Sending more than one transaction to a given node would be a privacy leak and thus enforce that this is not done. `GetSendStatusByNode()` assumes unique node ids. Note that sending more than one transaction to a given address is fine, if that is done via separate connections, in which case the node ids would be different.
1 parent 0f156c1 commit 08b7c61

2 files changed

Lines changed: 8 additions & 1 deletion

File tree

‎src/private_broadcast.cpp‎

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,11 @@ std::optional<CTransactionRef> PrivateBroadcast::PickTxForSend(const NodeId& wil
3333
{
3434
LOCK(m_mutex);
3535

36+
if (GetSendStatusByNode(will_send_to_nodeid).has_value()) { // nodeid reuse, shouldn't send >1 tx to a given node
37+
Assume(false);
38+
return std::nullopt;
39+
}
40+
3641
const auto it{std::ranges::max_element(
3742
m_transactions,
3843
[](const auto& a, const auto& b) { return a < b; },

‎src/private_broadcast.h‎

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,9 @@ class PrivateBroadcast
7373
* Pick the transaction with the fewest send attempts, and confirmations,
7474
* and oldest send/confirm times.
7575
* @param[in] will_send_to_nodeid Will remember that the returned transaction
76-
* was picked for sending to this node.
76+
* was picked for sending to this node. Calling this method more than once with
77+
* the same `will_send_to_nodeid` is not allowed because sending more than one
78+
* transaction to one node would be a privacy leak.
7779
* @param[in] will_send_to_address Address of the peer to which this transaction
7880
* will be sent.
7981
* @return Most urgent transaction or nullopt if there are no transactions.

0 commit comments

Comments
 (0)