diff --git a/Gopkg.lock b/Gopkg.lock index 9831f0c..d7b4459 100644 --- a/Gopkg.lock +++ b/Gopkg.lock @@ -17,16 +17,16 @@ revision = "53f62d9b43e87a6c56975cf862af7edf33a8d0df" [[projects]] - branch = "master" name = "github.com/dchest/blake256" packages = ["."] revision = "dee3fe6eb0e98dc774a94fc231f85baf7c29d360" + version = "v1.0.0" [[projects]] - branch = "master" name = "github.com/decred/base58" packages = ["."] revision = "56c501706f00d9e1cfacee19a27117e12da24734" + version = "v1.0.0" [[projects]] name = "github.com/decred/dcrd" @@ -40,18 +40,18 @@ "dcrutil", "wire" ] - revision = "008e80bf8668544de4200a08927e95e5926439a0" - version = "v1.1.2" + revision = "fd99f572cfd52ca722ad501ccb34acdcb22b4a67" + version = "v1.2.0" [[projects]] branch = "master" name = "golang.org/x/crypto" packages = ["ripemd160"] - revision = "91a49db82a88618983a78a06c1cbd4e00ab749ab" + revision = "37a17fe027db43f76fd88b056ddf588563fc8722" [solve-meta] analyzer-name = "dep" analyzer-version = 1 - inputs-digest = "b2bef9c09e7edbc322fdb6cac78be875f752eea2435f8426163d1b46cbd4ecab" + inputs-digest = "0110482b3235021fdaaf4cb8982aa040e88503f659adab65233b6792f518f5f5" solver-name = "gps-cdcl" solver-version = 1 diff --git a/Gopkg.toml b/Gopkg.toml index 7547ef1..f705e59 100644 --- a/Gopkg.toml +++ b/Gopkg.toml @@ -1,6 +1,6 @@ # Gopkg.toml example # -# Refer to https://github.com/golang/dep/blob/master/docs/Gopkg.toml.md +# Refer to https://golang.github.io/dep/docs/Gopkg.toml.html # for detailed Gopkg.toml documentation. # # required = ["github.com/user/thing/cmd/thing"] @@ -30,12 +30,12 @@ name = "github.com/btcsuite/golangcrypto" [[constraint]] - branch = "master" name = "github.com/decred/base58" + version = "1.0.0" [[constraint]] name = "github.com/decred/dcrd" - version = "1.1.2" + version = "1.2.0" [prune] go-tests = true diff --git a/README.md b/README.md index db3e4a6..4ffd916 100644 --- a/README.md +++ b/README.md @@ -20,11 +20,13 @@ also][2]. ## Installation +You must use `dep` to fetch the correct dependencies. + ```bash git clone https://github.com/chappjc/dcrvanity $GOPATH/src/chappjc/dcrvanity cd $GOPATH/src/chappjc/dcrvanity -go get -u github.com/Masterminds/glide -$GOPATH/bin/glide install +go get -u -v github.com/golang/dep/cmd/dep +$GOPATH/bin/dep ensure go build ``` diff --git a/main.go b/main.go index aa4d1e2..699bcdc 100644 --- a/main.go +++ b/main.go @@ -1,5 +1,5 @@ +// Copyright (c) 2015, 2018 The Decred developers // Copyright (c) 2016-2017 Jonathan Chappelow -// Copyright (c) 2015 The Decred Developers // Use of this source code is governed by an ISC // license that can be found in the LICENSE file. @@ -19,21 +19,12 @@ import ( "sync/atomic" "time" - //"github.com/davecgh/go-spew/spew" "github.com/decred/dcrd/chaincfg" "github.com/decred/dcrd/chaincfg/chainec" "github.com/decred/dcrd/dcrec/secp256k1" "github.com/decred/dcrd/dcrutil" ) -// TODO: Use a logger, if even golang's logger -// var ( -// Trace *log.Logger -// Info *log.Logger -// Warning *log.Logger -// Error *log.Logger -// ) - var curve = secp256k1.S256() var params = chaincfg.MainNetParams @@ -185,29 +176,6 @@ searchloop: //privWif := NewWIF(priv) } -// func InitLog( -// traceHandle io.Writer, -// infoHandle io.Writer, -// warningHandle io.Writer, -// errorHandle io.Writer) { - -// Trace = log.New(traceHandle, -// "TRACE: ", -// log.Ldate|log.Ltime|log.Lshortfile) - -// Info = log.New(infoHandle, -// "INFO: ", -// log.Ldate|log.Ltime|log.Lshortfile) - -// Warning = log.New(warningHandle, -// "WARNING: ", -// log.Ldate|log.Ltime|log.Lshortfile) - -// Error = log.New(errorHandle, -// "ERROR: ", -// log.Ldate|log.Ltime|log.Lshortfile) -// } - func main() { if runtime.GOOS == "windows" { newLine = "\r\n" @@ -322,7 +290,6 @@ goroutineloop: // Close the channel so multiple goroutines can get the message fmt.Print("CTRL+C hit. Terminating searchers.") close(quit) - return }() // Allow each goroutine to receive the quit signal and finish up @@ -335,6 +302,4 @@ goroutineloop: fmt.Println("Private key (WIF-encoded): ", privWif) fmt.Println("You many now import this into your wallet via importprivkey.") } - - return } diff --git a/version.go b/version.go index 21a4228..1fc4447 100644 --- a/version.go +++ b/version.go @@ -1,3 +1,5 @@ +// Copyright (c) 2015, 2018 The Decred developers + package main import "fmt" @@ -10,7 +12,7 @@ type version struct { var ver = version{ Major: 0, Minor: 1, - Patch: 3, + Patch: 4, Label: "beta"} // CommitHash may be set on the build command line: diff --git a/wif.go b/wif.go index 45ca792..be3a3f6 100644 --- a/wif.go +++ b/wif.go @@ -1,5 +1,5 @@ +// Copyright (c) 2015, 2018 The Decred developers // Copyright (c) 2013, 2014 The btcsuite developers -// Copyright (c) 2015 The Decred Developers // Use of this source code is governed by an ISC // license that can be found in the LICENSE file. @@ -15,18 +15,17 @@ import ( "github.com/decred/dcrd/dcrutil" ) -// ErrMalformedPrivateKey describes an error where a WIF-encoded private -// key cannot be decoded due to being improperly formatted. This may occur -// if the byte length is incorrect or an unexpected magic number was -// encountered. +// ErrMalformedPrivateKey describes an error where a WIF-encoded private key +// cannot be decoded due to being improperly formatted. This may occur if the +// byte length is incorrect or an unexpected magic number was encountered. var ErrMalformedPrivateKey = errors.New("malformed private key") // WIF contains the individual components described by the Wallet Import Format // (WIF). A WIF string is typically used to represent a private key and its // associated address in a way that may be easily copied and imported into or // exported from wallet software. WIF strings may be decoded into this -// structure by calling DecodeWIF or created with a user-provided private key -// by calling NewWIF. +// structure by calling DecodeWIF or created with a user-provided private key by +// calling NewWIF. type WIF struct { // ecType is the type of ECDSA used. ecType int @@ -44,6 +43,7 @@ type WIF struct { // specifies whether the address intended to be imported or exported was created // by serializing the public key compressed rather than uncompressed. func NewWIF(privKey secp256k1.PrivateKey) *WIF { + // ECTypeSecp256k1 only return &WIF{0, privKey, params.PrivateKeyID} } @@ -82,19 +82,20 @@ func DecodeWIF(wif string) (*WIF, error) { netID := [2]byte{decoded[0], decoded[1]} + // only ECTypeSecp256k1 privKeyBytes := decoded[3 : 3+secp256k1.PrivKeyBytesLen] - privKey, _ := secp256k1.PrivKeyFromBytes(curve, privKeyBytes) + privKey, _ := secp256k1.PrivKeyFromBytes(privKeyBytes) return &WIF{0, *privKey, netID}, nil } // String creates the Wallet Import Format string encoding of a WIF structure. -// See DecodeWIF for a detailed breakdown of the format and requirements of -// a valid WIF string. +// See DecodeWIF for a detailed breakdown of the format and requirements of a +// valid WIF string. func (w *WIF) String() string { - // Precalculate size. Maximum number of bytes before base58 encoding - // is two bytes for the network, one byte for the ECDSA type, 32 bytes - // of private key and finally four bytes of checksum. + // Precalculate size. Maximum number of bytes before base58 encoding is two + // bytes for the network, one byte for the ECDSA type, 32 bytes of private + // key and finally four bytes of checksum. encodeLen := 2 + 1 + 32 + 4 a := make([]byte, 0, encodeLen) @@ -108,24 +109,10 @@ func (w *WIF) String() string { } // SerializePubKey serializes the associated public key of the imported or -// exported private key in compressed format. The serialization format -// chosen depends on the value of w.ecType. +// exported private key in compressed format. The serialization format chosen +// depends on the value of w.ecType. func (w *WIF) SerializePubKey() []byte { - pk := secp256k1.PublicKey{ - Curve: curve, - X: w.PrivKey.PublicKey.X, - Y: w.PrivKey.PublicKey.Y, - } - + pkx, pky := w.PrivKey.Public() + pk := secp256k1.NewPublicKey(pkx, pky) return pk.SerializeCompressed() } - -// paddedAppend appends the src byte slice to dst, returning the new slice. -// If the length of the source is smaller than the passed size, leading zero -// bytes are appended to the dst slice before appending src. -func paddedAppend(size uint, dst, src []byte) []byte { - for i := 0; i < int(size)-len(src); i++ { - dst = append(dst, 0) - } - return append(dst, src...) -}