MCPcopy Create free account
hub / github.com/ElementsProject/lightning / test_bip86_deterministic_addresses

Function test_bip86_deterministic_addresses

tests/test_wallet.py:1863–1883  ·  view source on GitHub ↗

Test that BIP86 addresses are deterministic and unique

(node_factory)

Source from the content-addressed store, hash-verified

1861
1862@unittest.skipIf(TEST_NETWORK != 'regtest', "BIP86 tests are regtest-specific")
1863def test_bip86_deterministic_addresses(node_factory):
1864 """Test that BIP86 addresses are deterministic and unique"""
1865 # Create two nodes with the same mnemonic
1866 mnemonic = "abandon abandon abandon abandon abandon abandon abandon abandon abandon abandon abandon about"
1867
1868 l1 = setup_bip86_node(node_factory, mnemonic)
1869 l2 = setup_bip86_node(node_factory, mnemonic)
1870
1871 # Generate addresses with the same index
1872 addr1_0 = l1.rpc.newaddr('p2tr')['p2tr']
1873 addr2_0 = l2.rpc.newaddr('p2tr')['p2tr']
1874
1875 addr1_1 = l1.rpc.newaddr('p2tr')['p2tr']
1876 addr2_1 = l2.rpc.newaddr('p2tr')['p2tr']
1877
1878 # Addresses should be identical for the same index
1879 assert addr1_0 == addr2_0, f"Addresses for index 0 don't match: {addr1_0} != {addr2_0}"
1880 assert addr1_1 == addr2_1, f"Addresses for index 1 don't match: {addr1_1} != {addr2_1}"
1881
1882 # Addresses should be different for different indices
1883 assert addr1_0 != addr1_1, f"Addresses for different indices should be different"
1884
1885
1886@unittest.skipIf(TEST_NETWORK != 'regtest', "BIP86 tests are regtest-specific")

Callers

nothing calls this directly

Calls 2

setup_bip86_nodeFunction · 0.85
newaddrMethod · 0.45

Tested by

no test coverage detected