What was copied, from where, and what was deliberately left behind. The plan
(docs/PLAN.md, "Copying from btcd and nostrino") commits to this list; this
file is the record that it was done, with the file names.
~/go/pkg/mod/github.com/btcsuite/btcd@v0.24.2)| file | what was taken | what was left |
|---|---|---|
wire/msgblock.go | the header-then-CompactSize-transactions shape; the 4 MB MaxBlockPayload ceiling; the coinbase-first check | BtcDecode's MerkleRoot computation on the header struct; the btcutil-level failure builders |
wire/msgtx.go | the segwit marker/flag rule (zero input count, then flag 0x01), the witness stack per input, the txid over the non-witness form, the 10,000-byte script ceiling | input/output value range checks, TxHash without witness, btcutil hashing helpers |
wire/blockheader.go | the 80-byte header layout: version, prev, merkle root, time, bits, nonce | the header codec's error taxonomy; the 164-byte XBT header is not in btcd at all |
wire/common.go | CompactSize read/write, canonical-encoding rejection, DoubleSha256Idx for merkle levels | the per-field decoder and error path for each message |
wire/message.go (concepts) | the validation that a block's transaction stream ends at its last tx and has no trailing bytes | the message registry and dispatcher |
btcd's blockchain, database, indexers, mempool and blockManager relay
logic are not copied: the first three are validation and storage this
program does not do, and the relay loop here is smaller than btcd's because it
has no orphan pool and no block-request bookkeeping to keep.
| package | why it is imported rather than copied |
|---|---|
pkg/neutrino | the header chain, the XBT v2 header rule (checkForkHeader), the 22-bit TargetShift at HeaderV2Height, difficulty and median-time-past, Truncate for reorgs, ApplyHeaders for imports. One implementation of the fork rules, in the repository that already has the fork's vectors. |
pkg/chain | the Profile type and the xbt profile's constants. |
pkg/crypto/chainhash | the hash type both sides agree on. |
pkg/filter | the Golomb-coded set, BIP158 N=19, M=784931, with the official vectors. Reimplementing it would give two implementations of a wire format that must be byte-identical. |
A filter needs the raw scriptPubKey bytes and the OP_RETURN first-opcode
test; nothing else.
164-byte header, its ForkHash and its retarget shift live in nostrino's
pkg/btcwire/fork.go and pkg/neutrino/pow.go, which this program imports.
WireError, RuleError and the btcjson error surface. This program returns fmt.Errorf-wrapped sentinels
(internal/wire's ErrShort, ErrTrailing, and the rest).
pkg/p2p.Conn.ReadUntil reads frames until it finds the command it is waiting
for and silently drops everything else. That is right for a client that only
ever receives replies to its own requests, and it is why the transaction relay
cannot share a lane's connection: a peer answering an inv with getdata would
have that request read and discarded while the lane waits for a headers or a
block. The replay/relay pool therefore owns its connections, its reader and
its queue, and never calls into a lane. That decision is what phase 5's relay
builds on.