diff --git a/chaincfg/params_test.go b/chaincfg/params_test.go index 4166ce0a23..4d3f4d2273 100644 --- a/chaincfg/params_test.go +++ b/chaincfg/params_test.go @@ -9,6 +9,9 @@ import ( "encoding/hex" "math/big" "testing" + + "github.com/btcsuite/btcd/wire" + "github.com/stretchr/testify/require" ) // TestInvalidHashStr ensures the newShaHashFromStr function panics when used to @@ -104,6 +107,12 @@ func TestSigNetPowLimit(t *testing.T) { } } +// TestSigNetMagic makes sure that the default signet has the expected bitcoin +// network magic. +func TestSigNetMagic(t *testing.T) { + require.Equal(t, wire.SigNet, SigNetParams.Net) +} + // compactToBig is a copy of the blockchain.CompactToBig function. We copy it // here so we don't run into a circular dependency just because of a test. func compactToBig(compact uint32) *big.Int { diff --git a/wire/doc.go b/wire/doc.go index 5e03ff20a1..e05bb93552 100644 --- a/wire/doc.go +++ b/wire/doc.go @@ -86,6 +86,7 @@ the following constants: wire.MainNet wire.TestNet (Regression test network) wire.TestNet3 (Test network version 3) + wire.SigNet (Signet, default) wire.SimNet (Simulation test network) # Determining Message Type diff --git a/wire/protocol.go b/wire/protocol.go index 4ed0922b3d..b6e5ea928c 100644 --- a/wire/protocol.go +++ b/wire/protocol.go @@ -165,7 +165,7 @@ func (f ServiceFlag) String() string { // BitcoinNet represents which bitcoin network a message belongs to. type BitcoinNet uint32 -// Constants used to indicate the message bitcoin network. They can also be +// Constants used to indicate the message bitcoin network. They can also be // used to seek to the next message when a stream's state is unknown, but // this package does not provide that functionality since it's generally a // better idea to simply disconnect clients that are misbehaving over TCP. @@ -179,6 +179,10 @@ const ( // TestNet3 represents the test network (version 3). TestNet3 BitcoinNet = 0x0709110b + // SigNet represents the public default SigNet. For custom signets, + // see CustomSignetParams. + SigNet BitcoinNet = 0x40CF030A + // SimNet represents the simulation test network. SimNet BitcoinNet = 0x12141c16 ) @@ -189,6 +193,7 @@ var bnStrings = map[BitcoinNet]string{ MainNet: "MainNet", TestNet: "TestNet", TestNet3: "TestNet3", + SigNet: "SigNet", SimNet: "SimNet", } diff --git a/wire/protocol_test.go b/wire/protocol_test.go index eeeffb600a..5ab5b9dd56 100644 --- a/wire/protocol_test.go +++ b/wire/protocol_test.go @@ -49,6 +49,7 @@ func TestBitcoinNetStringer(t *testing.T) { {MainNet, "MainNet"}, {TestNet, "TestNet"}, {TestNet3, "TestNet3"}, + {SigNet, "SigNet"}, {SimNet, "SimNet"}, {0xffffffff, "Unknown BitcoinNet (4294967295)"}, }