forked from bitcoin/bitcoin
-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge bitcoin#26616: [24.x] Backports for 24.0.1
8b726bf test: Coin Selection, duplicated preset inputs selection (furszy) 9d73176 test: wallet, coverage for CoinsResult::Erase function (furszy) 195f0df wallet: bugfix, 'CoinsResult::Erase' is erasing only one output of the set (furszy) e5d097b [test] Add p2p_tx_privacy.py (dergoegge) c842670 [net processing] Assume that TxRelay::m_tx_inventory_to_send is empty pre-verack (dergoegge) e15b306 [net processing] Ensure transaction announcements are only queued for fully connected peers (dergoegge) 95fded1 wallet: Explicitly say migratewallet on encrypted wallets is unsupported (Andrew Chow) d464b2a tests: Test for migrating encrypted wallets (Andrew Chow) 7a97a56 wallet: Avoid null pointer deref when cleaning up migratewallet (Andrew Chow) Pull request description: Backports remaining changes on the 24.0.1 milestone. Currently backports: * bitcoin#26594 * bitcoin#26569 * bitcoin#26560 ACKs for top commit: josibake: ACK bitcoin@8b726bf Tree-SHA512: db77ec1a63a7b6a4412750a0f4c0645681fc346a5df0a7cd38d5d27384e1d0fa95f3953af90042afe131ddbd4b6a6e009527095f13e9f58c0190cd378738a9e5
- Loading branch information
Showing
11 changed files
with
254 additions
and
13 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,78 @@ | ||
#!/usr/bin/env python3 | ||
# Copyright (c) 2022 The Bitcoin Core developers | ||
# Distributed under the MIT software license, see the accompanying | ||
# file COPYING or http://www.opensource.org/licenses/mit-license.php. | ||
""" | ||
Test that transaction announcements are only queued for peers that have | ||
successfully completed the version handshake. | ||
Topology: | ||
tx_originator ----> node[0] <---- spy | ||
We test that a transaction sent by tx_originator is only relayed to spy | ||
if it was received after spy's version handshake completed. | ||
1. Fully connect tx_originator | ||
2. Connect spy (no version handshake) | ||
3. tx_originator sends tx1 | ||
4. spy completes the version handshake | ||
5. tx_originator sends tx2 | ||
6. We check that only tx2 is announced on the spy interface | ||
""" | ||
from test_framework.messages import ( | ||
msg_wtxidrelay, | ||
msg_verack, | ||
msg_tx, | ||
CInv, | ||
MSG_WTX, | ||
) | ||
from test_framework.p2p import ( | ||
P2PInterface, | ||
) | ||
from test_framework.test_framework import BitcoinTestFramework | ||
from test_framework.wallet import MiniWallet | ||
|
||
class P2PTxSpy(P2PInterface): | ||
def __init__(self): | ||
super().__init__() | ||
self.all_invs = [] | ||
|
||
def on_version(self, message): | ||
self.send_message(msg_wtxidrelay()) | ||
|
||
def on_inv(self, message): | ||
self.all_invs += message.inv | ||
|
||
def wait_for_inv_match(self, expected_inv): | ||
self.wait_until(lambda: len(self.all_invs) == 1 and self.all_invs[0] == expected_inv) | ||
|
||
class TxPrivacyTest(BitcoinTestFramework): | ||
def set_test_params(self): | ||
self.num_nodes = 1 | ||
|
||
def run_test(self): | ||
self.wallet = MiniWallet(self.nodes[0]) | ||
self.wallet.rescan_utxos() | ||
|
||
tx_originator = self.nodes[0].add_p2p_connection(P2PInterface()) | ||
spy = self.nodes[0].add_p2p_connection(P2PTxSpy(), wait_for_verack=False) | ||
spy.wait_for_verack() | ||
|
||
# tx_originator sends tx1 | ||
tx1 = self.wallet.create_self_transfer()["tx"] | ||
tx_originator.send_and_ping(msg_tx(tx1)) | ||
|
||
# Spy sends the verack | ||
spy.send_and_ping(msg_verack()) | ||
|
||
# tx_originator sends tx2 | ||
tx2 = self.wallet.create_self_transfer()["tx"] | ||
tx_originator.send_and_ping(msg_tx(tx2)) | ||
|
||
# Spy should only get an inv for the second transaction as the first | ||
# one was received pre-verack with the spy | ||
spy.wait_for_inv_match(CInv(MSG_WTX, tx2.calc_sha256(True))) | ||
|
||
if __name__ == '__main__': | ||
TxPrivacyTest().main() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters