upleb.uk

Public git repos — served from a NIP-34 GRASP relay at git.upleb.uk

summaryrefslogtreecommitdiff
path: root/src/net.h
diff options
context:
space:
mode:
authormtg0001 <106211915+mtg0001@users.noreply.github.com>2026-08-02 10:56:50 -0300
committerGitHub <noreply@github.com>2026-08-02 10:56:50 -0300
commit89f6d045c8e3dacbfbb369a3ac89c0c33de22b4c (patch)
tree3ff7c5ed2c0814a51e5746320f42bfe9c893c56b /src/net.h
parentee340c535dd26c034e18c4d97bf225a56bf91f6f (diff)
Keep HD change recoverable and bound message stalls (#109)
Change from an HD wallet now goes to a newly derived phrase-backed key instead of reusing a spent input's key. Reusing an input key silently moved value back to a key the phrase cannot reproduce; if derivation fails the transaction is refused rather than creating unrecoverable change. Legacy wallets with no seed keep the 0.1.0 behaviour. Restore also scans past the pre-generated key-pool window before treating an empty batch as the end. The message parser no longer consumes a header it cannot complete: it reads from a copy, so the O(n) reinsert and the 100 ms sleep inside the shared message thread are gone, and a peer that sits on an incomplete payload is disconnected after two minutes. The wire cap drops from 256 MB to MAX_SIZE. New net-message self-test covers complete, incomplete, stale and oversized headers. Verified here: clean rebuild, all self-tests pass, lock order checked (no path takes cs_keyPool before cs_mapWallet), and a node built from this branch synced from genesis to the chain tip on the live network with zero rejections.
Diffstat (limited to 'src/net.h')
-rw-r--r--src/net.h15
1 files changed, 14 insertions, 1 deletions
diff --git a/src/net.h b/src/net.h
index 1c0c24e..37f335e 100644
--- a/src/net.h
+++ b/src/net.h
@@ -67,6 +67,13 @@ static const int BTF_RECV_TIMEOUT_SECS = 30 * 60;
67static const int BTF_SEND_STALL_SECS = 10 * 60; 67static const int BTF_SEND_STALL_SECS = 10 * 60;
68static const int BTF_HANDSHAKE_GRACE_SECS = 60; 68static const int BTF_HANDSHAKE_GRACE_SECS = 60;
69 69
70// A serialized object cannot be larger than MAX_SIZE, so no valid network
71// message needs the old 256 MB header allowance. Keep the wire cap aligned with
72// what the deserializer can accept and bound how long one peer may sit on a
73// partial payload after a complete header has arrived.
74static const unsigned int MAX_PROTOCOL_MESSAGE_SIZE = MAX_SIZE;
75static const int BTF_INCOMPLETE_MESSAGE_TIMEOUT_SECS = 2 * 60;
76
70// Ceiling on simultaneous connections. 77// Ceiling on simultaneous connections.
71// 78//
72// ThreadSocketHandler watches every peer through one select(), and select() 79// ThreadSocketHandler watches every peer through one select(), and select()
@@ -225,7 +232,7 @@ public:
225 } 232 }
226 233
227 // Message size 234 // Message size
228 if (nMessageSize > 0x10000000) 235 if (nMessageSize > MAX_PROTOCOL_MESSAGE_SIZE)
229 { 236 {
230 if (LogAcceptsCategory("net")) printf("CMessageHeader::IsValid() : nMessageSize too large %u\n", nMessageSize); 237 if (LogAcceptsCategory("net")) printf("CMessageHeader::IsValid() : nMessageSize too large %u\n", nMessageSize);
231 return false; 238 return false;
@@ -596,6 +603,9 @@ public:
596 int64 nLastSend; 603 int64 nLastSend;
597 int64 nLastRecv; 604 int64 nLastRecv;
598 int64 nLastSendEmpty; 605 int64 nLastSendEmpty;
606 int64 nIncompleteMessageStart;
607 unsigned int nIncompleteMessageSize;
608 string strIncompleteMessageCommand;
599 609
600 // Height this peer announced in its version message, or -1 if it sent a 610 // Height this peer announced in its version message, or -1 if it sent a
601 // version message that predates the field. Knowing how far along everyone 611 // version message that predates the field. Knowing how far along everyone
@@ -626,6 +636,9 @@ public:
626 nLastSend = 0; 636 nLastSend = 0;
627 nLastRecv = 0; 637 nLastRecv = 0;
628 nLastSendEmpty = GetTime(); 638 nLastSendEmpty = GetTime();
639 nIncompleteMessageStart = 0;
640 nIncompleteMessageSize = 0;
641 strIncompleteMessageCommand.clear();
629 nStartingHeight = -1; 642 nStartingHeight = -1;
630 vfSubscribe.assign(256, false); 643 vfSubscribe.assign(256, false);
631 644