From 3d003ca102c4218f61b4e670d19e1e8f84fafab6 Mon Sep 17 00:00:00 2001 From: Mike Zak Date: Thu, 7 Jun 2018 12:57:22 +0300 Subject: [PATCH 1/8] Ignore btcutil in Gopkg.toml --- Gopkg.lock | 28 +--------------------------- Gopkg.toml | 6 +----- 2 files changed, 2 insertions(+), 32 deletions(-) diff --git a/Gopkg.lock b/Gopkg.lock index 31f1a80d4..ea2602e2c 100644 --- a/Gopkg.lock +++ b/Gopkg.lock @@ -1,12 +1,6 @@ # This file is autogenerated, do not edit; changes may be undone by the next 'dep ensure'. -[[projects]] - branch = "master" - name = "github.com/aead/siphash" - packages = ["."] - revision = "e404fcfc888570cadd1610538e2dbc89f66af814" - [[projects]] branch = "master" name = "github.com/btcsuite/btclog" @@ -62,20 +56,6 @@ revision = "f8fb11f83f7e860e3769a08e6811d1b399a43722" version = "v1.0.0" -[[projects]] - branch = "master" - name = "github.com/daglabs/btcutil" - packages = [ - ".", - "base58", - "bech32", - "bloom", - "gcs", - "gcs/builder", - "hdkeychain" - ] - revision = "b4e6eb624c3db8fb260f6ce2200a4a135c466652" - [[projects]] name = "github.com/davecgh/go-spew" packages = ["spew"] @@ -94,12 +74,6 @@ revision = "a93b200c26cbae3bb09dd0dc2c7c7fe1468a034a" version = "v1.0.0" -[[projects]] - branch = "master" - name = "github.com/kkdai/bstream" - packages = ["."] - revision = "f71540b9dfdcfe64dbf2818e9b66423c6aafcacd" - [[projects]] branch = "master" name = "golang.org/x/crypto" @@ -109,6 +83,6 @@ [solve-meta] analyzer-name = "dep" analyzer-version = 1 - inputs-digest = "939184fbaca652ccb2ada55cbf06b46a2e8aae3bc73d59206748889013761f19" + inputs-digest = "f6928f9045d39e392385664563e9e2ebad733056d5a2d28747dfbfbe19aa6ad2" solver-name = "gps-cdcl" solver-version = 1 diff --git a/Gopkg.toml b/Gopkg.toml index e56f957ac..c6006391d 100644 --- a/Gopkg.toml +++ b/Gopkg.toml @@ -4,7 +4,6 @@ # for detailed Gopkg.toml documentation. # # required = ["github.com/user/thing/cmd/thing"] -# ignored = ["github.com/user/project/pkgX", "bitbucket.org/user/project/pkgA/pkgY"] # # [[constraint]] # name = "github.com/user/project" @@ -24,6 +23,7 @@ # go-tests = true # unused-packages = true +ignored = ["github.com/daglabs/btcutil*"] [[constraint]] branch = "master" @@ -45,10 +45,6 @@ name = "github.com/btcsuite/winsvc" version = "1.0.0" -[[constraint]] - branch = "master" - name = "github.com/daglabs/btcutil" - [[constraint]] name = "github.com/davecgh/go-spew" version = "1.1.0" From 7b87673f9f416cdf80199eb5945d0e4a09b8be4a Mon Sep 17 00:00:00 2001 From: Stas Boutenko Date: Thu, 7 Jun 2018 17:45:24 +0300 Subject: [PATCH 2/8] (#DEV-13) Added Bech13 prefixes to all networks. --- chaincfg/params.go | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/chaincfg/params.go b/chaincfg/params.go index b48d44484..2d37fd207 100644 --- a/chaincfg/params.go +++ b/chaincfg/params.go @@ -201,6 +201,9 @@ type Params struct { // Mempool parameters RelayNonStdTxs bool + // Human-readable part for Bech32 encoded addresses + Bech32HRP string + // Human-readable part for Bech32 encoded segwit addresses, as defined // in BIP 173. Bech32HRPSegwit string @@ -301,6 +304,9 @@ var MainNetParams = Params{ // Mempool parameters RelayNonStdTxs: false, + // Human-readable part for Bech32 encoded addresses + Bech32HRP: "dagcoin", + // Human-readable part for Bech32 encoded segwit addresses, as defined in // BIP 173. Bech32HRPSegwit: "bc", // always bc for main net @@ -377,6 +383,9 @@ var RegressionNetParams = Params{ // Mempool parameters RelayNonStdTxs: true, + // Human-readable part for Bech32 encoded addresses + Bech32HRP: "dagreg", + // Human-readable part for Bech32 encoded segwit addresses, as defined in // BIP 173. Bech32HRPSegwit: "bcrt", // always bcrt for reg test net @@ -468,6 +477,9 @@ var TestNet3Params = Params{ // Mempool parameters RelayNonStdTxs: true, + // Human-readable part for Bech32 encoded addresses + Bech32HRP: "dagtest", + // Human-readable part for Bech32 encoded segwit addresses, as defined in // BIP 173. Bech32HRPSegwit: "tb", // always tb for test net @@ -548,6 +560,9 @@ var SimNetParams = Params{ // Mempool parameters RelayNonStdTxs: true, + // Human-readable part for Bech32 encoded addresses + Bech32HRP: "dagsim", + // Human-readable part for Bech32 encoded segwit addresses, as defined in // BIP 173. Bech32HRPSegwit: "sb", // always sb for sim net From 1fd78ec2c0f1e3486f4ea18651a868770496568f Mon Sep 17 00:00:00 2001 From: Stas Boutenko Date: Sun, 10 Jun 2018 16:34:36 +0300 Subject: [PATCH 3/8] (#DEV-13) In Bech32, P2PKH always starts with 0 and P2SH always starts with 8. --- chaincfg/params.go | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/chaincfg/params.go b/chaincfg/params.go index 2d37fd207..e6e495a40 100644 --- a/chaincfg/params.go +++ b/chaincfg/params.go @@ -312,8 +312,8 @@ var MainNetParams = Params{ Bech32HRPSegwit: "bc", // always bc for main net // Address encoding magics - PubKeyHashAddrID: 0x00, // starts with 1 - ScriptHashAddrID: 0x05, // starts with 3 + PubKeyHashAddrID: 0x00, // starts with 0 + ScriptHashAddrID: 0x08, // starts with 8 PrivateKeyID: 0x80, // starts with 5 (uncompressed) or K (compressed) WitnessPubKeyHashAddrID: 0x06, // starts with p2 WitnessScriptHashAddrID: 0x0A, // starts with 7Xh @@ -391,8 +391,8 @@ var RegressionNetParams = Params{ Bech32HRPSegwit: "bcrt", // always bcrt for reg test net // Address encoding magics - PubKeyHashAddrID: 0x6f, // starts with m or n - ScriptHashAddrID: 0xc4, // starts with 2 + PubKeyHashAddrID: 0x00, // starts with 0 + ScriptHashAddrID: 0x08, // starts with 8 PrivateKeyID: 0xef, // starts with 9 (uncompressed) or c (compressed) // BIP32 hierarchical deterministic extended key magics @@ -485,8 +485,8 @@ var TestNet3Params = Params{ Bech32HRPSegwit: "tb", // always tb for test net // Address encoding magics - PubKeyHashAddrID: 0x6f, // starts with m or n - ScriptHashAddrID: 0xc4, // starts with 2 + PubKeyHashAddrID: 0x00, // starts with 0 + ScriptHashAddrID: 0x08, // starts with 8 WitnessPubKeyHashAddrID: 0x03, // starts with QW WitnessScriptHashAddrID: 0x28, // starts with T7n PrivateKeyID: 0xef, // starts with 9 (uncompressed) or c (compressed) @@ -568,8 +568,8 @@ var SimNetParams = Params{ Bech32HRPSegwit: "sb", // always sb for sim net // Address encoding magics - PubKeyHashAddrID: 0x3f, // starts with S - ScriptHashAddrID: 0x7b, // starts with s + PubKeyHashAddrID: 0x00, // starts with 0 + ScriptHashAddrID: 0x08, // starts with 8 PrivateKeyID: 0x64, // starts with 4 (uncompressed) or F (compressed) WitnessPubKeyHashAddrID: 0x19, // starts with Gg WitnessScriptHashAddrID: 0x28, // starts with ? From d1bec5ced552d9c2c0263540c89ef8a609cc9734 Mon Sep 17 00:00:00 2001 From: Stas Boutenko Date: Sun, 10 Jun 2018 16:45:38 +0300 Subject: [PATCH 4/8] (#DEV-13) Fixed failing tests. --- txscript/example_test.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/txscript/example_test.go b/txscript/example_test.go index 9a2b49ef6..10afa447b 100644 --- a/txscript/example_test.go +++ b/txscript/example_test.go @@ -24,7 +24,7 @@ func ExamplePayToAddrScript() { // which is useful to ensure the accuracy of the address and determine // the address type. It is also required for the upcoming call to // PayToAddrScript. - addressStr := "12gpXQVcCL2qhTNQgyLVdCFG2Qs2px98nV" + addressStr := "dagcoin:qqfgqp8l9l90zwetj84k2jcac2m8falvvy9uastr55" address, err := btcutil.DecodeAddress(addressStr, &chaincfg.MainNetParams) if err != nil { fmt.Println(err) @@ -75,7 +75,7 @@ func ExampleExtractPkScriptAddrs() { // Output: // Script Class: pubkeyhash - // Addresses: [12gpXQVcCL2qhTNQgyLVdCFG2Qs2px98nV] + // Addresses: [dagcoin:qqfgqp8l9l90zwetj84k2jcac2m8falvvy9uastr55] // Required Signatures: 1 } From 69244036533757fdd34862805c6de03def2ca0cf Mon Sep 17 00:00:00 2001 From: Stas Boutenko Date: Mon, 11 Jun 2018 11:13:16 +0300 Subject: [PATCH 5/8] [DEV-13] Removed netID magic numbers. --- blockchain/fullblocktests/params.go | 2 - chaincfg/params.go | 38 +----- chaincfg/register_test.go | 188 +--------------------------- integration/rpctest/memwallet.go | 8 +- mempool/mempool_test.go | 2 +- rpcserver.go | 18 +-- txscript/sign_test.go | 42 +++---- txscript/standard.go | 17 ++- txscript/standard_test.go | 19 ++- 9 files changed, 49 insertions(+), 285 deletions(-) diff --git a/blockchain/fullblocktests/params.go b/blockchain/fullblocktests/params.go index ee6d53772..de5c69618 100644 --- a/blockchain/fullblocktests/params.go +++ b/blockchain/fullblocktests/params.go @@ -121,8 +121,6 @@ var regressionNetParams = &chaincfg.Params{ RelayNonStdTxs: true, // Address encoding magics - PubKeyHashAddrID: 0x6f, // starts with m or n - ScriptHashAddrID: 0xc4, // starts with 2 PrivateKeyID: 0xef, // starts with 9 (uncompressed) or c (compressed) // BIP32 hierarchical deterministic extended key magics diff --git a/chaincfg/params.go b/chaincfg/params.go index e6e495a40..ba9ab4c30 100644 --- a/chaincfg/params.go +++ b/chaincfg/params.go @@ -209,8 +209,6 @@ type Params struct { Bech32HRPSegwit string // Address encoding magics - PubKeyHashAddrID byte // First byte of a P2PKH address - ScriptHashAddrID byte // First byte of a P2SH address PrivateKeyID byte // First byte of a WIF private key WitnessPubKeyHashAddrID byte // First byte of a P2WPKH address WitnessScriptHashAddrID byte // First byte of a P2WSH address @@ -312,8 +310,6 @@ var MainNetParams = Params{ Bech32HRPSegwit: "bc", // always bc for main net // Address encoding magics - PubKeyHashAddrID: 0x00, // starts with 0 - ScriptHashAddrID: 0x08, // starts with 8 PrivateKeyID: 0x80, // starts with 5 (uncompressed) or K (compressed) WitnessPubKeyHashAddrID: 0x06, // starts with p2 WitnessScriptHashAddrID: 0x0A, // starts with 7Xh @@ -391,9 +387,7 @@ var RegressionNetParams = Params{ Bech32HRPSegwit: "bcrt", // always bcrt for reg test net // Address encoding magics - PubKeyHashAddrID: 0x00, // starts with 0 - ScriptHashAddrID: 0x08, // starts with 8 - PrivateKeyID: 0xef, // starts with 9 (uncompressed) or c (compressed) + 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 @@ -485,8 +479,6 @@ var TestNet3Params = Params{ Bech32HRPSegwit: "tb", // always tb for test net // Address encoding magics - PubKeyHashAddrID: 0x00, // starts with 0 - ScriptHashAddrID: 0x08, // starts with 8 WitnessPubKeyHashAddrID: 0x03, // starts with QW WitnessScriptHashAddrID: 0x28, // starts with T7n PrivateKeyID: 0xef, // starts with 9 (uncompressed) or c (compressed) @@ -568,8 +560,6 @@ var SimNetParams = Params{ Bech32HRPSegwit: "sb", // always sb for sim net // Address encoding magics - PubKeyHashAddrID: 0x00, // starts with 0 - ScriptHashAddrID: 0x08, // starts with 8 PrivateKeyID: 0x64, // starts with 4 (uncompressed) or F (compressed) WitnessPubKeyHashAddrID: 0x19, // starts with Gg WitnessScriptHashAddrID: 0x28, // starts with ? @@ -597,8 +587,6 @@ var ( var ( registeredNets = make(map[wire.BitcoinNet]struct{}) - pubKeyHashAddrIDs = make(map[byte]struct{}) - scriptHashAddrIDs = make(map[byte]struct{}) bech32SegwitPrefixes = make(map[string]struct{}) hdPrivToPubKeyIDs = make(map[[4]byte][]byte) ) @@ -622,8 +610,6 @@ func Register(params *Params) error { return ErrDuplicateNet } registeredNets[params.Net] = struct{}{} - pubKeyHashAddrIDs[params.PubKeyHashAddrID] = struct{}{} - scriptHashAddrIDs[params.ScriptHashAddrID] = struct{}{} hdPrivToPubKeyIDs[params.HDPrivateKeyID] = params.HDPublicKeyID[:] // A valid Bech32 encoded segwit address always has as prefix the @@ -640,28 +626,6 @@ func mustRegister(params *Params) { } } -// IsPubKeyHashAddrID returns whether the id is an identifier known to prefix a -// pay-to-pubkey-hash address on any default or registered network. This is -// used when decoding an address string into a specific address type. It is up -// to the caller to check both this and IsScriptHashAddrID and decide whether an -// address is a pubkey hash address, script hash address, neither, or -// undeterminable (if both return true). -func IsPubKeyHashAddrID(id byte) bool { - _, ok := pubKeyHashAddrIDs[id] - return ok -} - -// IsScriptHashAddrID returns whether the id is an identifier known to prefix a -// pay-to-script-hash address on any default or registered network. This is -// used when decoding an address string into a specific address type. It is up -// to the caller to check both this and IsPubKeyHashAddrID and decide whether an -// address is a pubkey hash address, script hash address, neither, or -// undeterminable (if both return true). -func IsScriptHashAddrID(id byte) bool { - _, ok := scriptHashAddrIDs[id] - return ok -} - // IsBech32SegwitPrefix returns whether the prefix is a known prefix for segwit // addresses on any default or registered network. This is used when decoding // an address string into a specific address type. diff --git a/chaincfg/register_test.go b/chaincfg/register_test.go index 1cb04dd6b..27e7a7df3 100644 --- a/chaincfg/register_test.go +++ b/chaincfg/register_test.go @@ -13,13 +13,11 @@ import ( // network. This is necessary to test the registration of and // lookup of encoding magics from the network. var mockNetParams = Params{ - Name: "mocknet", - Net: 1<<32 - 1, - PubKeyHashAddrID: 0x9f, - ScriptHashAddrID: 0xf9, - Bech32HRPSegwit: "tc", - HDPrivateKeyID: [4]byte{0x01, 0x02, 0x03, 0x04}, - HDPublicKeyID: [4]byte{0x05, 0x06, 0x07, 0x08}, + Name: "mocknet", + Net: 1<<32 - 1, + Bech32HRPSegwit: "tc", + HDPrivateKeyID: [4]byte{0x01, 0x02, 0x03, 0x04}, + HDPublicKeyID: [4]byte{0x05, 0x06, 0x07, 0x08}, } func TestRegister(t *testing.T) { @@ -28,10 +26,6 @@ func TestRegister(t *testing.T) { params *Params err error } - type magicTest struct { - magic byte - valid bool - } type prefixTest struct { prefix string valid bool @@ -45,8 +39,6 @@ func TestRegister(t *testing.T) { tests := []struct { name string register []registerTest - p2pkhMagics []magicTest - p2shMagics []magicTest segwitPrefixes []prefixTest hdMagics []hdTest }{ @@ -74,58 +66,6 @@ func TestRegister(t *testing.T) { err: ErrDuplicateNet, }, }, - p2pkhMagics: []magicTest{ - { - magic: MainNetParams.PubKeyHashAddrID, - valid: true, - }, - { - magic: TestNet3Params.PubKeyHashAddrID, - valid: true, - }, - { - magic: RegressionNetParams.PubKeyHashAddrID, - valid: true, - }, - { - magic: SimNetParams.PubKeyHashAddrID, - valid: true, - }, - { - magic: mockNetParams.PubKeyHashAddrID, - valid: false, - }, - { - magic: 0xFF, - valid: false, - }, - }, - p2shMagics: []magicTest{ - { - magic: MainNetParams.ScriptHashAddrID, - valid: true, - }, - { - magic: TestNet3Params.ScriptHashAddrID, - valid: true, - }, - { - magic: RegressionNetParams.ScriptHashAddrID, - valid: true, - }, - { - magic: SimNetParams.ScriptHashAddrID, - valid: true, - }, - { - magic: mockNetParams.ScriptHashAddrID, - valid: false, - }, - { - magic: 0xFF, - valid: false, - }, - }, segwitPrefixes: []prefixTest{ { prefix: MainNetParams.Bech32HRPSegwit + "1", @@ -208,58 +148,6 @@ func TestRegister(t *testing.T) { err: nil, }, }, - p2pkhMagics: []magicTest{ - { - magic: MainNetParams.PubKeyHashAddrID, - valid: true, - }, - { - magic: TestNet3Params.PubKeyHashAddrID, - valid: true, - }, - { - magic: RegressionNetParams.PubKeyHashAddrID, - valid: true, - }, - { - magic: SimNetParams.PubKeyHashAddrID, - valid: true, - }, - { - magic: mockNetParams.PubKeyHashAddrID, - valid: true, - }, - { - magic: 0xFF, - valid: false, - }, - }, - p2shMagics: []magicTest{ - { - magic: MainNetParams.ScriptHashAddrID, - valid: true, - }, - { - magic: TestNet3Params.ScriptHashAddrID, - valid: true, - }, - { - magic: RegressionNetParams.ScriptHashAddrID, - valid: true, - }, - { - magic: SimNetParams.ScriptHashAddrID, - valid: true, - }, - { - magic: mockNetParams.ScriptHashAddrID, - valid: true, - }, - { - magic: 0xFF, - valid: false, - }, - }, segwitPrefixes: []prefixTest{ { prefix: MainNetParams.Bech32HRPSegwit + "1", @@ -335,58 +223,6 @@ func TestRegister(t *testing.T) { err: ErrDuplicateNet, }, }, - p2pkhMagics: []magicTest{ - { - magic: MainNetParams.PubKeyHashAddrID, - valid: true, - }, - { - magic: TestNet3Params.PubKeyHashAddrID, - valid: true, - }, - { - magic: RegressionNetParams.PubKeyHashAddrID, - valid: true, - }, - { - magic: SimNetParams.PubKeyHashAddrID, - valid: true, - }, - { - magic: mockNetParams.PubKeyHashAddrID, - valid: true, - }, - { - magic: 0xFF, - valid: false, - }, - }, - p2shMagics: []magicTest{ - { - magic: MainNetParams.ScriptHashAddrID, - valid: true, - }, - { - magic: TestNet3Params.ScriptHashAddrID, - valid: true, - }, - { - magic: RegressionNetParams.ScriptHashAddrID, - valid: true, - }, - { - magic: SimNetParams.ScriptHashAddrID, - valid: true, - }, - { - magic: mockNetParams.ScriptHashAddrID, - valid: true, - }, - { - magic: 0xFF, - valid: false, - }, - }, segwitPrefixes: []prefixTest{ { prefix: MainNetParams.Bech32HRPSegwit + "1", @@ -471,20 +307,6 @@ func TestRegister(t *testing.T) { test.name, regTest.name, err, regTest.err) } } - for i, magTest := range test.p2pkhMagics { - valid := IsPubKeyHashAddrID(magTest.magic) - if valid != magTest.valid { - t.Errorf("%s: P2PKH magic %d valid mismatch: got %v expected %v", - test.name, i, valid, magTest.valid) - } - } - for i, magTest := range test.p2shMagics { - valid := IsScriptHashAddrID(magTest.magic) - if valid != magTest.valid { - t.Errorf("%s: P2SH magic %d valid mismatch: got %v expected %v", - test.name, i, valid, magTest.valid) - } - } for i, prxTest := range test.segwitPrefixes { valid := IsBech32SegwitPrefix(prxTest.prefix) if valid != prxTest.valid { diff --git a/integration/rpctest/memwallet.go b/integration/rpctest/memwallet.go index 8bf91feae..5c6e314a9 100644 --- a/integration/rpctest/memwallet.go +++ b/integration/rpctest/memwallet.go @@ -133,7 +133,7 @@ func newMemWallet(net *chaincfg.Params, harnessID uint32) (*memWallet, error) { if err != nil { return nil, err } - coinbaseAddr, err := keyToAddr(coinbaseKey, net) + coinbaseAddr, err := keyToAddr(coinbaseKey) if err != nil { return nil, err } @@ -346,7 +346,7 @@ func (m *memWallet) newAddress() (btcutil.Address, error) { return nil, err } - addr, err := keyToAddr(privKey, m.net) + addr, err := keyToAddr(privKey) if err != nil { return nil, err } @@ -560,9 +560,9 @@ func (m *memWallet) ConfirmedBalance() btcutil.Amount { } // keyToAddr maps the passed private to corresponding p2pkh address. -func keyToAddr(key *btcec.PrivateKey, net *chaincfg.Params) (btcutil.Address, error) { +func keyToAddr(key *btcec.PrivateKey) (btcutil.Address, error) { serializedKey := key.PubKey().SerializeCompressed() - pubKeyAddr, err := btcutil.NewAddressPubKey(serializedKey, net) + pubKeyAddr, err := btcutil.NewAddressPubKey(serializedKey) if err != nil { return nil, err } diff --git a/mempool/mempool_test.go b/mempool/mempool_test.go index e77f7b847..2827a40f6 100644 --- a/mempool/mempool_test.go +++ b/mempool/mempool_test.go @@ -288,7 +288,7 @@ func newPoolHarness(chainParams *chaincfg.Params) (*poolHarness, []spendableOutp // Generate associated pay-to-script-hash address and resulting payment // script. pubKeyBytes := signPub.SerializeCompressed() - payPubKeyAddr, err := btcutil.NewAddressPubKey(pubKeyBytes, chainParams) + payPubKeyAddr, err := btcutil.NewAddressPubKey(pubKeyBytes) if err != nil { return nil, nil, err } diff --git a/rpcserver.go b/rpcserver.go index 0abb5b823..80bd34f92 100644 --- a/rpcserver.go +++ b/rpcserver.go @@ -333,15 +333,15 @@ type gbtWorkState struct { prevHash *chainhash.Hash minTimestamp time.Time template *mining.BlockTemplate - notifyMap map[chainhash.Hash]map[int64]chan struct{} - timeSource blockchain.MedianTimeSource + notifyMap map[chainhash.Hash]map[int64]chan struct{} + timeSource blockchain.MedianTimeSource } // newGbtWorkState returns a new instance of a gbtWorkState with all internal // fields initialized and ready to use. func newGbtWorkState(timeSource blockchain.MedianTimeSource) *gbtWorkState { return &gbtWorkState{ - notifyMap: make(map[chainhash.Hash]map[int64]chan struct{}), + notifyMap: make(map[chainhash.Hash]map[int64]chan struct{}), timeSource: timeSource, } } @@ -1549,7 +1549,7 @@ func (state *gbtWorkState) updateBlockTemplate(s *rpcServer, useCoinbaseValue bo if template == nil || state.prevHash == nil || !state.prevHash.IsEqual(latestHash) || (state.lastTxUpdate != lastTxUpdate && - time.Now().After(state.lastGenerated.Add(time.Second* + time.Now().After(state.lastGenerated.Add(time.Second * gbtRegenerateSeconds))) { // Reset the previous best hash the block template was generated @@ -1573,7 +1573,7 @@ func (state *gbtWorkState) updateBlockTemplate(s *rpcServer, useCoinbaseValue bo blkTemplate, err := generator.NewBlockTemplate(payAddr) if err != nil { return internalRPCError("Failed to create new block "+ - "template: "+err.Error(), "") + "template: "+ err.Error(), "") } template = blkTemplate msgBlock = template.Block @@ -1870,7 +1870,7 @@ func handleGetBlockTemplateLongPoll(s *rpcServer, longPollID string, useCoinbase case <-closeChan: return nil, ErrClientQuit - // Wait until signal received to send the reply. + // Wait until signal received to send the reply. case <-longPollChan: // Fallthrough } @@ -2804,7 +2804,7 @@ func handlePing(s *rpcServer, cmd interface{}, closeChan <-chan struct{}) (inter nonce, err := wire.RandomUint64() if err != nil { return nil, internalRPCError("Not sending ping - failed to "+ - "generate nonce: "+err.Error(), "") + "generate nonce: "+ err.Error(), "") } s.cfg.ConnMgr.BroadcastMessage(wire.NewMsgPing(nonce)) @@ -3576,7 +3576,7 @@ func handleVerifyMessage(s *rpcServer, cmd interface{}, closeChan <-chan struct{ } else { serializedPK = pk.SerializeUncompressed() } - address, err := btcutil.NewAddressPubKey(serializedPK, params) + address, err := btcutil.NewAddressPubKey(serializedPK) if err != nil { // Again mirror Bitcoin Core behavior, which treats error in public key // reconstruction as invalid signature. @@ -4281,7 +4281,7 @@ func newRPCServer(config *rpcserverConfig) (*rpcServer, error) { gbtWorkState: newGbtWorkState(config.TimeSource), helpCacher: newHelpCacher(), requestProcessShutdown: make(chan struct{}), - quit: make(chan int), + quit: make(chan int), } if cfg.RPCUser != "" && cfg.RPCPass != "" { login := cfg.RPCUser + ":" + cfg.RPCPass diff --git a/txscript/sign_test.go b/txscript/sign_test.go index fee1b1ba5..f256ad362 100644 --- a/txscript/sign_test.go +++ b/txscript/sign_test.go @@ -351,8 +351,7 @@ func TestSignTxOutput(t *testing.T) { pk := (*btcec.PublicKey)(&key.PublicKey). SerializeUncompressed() - address, err := btcutil.NewAddressPubKey(pk, - &chaincfg.TestNet3Params) + address, err := btcutil.NewAddressPubKey(pk) if err != nil { t.Errorf("failed to make address for %s: %v", msg, err) @@ -390,8 +389,7 @@ func TestSignTxOutput(t *testing.T) { pk := (*btcec.PublicKey)(&key.PublicKey). SerializeUncompressed() - address, err := btcutil.NewAddressPubKey(pk, - &chaincfg.TestNet3Params) + address, err := btcutil.NewAddressPubKey(pk) if err != nil { t.Errorf("failed to make address for %s: %v", msg, err) @@ -451,8 +449,7 @@ func TestSignTxOutput(t *testing.T) { pk := (*btcec.PublicKey)(&key.PublicKey). SerializeCompressed() - address, err := btcutil.NewAddressPubKey(pk, - &chaincfg.TestNet3Params) + address, err := btcutil.NewAddressPubKey(pk) if err != nil { t.Errorf("failed to make address for %s: %v", msg, err) @@ -490,8 +487,7 @@ func TestSignTxOutput(t *testing.T) { pk := (*btcec.PublicKey)(&key.PublicKey). SerializeCompressed() - address, err := btcutil.NewAddressPubKey(pk, - &chaincfg.TestNet3Params) + address, err := btcutil.NewAddressPubKey(pk) if err != nil { t.Errorf("failed to make address for %s: %v", msg, err) @@ -831,8 +827,7 @@ func TestSignTxOutput(t *testing.T) { pk := (*btcec.PublicKey)(&key.PublicKey). SerializeUncompressed() - address, err := btcutil.NewAddressPubKey(pk, - &chaincfg.TestNet3Params) + address, err := btcutil.NewAddressPubKey(pk) if err != nil { t.Errorf("failed to make address for %s: %v", msg, err) @@ -888,8 +883,7 @@ func TestSignTxOutput(t *testing.T) { pk := (*btcec.PublicKey)(&key.PublicKey). SerializeUncompressed() - address, err := btcutil.NewAddressPubKey(pk, - &chaincfg.TestNet3Params) + address, err := btcutil.NewAddressPubKey(pk) if err != nil { t.Errorf("failed to make address for %s: %v", msg, err) @@ -969,8 +963,7 @@ func TestSignTxOutput(t *testing.T) { pk := (*btcec.PublicKey)(&key.PublicKey). SerializeCompressed() - address, err := btcutil.NewAddressPubKey(pk, - &chaincfg.TestNet3Params) + address, err := btcutil.NewAddressPubKey(pk) if err != nil { t.Errorf("failed to make address for %s: %v", msg, err) @@ -1025,8 +1018,7 @@ func TestSignTxOutput(t *testing.T) { pk := (*btcec.PublicKey)(&key.PublicKey). SerializeCompressed() - address, err := btcutil.NewAddressPubKey(pk, - &chaincfg.TestNet3Params) + address, err := btcutil.NewAddressPubKey(pk) if err != nil { t.Errorf("failed to make address for %s: %v", msg, err) @@ -1106,8 +1098,7 @@ func TestSignTxOutput(t *testing.T) { pk1 := (*btcec.PublicKey)(&key1.PublicKey). SerializeCompressed() - address1, err := btcutil.NewAddressPubKey(pk1, - &chaincfg.TestNet3Params) + address1, err := btcutil.NewAddressPubKey(pk1) if err != nil { t.Errorf("failed to make address for %s: %v", msg, err) @@ -1123,8 +1114,7 @@ func TestSignTxOutput(t *testing.T) { pk2 := (*btcec.PublicKey)(&key2.PublicKey). SerializeCompressed() - address2, err := btcutil.NewAddressPubKey(pk2, - &chaincfg.TestNet3Params) + address2, err := btcutil.NewAddressPubKey(pk2) if err != nil { t.Errorf("failed to make address 2 for %s: %v", msg, err) @@ -1182,8 +1172,7 @@ func TestSignTxOutput(t *testing.T) { pk1 := (*btcec.PublicKey)(&key1.PublicKey). SerializeCompressed() - address1, err := btcutil.NewAddressPubKey(pk1, - &chaincfg.TestNet3Params) + address1, err := btcutil.NewAddressPubKey(pk1) if err != nil { t.Errorf("failed to make address for %s: %v", msg, err) @@ -1199,8 +1188,7 @@ func TestSignTxOutput(t *testing.T) { pk2 := (*btcec.PublicKey)(&key2.PublicKey). SerializeCompressed() - address2, err := btcutil.NewAddressPubKey(pk2, - &chaincfg.TestNet3Params) + address2, err := btcutil.NewAddressPubKey(pk2) if err != nil { t.Errorf("failed to make address 2 for %s: %v", msg, err) @@ -1288,8 +1276,7 @@ func TestSignTxOutput(t *testing.T) { pk1 := (*btcec.PublicKey)(&key1.PublicKey). SerializeCompressed() - address1, err := btcutil.NewAddressPubKey(pk1, - &chaincfg.TestNet3Params) + address1, err := btcutil.NewAddressPubKey(pk1) if err != nil { t.Errorf("failed to make address for %s: %v", msg, err) @@ -1305,8 +1292,7 @@ func TestSignTxOutput(t *testing.T) { pk2 := (*btcec.PublicKey)(&key2.PublicKey). SerializeCompressed() - address2, err := btcutil.NewAddressPubKey(pk2, - &chaincfg.TestNet3Params) + address2, err := btcutil.NewAddressPubKey(pk2) if err != nil { t.Errorf("failed to make address 2 for %s: %v", msg, err) diff --git a/txscript/standard.go b/txscript/standard.go index 0494431f4..3e42aa37e 100644 --- a/txscript/standard.go +++ b/txscript/standard.go @@ -300,15 +300,15 @@ func CalcScriptInfo(sigScript, pkScript []byte, witness wire.TxWitness, // will fail). si.NumInputs = len(sigPops) - // If segwit is active, and this is a regular p2wkh output, then we'll - // treat the script as a p2pkh output in essence. + // If segwit is active, and this is a regular p2wkh output, then we'll + // treat the script as a p2pkh output in essence. case si.PkScriptClass == WitnessV0PubKeyHashTy && segwit: si.SigOps = GetWitnessSigOpCount(sigScript, pkScript, witness) si.NumInputs = len(witness) - // We'll attempt to detect the nested p2sh case so we can accurately - // count the signature operations involved. + // We'll attempt to detect the nested p2sh case so we can accurately + // count the signature operations involved. case si.PkScriptClass == ScriptHashTy && IsWitnessProgram(sigScript[1:]) && bip16 && segwit: @@ -327,8 +327,8 @@ func CalcScriptInfo(sigScript, pkScript []byte, witness wire.TxWitness, si.NumInputs = len(witness) si.NumInputs += len(sigPops) - // If segwit is active, and this is a p2wsh output, then we'll need to - // examine the witness script to generate accurate script info. + // If segwit is active, and this is a p2wsh output, then we'll need to + // examine the witness script to generate accurate script info. case si.PkScriptClass == WitnessV0ScriptHashTy && segwit: // The witness script is the final element of the witness // stack. @@ -564,7 +564,7 @@ func ExtractPkScriptAddrs(pkScript []byte, chainParams *chaincfg.Params) (Script // Therefore the pubkey is the first item on the stack. // Skip the pubkey if it's invalid for some reason. requiredSigs = 1 - addr, err := btcutil.NewAddressPubKey(pops[0].data, chainParams) + addr, err := btcutil.NewAddressPubKey(pops[0].data) if err == nil { addrs = append(addrs, addr) } @@ -605,8 +605,7 @@ func ExtractPkScriptAddrs(pkScript []byte, chainParams *chaincfg.Params) (Script // Extract the public keys while skipping any that are invalid. addrs = make([]btcutil.Address, 0, numPubKeys) for i := 0; i < numPubKeys; i++ { - addr, err := btcutil.NewAddressPubKey(pops[i+1].data, - chainParams) + addr, err := btcutil.NewAddressPubKey(pops[i+1].data) if err == nil { addrs = append(addrs, addr) } diff --git a/txscript/standard_test.go b/txscript/standard_test.go index 073ebd9a0..c418b5914 100644 --- a/txscript/standard_test.go +++ b/txscript/standard_test.go @@ -34,8 +34,7 @@ func mustParseShortForm(script string) []byte { // the tests as a helper since the only way it can fail is if there is an error // in the test source code. func newAddressPubKey(serializedPubKey []byte) btcutil.Address { - addr, err := btcutil.NewAddressPubKey(serializedPubKey, - &chaincfg.MainNetParams) + addr, err := btcutil.NewAddressPubKey(serializedPubKey) if err != nil { panic("invalid public key in test source") } @@ -613,15 +612,13 @@ func TestPayToAddrScript(t *testing.T) { // mainnet p2pk 13CG6SJ3yHUXo4Cr2RY4THLLJrNFuG3gUg p2pkCompressedMain, err := btcutil.NewAddressPubKey(hexToBytes("02192d"+ - "74d0cb94344c9569c2e77901573d8d7903c3ebec3a957724895dca52c6b4"), - &chaincfg.MainNetParams) + "74d0cb94344c9569c2e77901573d8d7903c3ebec3a957724895dca52c6b4")) if err != nil { t.Fatalf("Unable to create pubkey address (compressed): %v", err) } p2pkCompressed2Main, err := btcutil.NewAddressPubKey(hexToBytes("03b0b"+ - "d634234abbb1ba1e986e884185c61cf43e001f9137f23c2c409273eb16e65"), - &chaincfg.MainNetParams) + "d634234abbb1ba1e986e884185c61cf43e001f9137f23c2c409273eb16e65")) if err != nil { t.Fatalf("Unable to create pubkey address (compressed 2): %v", err) @@ -630,7 +627,7 @@ func TestPayToAddrScript(t *testing.T) { p2pkUncompressedMain, err := btcutil.NewAddressPubKey(hexToBytes("0411"+ "db93e1dcdb8a016b49840f8c53bc1eb68a382e97b1482ecad7b148a6909a5"+ "cb2e0eaddfb84ccf9744464f82e160bfa9b8b64f9d4c03f999b8643f656b4"+ - "12a3"), &chaincfg.MainNetParams) + "12a3")) if err != nil { t.Fatalf("Unable to create pubkey address (uncompressed): %v", err) @@ -717,15 +714,13 @@ func TestMultiSigScript(t *testing.T) { // mainnet p2pk 13CG6SJ3yHUXo4Cr2RY4THLLJrNFuG3gUg p2pkCompressedMain, err := btcutil.NewAddressPubKey(hexToBytes("02192d"+ - "74d0cb94344c9569c2e77901573d8d7903c3ebec3a957724895dca52c6b4"), - &chaincfg.MainNetParams) + "74d0cb94344c9569c2e77901573d8d7903c3ebec3a957724895dca52c6b4")) if err != nil { t.Fatalf("Unable to create pubkey address (compressed): %v", err) } p2pkCompressed2Main, err := btcutil.NewAddressPubKey(hexToBytes("03b0b"+ - "d634234abbb1ba1e986e884185c61cf43e001f9137f23c2c409273eb16e65"), - &chaincfg.MainNetParams) + "d634234abbb1ba1e986e884185c61cf43e001f9137f23c2c409273eb16e65")) if err != nil { t.Fatalf("Unable to create pubkey address (compressed 2): %v", err) @@ -734,7 +729,7 @@ func TestMultiSigScript(t *testing.T) { p2pkUncompressedMain, err := btcutil.NewAddressPubKey(hexToBytes("0411"+ "db93e1dcdb8a016b49840f8c53bc1eb68a382e97b1482ecad7b148a6909a5"+ "cb2e0eaddfb84ccf9744464f82e160bfa9b8b64f9d4c03f999b8643f656b4"+ - "12a3"), &chaincfg.MainNetParams) + "12a3")) if err != nil { t.Fatalf("Unable to create pubkey address (uncompressed): %v", err) From 371be97a06dd1965b576dee9e197d17345d86f25 Mon Sep 17 00:00:00 2001 From: Stas Boutenko Date: Tue, 12 Jun 2018 12:20:19 +0300 Subject: [PATCH 6/8] [DEV-13] Reimplemented prefixes as enums instead of string values. --- chaincfg/params.go | 66 +++++++++++++++++++++++++++++++++++++++++----- 1 file changed, 60 insertions(+), 6 deletions(-) diff --git a/chaincfg/params.go b/chaincfg/params.go index ba9ab4c30..6e982a424 100644 --- a/chaincfg/params.go +++ b/chaincfg/params.go @@ -13,6 +13,7 @@ import ( "github.com/daglabs/btcd/chaincfg/chainhash" "github.com/daglabs/btcd/wire" + "fmt" ) // These variables are the chain proof-of-work limit parameters for each default @@ -103,6 +104,59 @@ const ( DefinedDeployments ) +// Bech32Prefix is the human-readable prefix for a Bech32 address. +type Bech32Prefix int + +// Constants that define Bech32 address prefixes. Every network is assigned +// a unique prefix. +const ( + // Unknown/Erroneous prefix + Unknown Bech32Prefix = iota + + // Prefix for the main network. + DagCoin + + // Prefix for the regression test network. + DagReg + + // Prefix for the test network. + DagTest + + // Prefix for the simulation network. + DagSim +) + +// Map from strings to Bech32 address prefix constants for parsing purposes. +var stringsToBech32Prefixes = make(map[string]Bech32Prefix) + +func init() { + stringsToBech32Prefixes["dagcoin"] = DagCoin + stringsToBech32Prefixes["dagreg"] = DagReg + stringsToBech32Prefixes["dagtest"] = DagTest + stringsToBech32Prefixes["dagsim"] = DagSim +} + +// Attempts to parse a Bech32 address prefix. +func ParsePrefix(prefixString string) (Bech32Prefix, error) { + prefix, ok := stringsToBech32Prefixes[prefixString] + if !ok { + return Unknown, errors.New(fmt.Sprintf("could not parse prefix %v", prefixString)) + } + + return prefix, nil +} + +// Converts from Bech32 address prefixes to their string values +func (prefix Bech32Prefix) String() string { + for key, value := range stringsToBech32Prefixes { + if prefix == value { + return key + } + } + + return "" +} + // Params defines a Bitcoin network by its parameters. These parameters may be // used by Bitcoin applications to differentiate networks as well as addresses // and keys for one network from those intended for use on another network. @@ -201,8 +255,8 @@ type Params struct { // Mempool parameters RelayNonStdTxs bool - // Human-readable part for Bech32 encoded addresses - Bech32HRP string + // Human-readable prefix for Bech32 encoded addresses + Prefix Bech32Prefix // Human-readable part for Bech32 encoded segwit addresses, as defined // in BIP 173. @@ -303,7 +357,7 @@ var MainNetParams = Params{ RelayNonStdTxs: false, // Human-readable part for Bech32 encoded addresses - Bech32HRP: "dagcoin", + Prefix: DagCoin, // Human-readable part for Bech32 encoded segwit addresses, as defined in // BIP 173. @@ -380,7 +434,7 @@ var RegressionNetParams = Params{ RelayNonStdTxs: true, // Human-readable part for Bech32 encoded addresses - Bech32HRP: "dagreg", + Prefix: DagReg, // Human-readable part for Bech32 encoded segwit addresses, as defined in // BIP 173. @@ -472,7 +526,7 @@ var TestNet3Params = Params{ RelayNonStdTxs: true, // Human-readable part for Bech32 encoded addresses - Bech32HRP: "dagtest", + Prefix: DagTest, // Human-readable part for Bech32 encoded segwit addresses, as defined in // BIP 173. @@ -553,7 +607,7 @@ var SimNetParams = Params{ RelayNonStdTxs: true, // Human-readable part for Bech32 encoded addresses - Bech32HRP: "dagsim", + Prefix: DagSim, // Human-readable part for Bech32 encoded segwit addresses, as defined in // BIP 173. From e850d4737c45a7fcf0d8af3a1b0db254d8e0f0d4 Mon Sep 17 00:00:00 2001 From: Stas Boutenko Date: Tue, 12 Jun 2018 15:28:02 +0300 Subject: [PATCH 7/8] [DEV-13] Moved map initialization out of init and into an initializer. --- chaincfg/params.go | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-) diff --git a/chaincfg/params.go b/chaincfg/params.go index 6e982a424..8817271a7 100644 --- a/chaincfg/params.go +++ b/chaincfg/params.go @@ -127,13 +127,11 @@ const ( ) // Map from strings to Bech32 address prefix constants for parsing purposes. -var stringsToBech32Prefixes = make(map[string]Bech32Prefix) - -func init() { - stringsToBech32Prefixes["dagcoin"] = DagCoin - stringsToBech32Prefixes["dagreg"] = DagReg - stringsToBech32Prefixes["dagtest"] = DagTest - stringsToBech32Prefixes["dagsim"] = DagSim +var stringsToBech32Prefixes = map[string]Bech32Prefix{ + "dagcoin": DagCoin, + "dagreg": DagReg, + "dagtest": DagTest, + "dagsim": DagSim, } // Attempts to parse a Bech32 address prefix. From da9960ff91c22653956d153aaa5f5fe1616b20d7 Mon Sep 17 00:00:00 2001 From: Stas Boutenko Date: Tue, 12 Jun 2018 17:17:23 +0300 Subject: [PATCH 8/8] [DEV-13] Fixed lint errors. --- addrmgr/doc.go | 2 +- blockchain/doc.go | 2 +- blockchain/fullblocktests/doc.go | 2 +- btcec/doc.go | 2 +- btcjson/doc.go | 2 +- chaincfg/doc.go | 2 +- chaincfg/params.go | 4 ++-- connmgr/doc.go | 2 +- database/doc.go | 2 +- database/ffldb/doc.go | 2 +- database/internal/treap/doc.go | 2 +- mempool/doc.go | 2 +- netsync/doc.go | 2 +- peer/doc.go | 2 +- rpcclient/doc.go | 2 +- txscript/doc.go | 2 +- wire/doc.go | 2 +- 17 files changed, 18 insertions(+), 18 deletions(-) diff --git a/addrmgr/doc.go b/addrmgr/doc.go index 8ddc8bfdf..23567a3bb 100644 --- a/addrmgr/doc.go +++ b/addrmgr/doc.go @@ -35,4 +35,4 @@ periodically purge peers which no longer appear to be good peers as well as bias the selection toward known good peers. The general idea is to make a best effort at only providing usable addresses. */ -package addrmgr +package addrmgr \ No newline at end of file diff --git a/blockchain/doc.go b/blockchain/doc.go index 244175414..df99c5f5f 100644 --- a/blockchain/doc.go +++ b/blockchain/doc.go @@ -78,4 +78,4 @@ This package includes spec changes outlined by the following BIPs: BIP0030 (https://en.bitcoin.it/wiki/BIP_0030) BIP0034 (https://en.bitcoin.it/wiki/BIP_0034) */ -package blockchain +package blockchain \ No newline at end of file diff --git a/blockchain/fullblocktests/doc.go b/blockchain/fullblocktests/doc.go index bfedc43d9..2b056ec72 100644 --- a/blockchain/fullblocktests/doc.go +++ b/blockchain/fullblocktests/doc.go @@ -17,4 +17,4 @@ This package has intentionally been designed so it can be used as a standalone package for any projects needing to test their implementation against a full set of blocks that exercise the consensus validation rules. */ -package fullblocktests +package fullblocktests \ No newline at end of file diff --git a/btcec/doc.go b/btcec/doc.go index fa8346ab0..4a8e2de7a 100644 --- a/btcec/doc.go +++ b/btcec/doc.go @@ -18,4 +18,4 @@ standard formats. It was designed for use with btcd, but should be general enough for other uses of elliptic curve crypto. It was originally based on some initial work by ThePiachu, but has significantly diverged since then. */ -package btcec +package btcec \ No newline at end of file diff --git a/btcjson/doc.go b/btcjson/doc.go index 165b9ef91..eca45930e 100644 --- a/btcjson/doc.go +++ b/btcjson/doc.go @@ -143,4 +143,4 @@ The second category of errors (type RPCError), on the other hand, are useful for returning errors to RPC clients. Consequently, they are used in the previously described Response type. */ -package btcjson +package btcjson \ No newline at end of file diff --git a/chaincfg/doc.go b/chaincfg/doc.go index 263ad2796..32cea4975 100644 --- a/chaincfg/doc.go +++ b/chaincfg/doc.go @@ -58,4 +58,4 @@ // non-standard network. As a general rule of thumb, all network parameters // should be unique to the network, but parameter collisions can still occur // (unfortunately, this is the case with regtest and testnet3 sharing magics). -package chaincfg +package chaincfg \ No newline at end of file diff --git a/chaincfg/params.go b/chaincfg/params.go index 8817271a7..bc907433b 100644 --- a/chaincfg/params.go +++ b/chaincfg/params.go @@ -134,11 +134,11 @@ var stringsToBech32Prefixes = map[string]Bech32Prefix{ "dagsim": DagSim, } -// Attempts to parse a Bech32 address prefix. +// ParsePrefix attempts to parse a Bech32 address prefix. func ParsePrefix(prefixString string) (Bech32Prefix, error) { prefix, ok := stringsToBech32Prefixes[prefixString] if !ok { - return Unknown, errors.New(fmt.Sprintf("could not parse prefix %v", prefixString)) + return Unknown, fmt.Errorf("could not parse prefix %v", prefixString) } return prefix, nil diff --git a/connmgr/doc.go b/connmgr/doc.go index acb90c31a..c8bbe825f 100644 --- a/connmgr/doc.go +++ b/connmgr/doc.go @@ -11,4 +11,4 @@ Connection Manager handles all the general connection concerns such as maintaining a set number of outbound connections, sourcing peers, banning, limiting max connections, tor lookup, etc. */ -package connmgr +package connmgr \ No newline at end of file diff --git a/database/doc.go b/database/doc.go index 497206713..3c307bf80 100644 --- a/database/doc.go +++ b/database/doc.go @@ -88,4 +88,4 @@ provide the ability to create an arbitrary number of nested buckets. It is a good idea to avoid a lot of buckets with little data in them as it could lead to poor page utilization depending on the specific driver in use. */ -package database +package database \ No newline at end of file diff --git a/database/ffldb/doc.go b/database/ffldb/doc.go index 96a2992cb..b3a0fd978 100644 --- a/database/ffldb/doc.go +++ b/database/ffldb/doc.go @@ -26,4 +26,4 @@ database path as a string and the block network: // Handle error } */ -package ffldb +package ffldb \ No newline at end of file diff --git a/database/internal/treap/doc.go b/database/internal/treap/doc.go index 4f46e057c..037a01cc0 100644 --- a/database/internal/treap/doc.go +++ b/database/internal/treap/doc.go @@ -24,4 +24,4 @@ since the treap it points to is immutable. This effectively provides O(1) snapshot capability with efficient memory usage characteristics since the old nodes only remain allocated until there are no longer any references to them. */ -package treap +package treap \ No newline at end of file diff --git a/mempool/doc.go b/mempool/doc.go index 3adad018b..57eb240ee 100644 --- a/mempool/doc.go +++ b/mempool/doc.go @@ -78,4 +78,4 @@ violations through type assertions. In addition, callers can programmatically determine the specific rule violation by type asserting the Err field to one of the aforementioned types and examining their underlying ErrorCode field. */ -package mempool +package mempool \ No newline at end of file diff --git a/netsync/doc.go b/netsync/doc.go index 7f45286d7..32a165d5a 100644 --- a/netsync/doc.go +++ b/netsync/doc.go @@ -10,4 +10,4 @@ new blocks connected to the chain. Currently the sync manager selects a single sync peer that it downloads all blocks from until it is up to date with the longest chain the sync peer is aware of. */ -package netsync +package netsync \ No newline at end of file diff --git a/peer/doc.go b/peer/doc.go index d483faddd..01bc2e8ed 100644 --- a/peer/doc.go +++ b/peer/doc.go @@ -147,4 +147,4 @@ Bitcoin Improvement Proposals This package supports all BIPS supported by the wire package. (https://godoc.org/github.com/daglabs/btcd/wire#hdr-Bitcoin_Improvement_Proposals) */ -package peer +package peer \ No newline at end of file diff --git a/rpcclient/doc.go b/rpcclient/doc.go index 347ad786e..8423f1658 100644 --- a/rpcclient/doc.go +++ b/rpcclient/doc.go @@ -175,4 +175,4 @@ The following full-blown client examples are in the examples directory: for notifications about changes to account balances, and gets a list of unspent transaction outputs (utxos) the wallet can sign */ -package rpcclient +package rpcclient \ No newline at end of file diff --git a/txscript/doc.go b/txscript/doc.go index 7da521615..1bf3c7c7c 100644 --- a/txscript/doc.go +++ b/txscript/doc.go @@ -39,4 +39,4 @@ error messages with contextual information. A convenience function named IsErrorCode is also provided to allow callers to easily check for a specific error code. See ErrorCode in the package documentation for a full list. */ -package txscript +package txscript \ No newline at end of file diff --git a/wire/doc.go b/wire/doc.go index b8b8c56ff..73ba5c7ed 100644 --- a/wire/doc.go +++ b/wire/doc.go @@ -159,4 +159,4 @@ This package includes spec changes outlined by the following BIPs: BIP0130 (https://github.com/bitcoin/bips/blob/master/bip-0130.mediawiki) BIP0133 (https://github.com/bitcoin/bips/blob/master/bip-0133.mediawiki) */ -package wire +package wire \ No newline at end of file