diff --git a/chaincfg/genesis.go b/chaincfg/genesis.go index ee47b84ce4b..9cd7e174011 100644 --- a/chaincfg/genesis.go +++ b/chaincfg/genesis.go @@ -170,3 +170,31 @@ var simNetGenesisBlock = wire.MsgBlock{ }, Transactions: []*wire.MsgTx{&genesisCoinbaseTx}, } + +// sigNetGenesisHash is the hash of the first block in the block chain for the +// signet test network. +var sigNetGenesisHash = chainhash.Hash([chainhash.HashSize]byte{ // Make go vet happy. + 0xf6, 0x1e, 0xee, 0x3b, 0x63, 0xa3, 0x80, 0xa4, + 0x77, 0xa0, 0x63, 0xaf, 0x32, 0xb2, 0xbb, 0xc9, + 0x7c, 0x9f, 0xf9, 0xf0, 0x1f, 0x2c, 0x42, 0x25, + 0xe9, 0x73, 0x98, 0x81, 0x08, 0x00, 0x00, 0x00, +}) + +// sigNetGenesisMerkleRoot is the hash of the first transaction in the genesis +// block for the signet test network. It is the same as the merkle root for +// the main network. +var sigNetGenesisMerkleRoot = genesisMerkleRoot + +// sigNetGenesisBlock defines the genesis block of the block chain which serves +// as the public transaction ledger for the signet test network. +var sigNetGenesisBlock = wire.MsgBlock{ + Header: wire.BlockHeader{ + Version: 1, + PrevBlock: chainhash.Hash{}, // 0000000000000000000000000000000000000000000000000000000000000000 + MerkleRoot: sigNetGenesisMerkleRoot, // 4a5e1e4baab89f3a32518a88c31bc87f618f76673e2cc77ab2127b7afdeda33b + Timestamp: time.Unix(1598918400, 0), // 2020-09-01 00:00:00 +0000 UTC + Bits: 0x1e0377ae, // 503543726 [000000377ae00000000000000000000000000000000000000000000000000000] + Nonce: 52613770, + }, + Transactions: []*wire.MsgTx{&genesisCoinbaseTx}, +} diff --git a/chaincfg/params.go b/chaincfg/params.go index 7e4327984c4..9efcd8561b0 100644 --- a/chaincfg/params.go +++ b/chaincfg/params.go @@ -38,6 +38,10 @@ var ( // simNetPowLimit is the highest proof of work value a Bitcoin block // can have for the simulation test network. It is the value 2^255 - 1. simNetPowLimit = new(big.Int).Sub(new(big.Int).Lsh(bigOne, 255), bigOne) + + // sigNetPowLimit is the highest proof of work value a bitcoin block can + // have for the signet test network. It is the value + sigNetPowLimit = new(big.Int).Lsh(new(big.Int).SetInt64(0x0377ae), 212) ) // Checkpoint identifies a known good point in the block chain. Using @@ -96,6 +100,11 @@ const ( // includes the deployment of BIPS 141, 142, 144, 145, 147 and 173. DeploymentSegwit + // DeploymentTaproot defines the rule change deployment ID for the + // Taproot (+Schnorr) soft-fork package. The taproot package includes + // the deployment of BIPS 340, 341 and 342. + DeploymentTaproot + // NOTE: DefinedDeployments must always come last since it is used to // determine how many defined deployments there currently are. @@ -578,6 +587,91 @@ var SimNetParams = Params{ HDCoinType: 115, // ASCII for s } +// SigNetParams defines the network parameters for the signet Bitcoin network. +// Not to be confused with the regression test network, this network is +// sometimes simply called "signet". +var SigNetParams = Params{ + Name: "signet", + Net: wire.SigNet, + DefaultPort: "38333", + DNSSeeds: []DNSSeed{ + {"178.128.221.177", false}, + {"2a01:7c8:d005:390::5", false}, + {"v7ajjeirttkbnt32wpy3c6w3emwnfr3fkla7hpxcfokr3ysd3kqtzmqd.onion:38333", false}, + }, + + // Chain parameters + GenesisBlock: &sigNetGenesisBlock, + GenesisHash: &sigNetGenesisHash, + PowLimit: sigNetPowLimit, + PowLimitBits: 0x1e0377ae, + BIP0034Height: 1, + BIP0065Height: 1, + BIP0066Height: 1, + CoinbaseMaturity: 100, + SubsidyReductionInterval: 210000, + TargetTimespan: time.Hour * 24 * 14, // 14 days + TargetTimePerBlock: time.Minute * 10, // 10 minutes + RetargetAdjustmentFactor: 4, // 25% less, 400% more + ReduceMinDifficulty: true, + MinDiffReductionTime: time.Minute * 20, // TargetTimePerBlock * 2 + GenerateSupported: false, + + // Checkpoints ordered from oldest to newest. + Checkpoints: nil, + + // Consensus rule change deployments. + // + // The miner confirmation window is defined as: + // target proof of work timespan / target proof of work spacing + RuleChangeActivationThreshold: 1512, // 95% of 2016 + MinerConfirmationWindow: 2016, + Deployments: [DefinedDeployments]ConsensusDeployment{ + DeploymentTestDummy: { + BitNumber: 28, + StartTime: 1199145601, // January 1, 2008 UTC + ExpireTime: 1230767999, // December 31, 2008 UTC + }, + DeploymentCSV: { + BitNumber: 0, + StartTime: 0, // Always available for vote + ExpireTime: math.MaxInt64, // Never expires + }, + DeploymentSegwit: { + BitNumber: 1, + StartTime: 0, // Always available for vote + ExpireTime: math.MaxInt64, // Never expires. + }, + DeploymentTaproot: { + BitNumber: 2, + StartTime: 0, // Always available for vote + ExpireTime: math.MaxInt64, // Never expires. + }, + }, + + // Mempool parameters + RelayNonStdTxs: true, + + // Human-readable part for Bech32 encoded segwit addresses, as defined in + // BIP 173. + Bech32HRPSegwit: "tb", // always tb for test net + + // Address encoding magics + PubKeyHashAddrID: 0x6f, // starts with m or n + ScriptHashAddrID: 0xc4, // starts with 2 + WitnessPubKeyHashAddrID: 0x03, // starts with QW + WitnessScriptHashAddrID: 0x28, // starts with T7n + PrivateKeyID: 0xef, // starts with 9 (uncompressed) or c (compressed) + + // BIP32 hierarchical deterministic extended key magics + HDPrivateKeyID: [4]byte{0x04, 0x35, 0x83, 0x94}, // starts with tprv + HDPublicKeyID: [4]byte{0x04, 0x35, 0x87, 0xcf}, // starts with tpub + + // BIP44 coin type used in the hierarchical deterministic path for + // address generation. + HDCoinType: 1, +} + var ( // ErrDuplicateNet describes an error where the parameters for a Bitcoin // network could not be set due to the network already being a standard diff --git a/chaincfg/params_test.go b/chaincfg/params_test.go index d9e1516812c..0eedadb4f3c 100644 --- a/chaincfg/params_test.go +++ b/chaincfg/params_test.go @@ -6,6 +6,8 @@ package chaincfg import ( "bytes" + "encoding/hex" + "math/big" "testing" ) @@ -84,3 +86,14 @@ func TestInvalidHDKeyID(t *testing.T) { t.Fatalf("HDPrivateKeyToPublicKeyID: want err ErrUnknownHDKeyID, got %v", err) } } + +func TestSigNetPowLimit(t *testing.T) { + sigNetPowLimitHex, _ := hex.DecodeString( + "000000377ae00000000000000000000000000000000000000000000000000000", + ) + powLimit := new(big.Int).SetBytes(sigNetPowLimitHex) + if sigNetPowLimit.Cmp(powLimit) != 0 { + t.Fatalf("Signet PoW limit bits (%s) not equal to big int (%s)", + sigNetPowLimit.Text(16), powLimit.Text(16)) + } +} diff --git a/wire/protocol.go b/wire/protocol.go index 8cc9838a55b..e674ebff856 100644 --- a/wire/protocol.go +++ b/wire/protocol.go @@ -157,6 +157,9 @@ const ( // SimNet represents the simulation test network. SimNet BitcoinNet = 0x12141c16 + + // SigNet represents the signet test network. + SigNet BitcoinNet = 0xe7ca5a64 ) // bnStrings is a map of bitcoin networks back to their constant names for @@ -166,6 +169,7 @@ var bnStrings = map[BitcoinNet]string{ TestNet: "TestNet", TestNet3: "TestNet3", SimNet: "SimNet", + SigNet: "SigNet", } // String returns the BitcoinNet in human-readable form.