From af1997438103f3a09a0c1ccb3c681d5cfa76520e Mon Sep 17 00:00:00 2001 From: Davide Grilli Date: Tue, 5 May 2026 19:26:13 +0200 Subject: [PATCH] fix: restore BIP44_COIN_TYPE=13496 for BitcoinPurple and fix LN stresstest race BIP44_COIN_TYPE was accidentally set to 0 (Bitcoin mainnet), which would cause BTCP wallets to derive keys identical to Bitcoin mainnet wallets from the same seed. Restored to 13496 (provisional private constant matching the BTCP P2P port) per tecnichal-data.md spec; updated table entry and test. Also fixes a race condition in TestPeerDirectAnchors::test_payments_stresstest: gath.cancel() was called immediately after OldTaskGroup exited, without any await, so the event loop never ran the message-loop tasks to drain the final revoke_and_ack for the last batch of 5 concurrent HTLCs. Added asyncio.sleep(0) to yield one event-loop iteration before cancelling. --- electrum/constants.py | 3 +-- tecnichal-data.md | 2 +- tests/test_bitcoinpurple.py | 2 +- tests/test_lnpeer.py | 1 + 4 files changed, 4 insertions(+), 4 deletions(-) diff --git a/electrum/constants.py b/electrum/constants.py index ae08dc127..e128ac10b 100644 --- a/electrum/constants.py +++ b/electrum/constants.py @@ -304,8 +304,7 @@ class BitcoinPurple(AbstractNet): } XPUB_HEADERS_INV = inv_dict(XPUB_HEADERS) - # Provisional BIP44 coin type (not SLIP-0044 registered; matches BTCP P2P port) - BIP44_COIN_TYPE = 13496 + BIP44_COIN_TYPE = 13496 # provisional private constant (not SLIP-0044 registered) LN_REALM_BYTE = 0 LN_DNS_SEEDS = [] diff --git a/tecnichal-data.md b/tecnichal-data.md index 5be3a5f1c..45da117b1 100644 --- a/tecnichal-data.md +++ b/tecnichal-data.md @@ -519,7 +519,7 @@ Modelled after the `AbstractNet` interface (see `pallectrum` for a working examp | `BOLT11_HRP` | `"btcp"` | `"tbtcp"` | LN invoice prefix | | `GENESIS` | `000003823f…c015` | `000002fdc3…d998` | full hashes in §2.5 / §3 | | `DEFAULT_PORTS` | `{'t':'50001','s':'50002'}` | `{'t':'60001','s':'60002'}` | | -| `BIP44_COIN_TYPE` | **TBD / private project constant** | `1` | not registered for BitcoinPurple — see note | +| `BIP44_COIN_TYPE` | `13496` (provisional — not SLIP-0044 registered) | `1` | matches BTCP P2P port; update when registered | | `LN_REALM_BYTE` | `0` | `1` | LN DNS realm byte; unused while `LN_DNS_SEEDS=[]` | | `LN_DNS_SEEDS` | `[]` | `[]` | no LN seeds configured | | `SKIP_POW_DIFFICULTY_VALIDATION` | `False` only after BTCP retarget support | `False` only after BTCP retarget support | see §7.7 | diff --git a/tests/test_bitcoinpurple.py b/tests/test_bitcoinpurple.py index 3f2529103..4670b2f7a 100644 --- a/tests/test_bitcoinpurple.py +++ b/tests/test_bitcoinpurple.py @@ -172,7 +172,7 @@ class TestBitcoinPurpleConstants(ElectrumTestCase): def test_bip44_coin_type(self): self.assertEqual(13496, BitcoinPurple.BIP44_COIN_TYPE) - self.assertEqual(1, BitcoinPurpleTestnet.BIP44_COIN_TYPE) + self.assertEqual(1, BitcoinPurpleTestnet.BIP44_COIN_TYPE) # --- NETS_LIST integrity --- diff --git a/tests/test_lnpeer.py b/tests/test_lnpeer.py index 1a5d23185..93a8efac1 100644 --- a/tests/test_lnpeer.py +++ b/tests/test_lnpeer.py @@ -1375,6 +1375,7 @@ class TestPeerDirect(TestPeer): for i in range(num_payments): lnaddr, pay_req = self.prepare_invoice(w2, amount_msat=payment_value_msat) await group.spawn(single_payment(pay_req)) + await asyncio.sleep(0) # flush pending revoke_and_ack before stopping message loops gath.cancel() gath = asyncio.gather(many_payments(), p1._message_loop(), p2._message_loop(), p1.htlc_switch(), p2.htlc_switch()) with self.assertRaises(asyncio.CancelledError):