Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update dependencies #1

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 6 additions & 6 deletions Gopkg.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 3 additions & 3 deletions Gopkg.toml
Original file line number Diff line number Diff line change
@@ -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"]
Expand Down Expand Up @@ -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
Expand Down
6 changes: 4 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
```

Expand Down
37 changes: 1 addition & 36 deletions main.go
Original file line number Diff line number Diff line change
@@ -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.

Expand All @@ -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
Expand Down Expand Up @@ -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"
Expand Down Expand Up @@ -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
Expand All @@ -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
}
4 changes: 3 additions & 1 deletion version.go
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
// Copyright (c) 2015, 2018 The Decred developers

package main

import "fmt"
Expand All @@ -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:
Expand Down
49 changes: 18 additions & 31 deletions wif.go
Original file line number Diff line number Diff line change
@@ -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.

Expand All @@ -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
Expand All @@ -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}
}

Expand Down Expand Up @@ -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)
Expand All @@ -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...)
}