Drop fastsha256 in favor of crypto/sha256 (#468)
This commit is contained in:
parent
3e598f0f7b
commit
15635025c4
13 changed files with 90 additions and 80 deletions
|
@ -1,7 +1,7 @@
|
|||
language: go
|
||||
go:
|
||||
- 1.6.3
|
||||
- 1.7.3
|
||||
- 1.6.x
|
||||
- 1.7.x
|
||||
sudo: false
|
||||
before_install:
|
||||
- GLIDE_TAG=v0.12.3
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
// Copyright (c) 2013-2016 The btcsuite developers
|
||||
// Copyright (c) 2013-2017 The btcsuite developers
|
||||
// Use of this source code is governed by an ISC
|
||||
// license that can be found in the LICENSE file.
|
||||
|
||||
|
@ -500,9 +500,9 @@ func loadConfig() (*config, []string, error) {
|
|||
}
|
||||
|
||||
localhostListeners := map[string]struct{}{
|
||||
"localhost": struct{}{},
|
||||
"127.0.0.1": struct{}{},
|
||||
"::1": struct{}{},
|
||||
"localhost": {},
|
||||
"127.0.0.1": {},
|
||||
"::1": {},
|
||||
}
|
||||
RPCHost, _, err := net.SplitHostPort(cfg.RPCConnect)
|
||||
if err != nil {
|
||||
|
|
29
glide.lock
generated
29
glide.lock
generated
|
@ -1,10 +1,10 @@
|
|||
hash: 5efa5cef5495a0b5256f45ecb2456ea21101934ed56e780a46b1c16e30177ebc
|
||||
updated: 2016-10-27T11:54:19.492811-05:00
|
||||
hash: d945622a1e24954b5ffe2855e922e687132ccc13fb1a1bc5d57c15c72603948a
|
||||
updated: 2017-01-11T20:24:15.024651319-05:00
|
||||
imports:
|
||||
- name: github.com/boltdb/bolt
|
||||
version: 583e8937c61f1af6513608ccc75c97b6abdf4ff9
|
||||
- name: github.com/btcsuite/btcd
|
||||
version: f6ad7eb2c963151c71de2bd37d04d9af644a891d
|
||||
version: 7c0fd83c87b2d2be405489cff522e0110328cd1e
|
||||
subpackages:
|
||||
- blockchain
|
||||
- btcec
|
||||
|
@ -17,16 +17,14 @@ imports:
|
|||
- name: github.com/btcsuite/btclog
|
||||
version: 73889fb79bd687870312b6e40effcecffbd57d30
|
||||
- name: github.com/btcsuite/btcrpcclient
|
||||
version: 2b780d16b042054d07aa322146194118fd7f7b81
|
||||
version: 5ce0ed600997eafaed25ad4936c1d84ec6ad2b5a
|
||||
- name: github.com/btcsuite/btcutil
|
||||
version: 9b9ce80a2edafc6198569550fcc01df11d214425
|
||||
version: 86346b5a958c0cf94186b87855469ae991be501c
|
||||
subpackages:
|
||||
- base58
|
||||
- hdkeychain
|
||||
- name: github.com/btcsuite/fastsha256
|
||||
version: 637e656429416087660c84436a2a035d69d54e2e
|
||||
- name: github.com/btcsuite/go-socks
|
||||
version: cfe8b59e565c1a5bd4e2005d77cd9aa8b2e14524
|
||||
version: 4720035b7bfd2a9bb130b1c184f8bbe41b6f0d0f
|
||||
subpackages:
|
||||
- socks
|
||||
- name: github.com/btcsuite/golangcrypto
|
||||
|
@ -44,13 +42,13 @@ imports:
|
|||
- name: github.com/btcsuite/websocket
|
||||
version: 31079b6807923eb23992c421b114992b95131b55
|
||||
- name: github.com/golang/protobuf
|
||||
version: 98fa357170587e470c5f27d3c3ea0947b71eb455
|
||||
version: 8ee79997227bf9b34611aee7946ae64735e6fd93
|
||||
subpackages:
|
||||
- proto
|
||||
- name: github.com/jessevdk/go-flags
|
||||
version: 1679536dcc895411a9f5848d9a0250be7856448c
|
||||
- name: golang.org/x/net
|
||||
version: c46f265c325130a7a6c7b27db8c6fe14b64f1a68
|
||||
version: 60c41d1de8da134c05b7b40154a9a82bf5b7edb9
|
||||
subpackages:
|
||||
- context
|
||||
- http2
|
||||
|
@ -60,9 +58,16 @@ imports:
|
|||
- lex/httplex
|
||||
- trace
|
||||
- name: golang.org/x/sys
|
||||
version: c200b10b5d5e122be351b67af224adc6128af5bf
|
||||
version: d75a52659825e75fff6158388dddc6a5b04f9ba5
|
||||
subpackages:
|
||||
- unix
|
||||
- name: golang.org/x/text
|
||||
version: 44f4f658a783b0cee41fe0a23b8fc91d9c120558
|
||||
subpackages:
|
||||
- secure/bidirule
|
||||
- transform
|
||||
- unicode/bidi
|
||||
- unicode/norm
|
||||
- name: google.golang.org/grpc
|
||||
version: b7f1379d3cbbbeb2ca3405852012e237aa05459e
|
||||
subpackages:
|
||||
|
@ -76,6 +81,6 @@ imports:
|
|||
- transport
|
||||
testImports:
|
||||
- name: github.com/davecgh/go-spew
|
||||
version: 6d212800a42e8ab5c146b8ace3490ee17e5225f9
|
||||
version: 346938d642f2ec3594ed81d874461961cd0faa76
|
||||
subpackages:
|
||||
- spew
|
||||
|
|
17
glide.yaml
17
glide.yaml
|
@ -1,11 +1,14 @@
|
|||
package: github.com/btcsuite/btcwallet
|
||||
import:
|
||||
- package: github.com/boltdb/bolt
|
||||
version: ^1.3.0
|
||||
- package: github.com/btcsuite/btcd
|
||||
subpackages:
|
||||
- blockchain
|
||||
- btcec
|
||||
- btcjson
|
||||
- chaincfg
|
||||
- chaincfg/chainhash
|
||||
- txscript
|
||||
- wire
|
||||
- package: github.com/btcsuite/btclog
|
||||
|
@ -13,7 +16,6 @@ import:
|
|||
- package: github.com/btcsuite/btcutil
|
||||
subpackages:
|
||||
- hdkeychain
|
||||
- package: github.com/btcsuite/fastsha256
|
||||
- package: github.com/btcsuite/golangcrypto
|
||||
subpackages:
|
||||
- nacl/secretbox
|
||||
|
@ -25,16 +27,19 @@ import:
|
|||
- package: github.com/golang/protobuf
|
||||
subpackages:
|
||||
- proto
|
||||
- package: github.com/jessevdk/go-flags
|
||||
version: 1679536dcc895411a9f5848d9a0250be7856448c
|
||||
- package: golang.org/x/net
|
||||
subpackages:
|
||||
- context
|
||||
- package: google.golang.org/grpc
|
||||
version: ^1.0.0
|
||||
version: 1.0.3
|
||||
subpackages:
|
||||
- codes
|
||||
- credentials
|
||||
- grpclog
|
||||
- package: github.com/jessevdk/go-flags
|
||||
version: 1679536dcc895411a9f5848d9a0250be7856448c
|
||||
- package: github.com/boltdb/bolt
|
||||
version: ^1.3.0
|
||||
testImport:
|
||||
- package: github.com/davecgh/go-spew
|
||||
version: ^1.1.0
|
||||
subpackages:
|
||||
- spew
|
||||
|
|
|
@ -1,10 +1,11 @@
|
|||
// Copyright (c) 2013-2015 The btcsuite developers
|
||||
// Copyright (c) 2013-2017 The btcsuite developers
|
||||
// Use of this source code is governed by an ISC
|
||||
// license that can be found in the LICENSE file.
|
||||
|
||||
package legacyrpc
|
||||
|
||||
import (
|
||||
"crypto/sha256"
|
||||
"crypto/subtle"
|
||||
"encoding/base64"
|
||||
"encoding/json"
|
||||
|
@ -21,7 +22,6 @@ import (
|
|||
"github.com/btcsuite/btcd/btcjson"
|
||||
"github.com/btcsuite/btcwallet/chain"
|
||||
"github.com/btcsuite/btcwallet/wallet"
|
||||
"github.com/btcsuite/fastsha256"
|
||||
"github.com/btcsuite/websocket"
|
||||
)
|
||||
|
||||
|
@ -66,7 +66,7 @@ type Server struct {
|
|||
handlerMu sync.Mutex
|
||||
|
||||
listeners []net.Listener
|
||||
authsha [fastsha256.Size]byte
|
||||
authsha [sha256.Size]byte
|
||||
upgrader websocket.Upgrader
|
||||
|
||||
maxPostClients int64 // Max concurrent HTTP POST clients.
|
||||
|
@ -105,7 +105,7 @@ func NewServer(opts *Options, walletLoader *wallet.Loader, listeners []net.Liste
|
|||
listeners: listeners,
|
||||
// A hash of the HTTP basic auth string is used for a constant
|
||||
// time comparison.
|
||||
authsha: fastsha256.Sum256(httpBasicAuth(opts.Username, opts.Password)),
|
||||
authsha: sha256.Sum256(httpBasicAuth(opts.Username, opts.Password)),
|
||||
upgrader: websocket.Upgrader{
|
||||
// Allow all origins.
|
||||
CheckOrigin: func(r *http.Request) bool { return true },
|
||||
|
@ -301,7 +301,7 @@ func (s *Server) checkAuthHeader(r *http.Request) error {
|
|||
return ErrNoAuth
|
||||
}
|
||||
|
||||
authsha := fastsha256.Sum256([]byte(authhdr[0]))
|
||||
authsha := sha256.Sum256([]byte(authhdr[0]))
|
||||
cmp := subtle.ConstantTimeCompare(authsha[:], s.authsha[:])
|
||||
if cmp != 1 {
|
||||
return errors.New("bad auth")
|
||||
|
@ -378,7 +378,7 @@ func (s *Server) invalidAuth(req *btcjson.Request) bool {
|
|||
// Check credentials.
|
||||
login := authCmd.Username + ":" + authCmd.Passphrase
|
||||
auth := "Basic " + base64.StdEncoding.EncodeToString([]byte(login))
|
||||
authSha := fastsha256.Sum256([]byte(auth))
|
||||
authSha := sha256.Sum256([]byte(auth))
|
||||
return subtle.ConstantTimeCompare(authSha[:], s.authsha[:]) != 1
|
||||
}
|
||||
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
// Copyright (c) 2014-2015 The btcsuite developers
|
||||
// Copyright (c) 2014-2017 The btcsuite developers
|
||||
// Use of this source code is governed by an ISC
|
||||
// license that can be found in the LICENSE file.
|
||||
|
||||
|
@ -6,6 +6,7 @@ package snacl
|
|||
|
||||
import (
|
||||
"crypto/rand"
|
||||
"crypto/sha256"
|
||||
"crypto/subtle"
|
||||
"encoding/binary"
|
||||
"errors"
|
||||
|
@ -13,7 +14,6 @@ import (
|
|||
"runtime/debug"
|
||||
|
||||
"github.com/btcsuite/btcwallet/internal/zero"
|
||||
"github.com/btcsuite/fastsha256"
|
||||
"github.com/btcsuite/golangcrypto/nacl/secretbox"
|
||||
"github.com/btcsuite/golangcrypto/scrypt"
|
||||
)
|
||||
|
@ -96,7 +96,7 @@ func GenerateCryptoKey() (*CryptoKey, error) {
|
|||
// Parameters are not secret and can be stored in plain text.
|
||||
type Parameters struct {
|
||||
Salt [KeySize]byte
|
||||
Digest [fastsha256.Size]byte
|
||||
Digest [sha256.Size]byte
|
||||
N int
|
||||
R int
|
||||
P int
|
||||
|
@ -141,14 +141,14 @@ func (sk *SecretKey) Marshal() []byte {
|
|||
// The marshalled format for the the params is as follows:
|
||||
// <salt><digest><N><R><P>
|
||||
//
|
||||
// KeySize + fastsha256.Size + N (8 bytes) + R (8 bytes) + P (8 bytes)
|
||||
marshalled := make([]byte, KeySize+fastsha256.Size+24)
|
||||
// KeySize + sha256.Size + N (8 bytes) + R (8 bytes) + P (8 bytes)
|
||||
marshalled := make([]byte, KeySize+sha256.Size+24)
|
||||
|
||||
b := marshalled
|
||||
copy(b[:KeySize], params.Salt[:])
|
||||
b = b[KeySize:]
|
||||
copy(b[:fastsha256.Size], params.Digest[:])
|
||||
b = b[fastsha256.Size:]
|
||||
copy(b[:sha256.Size], params.Digest[:])
|
||||
b = b[sha256.Size:]
|
||||
binary.LittleEndian.PutUint64(b[:8], uint64(params.N))
|
||||
b = b[8:]
|
||||
binary.LittleEndian.PutUint64(b[:8], uint64(params.R))
|
||||
|
@ -168,16 +168,16 @@ func (sk *SecretKey) Unmarshal(marshalled []byte) error {
|
|||
// The marshalled format for the the params is as follows:
|
||||
// <salt><digest><N><R><P>
|
||||
//
|
||||
// KeySize + fastsha256.Size + N (8 bytes) + R (8 bytes) + P (8 bytes)
|
||||
if len(marshalled) != KeySize+fastsha256.Size+24 {
|
||||
// KeySize + sha256.Size + N (8 bytes) + R (8 bytes) + P (8 bytes)
|
||||
if len(marshalled) != KeySize+sha256.Size+24 {
|
||||
return ErrMalformed
|
||||
}
|
||||
|
||||
params := &sk.Parameters
|
||||
copy(params.Salt[:], marshalled[:KeySize])
|
||||
marshalled = marshalled[KeySize:]
|
||||
copy(params.Digest[:], marshalled[:fastsha256.Size])
|
||||
marshalled = marshalled[fastsha256.Size:]
|
||||
copy(params.Digest[:], marshalled[:sha256.Size])
|
||||
marshalled = marshalled[sha256.Size:]
|
||||
params.N = int(binary.LittleEndian.Uint64(marshalled[:8]))
|
||||
marshalled = marshalled[8:]
|
||||
params.R = int(binary.LittleEndian.Uint64(marshalled[:8]))
|
||||
|
@ -203,7 +203,7 @@ func (sk *SecretKey) DeriveKey(password *[]byte) error {
|
|||
}
|
||||
|
||||
// verify password
|
||||
digest := fastsha256.Sum256(sk.Key[:])
|
||||
digest := sha256.Sum256(sk.Key[:])
|
||||
if subtle.ConstantTimeCompare(digest[:], sk.Parameters.Digest[:]) != 1 {
|
||||
return ErrInvalidPassword
|
||||
}
|
||||
|
@ -242,7 +242,7 @@ func NewSecretKey(password *[]byte, N, r, p int) (*SecretKey, error) {
|
|||
}
|
||||
|
||||
// store digest
|
||||
sk.Parameters.Digest = fastsha256.Sum256(sk.Key[:])
|
||||
sk.Parameters.Digest = sha256.Sum256(sk.Key[:])
|
||||
|
||||
return &sk, nil
|
||||
}
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
* Copyright (c) 2014 The btcsuite developers
|
||||
* Copyright (c) 2014-2017 The btcsuite developers
|
||||
*
|
||||
* Permission to use, copy, modify, and distribute this software for any
|
||||
* purpose with or without fee is hereby granted, provided that the above
|
||||
|
@ -203,7 +203,7 @@ func Example_startWithdrawal() {
|
|||
addr, _ := btcutil.DecodeAddress("1MirQ9bwyQcGVJPwKUgapu5ouK2E2Ey4gX", mgr.ChainParams())
|
||||
pkScript, _ := txscript.PayToAddrScript(addr)
|
||||
requests := []votingpool.OutputRequest{
|
||||
votingpool.OutputRequest{
|
||||
{
|
||||
PkScript: pkScript,
|
||||
Address: addr,
|
||||
Amount: 1e6,
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
// Copyright (c) 2015-2016 The btcsuite developers
|
||||
// Copyright (c) 2015-2017 The btcsuite developers
|
||||
// Use of this source code is governed by an ISC
|
||||
// license that can be found in the LICENSE file.
|
||||
|
||||
|
@ -264,9 +264,9 @@ func TestCreditSortingByAddress(t *testing.T) {
|
|||
c6 := newDummyCredit(t, pool, 2, 0, 0, shaHash0, 0)
|
||||
|
||||
randomCredits := [][]credit{
|
||||
[]credit{c6, c5, c4, c3, c2, c1, c0},
|
||||
[]credit{c2, c1, c0, c6, c5, c4, c3},
|
||||
[]credit{c6, c4, c5, c2, c3, c0, c1},
|
||||
{c6, c5, c4, c3, c2, c1, c0},
|
||||
{c2, c1, c0, c6, c5, c4, c3},
|
||||
{c6, c4, c5, c2, c3, c0, c1},
|
||||
}
|
||||
|
||||
want := []credit{c0, c1, c2, c3, c4, c5, c6}
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
// Copyright (c) 2015-2016 The btcsuite developers
|
||||
// Copyright (c) 2015-2017 The btcsuite developers
|
||||
// Use of this source code is governed by an ISC
|
||||
// license that can be found in the LICENSE file.
|
||||
|
||||
|
@ -6,6 +6,7 @@ package votingpool
|
|||
|
||||
import (
|
||||
"bytes"
|
||||
"crypto/sha256"
|
||||
"fmt"
|
||||
"math"
|
||||
"reflect"
|
||||
|
@ -19,7 +20,6 @@ import (
|
|||
"github.com/btcsuite/btcwallet/waddrmgr"
|
||||
"github.com/btcsuite/btcwallet/walletdb"
|
||||
"github.com/btcsuite/btcwallet/wtxmgr"
|
||||
"github.com/btcsuite/fastsha256"
|
||||
)
|
||||
|
||||
// Maximum tx size (in bytes). This should be the same as bitcoind's
|
||||
|
@ -212,7 +212,7 @@ func (r OutputRequest) outBailmentIDHash() []byte {
|
|||
return r.cachedHash
|
||||
}
|
||||
str := r.Server + strconv.Itoa(int(r.Transaction))
|
||||
hasher := fastsha256.New()
|
||||
hasher := sha256.New()
|
||||
// hasher.Write() always returns nil as the error, so it's safe to ignore it here.
|
||||
_, _ = hasher.Write([]byte(str))
|
||||
id := hasher.Sum(nil)
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
// Copyright (c) 2015 The btcsuite developers
|
||||
// Copyright (c) 2015-2017 The btcsuite developers
|
||||
// Use of this source code is governed by an ISC
|
||||
// license that can be found in the LICENSE file.
|
||||
|
||||
|
@ -413,14 +413,14 @@ func TestRollbackLastOutputWhenNewOutputAdded(t *testing.T) {
|
|||
firstTx := w.transactions[0]
|
||||
req1 := requests[0]
|
||||
checkTxOutputs(t, firstTx,
|
||||
[]*withdrawalTxOut{&withdrawalTxOut{request: req1, amount: req1.Amount}})
|
||||
[]*withdrawalTxOut{{request: req1, amount: req1.Amount}})
|
||||
checkTxChangeAmount(t, firstTx, btcutil.Amount(4))
|
||||
|
||||
// Second tx should have one output with 2 and one changeoutput with 3 satoshis.
|
||||
secondTx := w.transactions[1]
|
||||
req2 := requests[1]
|
||||
checkTxOutputs(t, secondTx,
|
||||
[]*withdrawalTxOut{&withdrawalTxOut{request: req2, amount: req2.Amount}})
|
||||
[]*withdrawalTxOut{{request: req2, amount: req2.Amount}})
|
||||
checkTxChangeAmount(t, secondTx, btcutil.Amount(3))
|
||||
}
|
||||
|
||||
|
@ -469,7 +469,7 @@ func TestRollbackLastOutputWhenNewInputAdded(t *testing.T) {
|
|||
firstTx := w.transactions[0]
|
||||
req1 := requests[0]
|
||||
checkTxOutputs(t, firstTx,
|
||||
[]*withdrawalTxOut{&withdrawalTxOut{request: req1, amount: req1.Amount}})
|
||||
[]*withdrawalTxOut{{request: req1, amount: req1.Amount}})
|
||||
checkTxInputs(t, firstTx, eligible[5:6])
|
||||
|
||||
// Second tx should have outputs for the two last requests (in the same
|
||||
|
@ -478,8 +478,8 @@ func TestRollbackLastOutputWhenNewInputAdded(t *testing.T) {
|
|||
// that's how fulfillRequests() consumes them) and no change output.
|
||||
secondTx := w.transactions[1]
|
||||
wantOutputs := []*withdrawalTxOut{
|
||||
&withdrawalTxOut{request: requests[1], amount: requests[1].Amount},
|
||||
&withdrawalTxOut{request: requests[2], amount: requests[2].Amount}}
|
||||
{request: requests[1], amount: requests[1].Amount},
|
||||
{request: requests[2], amount: requests[2].Amount}}
|
||||
checkTxOutputs(t, secondTx, wantOutputs)
|
||||
wantInputs := []credit{eligible[4], eligible[3], eligible[2]}
|
||||
checkTxInputs(t, secondTx, wantInputs)
|
||||
|
@ -804,7 +804,7 @@ func TestSignMultiSigUTXOUnparseablePkScript(t *testing.T) {
|
|||
msgtx := tx.toMsgTx()
|
||||
|
||||
unparseablePkScript := []byte{0x01}
|
||||
err := signMultiSigUTXO(mgr, msgtx, 0, unparseablePkScript, []RawSig{RawSig{}})
|
||||
err := signMultiSigUTXO(mgr, msgtx, 0, unparseablePkScript, []RawSig{{}})
|
||||
|
||||
TstCheckError(t, "", err, ErrTxSigning)
|
||||
}
|
||||
|
@ -819,7 +819,7 @@ func TestSignMultiSigUTXOPkScriptNotP2SH(t *testing.T) {
|
|||
pubKeyHashPkScript, _ := txscript.PayToAddrScript(addr.(*btcutil.AddressPubKeyHash))
|
||||
msgtx := tx.toMsgTx()
|
||||
|
||||
err := signMultiSigUTXO(mgr, msgtx, 0, pubKeyHashPkScript, []RawSig{RawSig{}})
|
||||
err := signMultiSigUTXO(mgr, msgtx, 0, pubKeyHashPkScript, []RawSig{{}})
|
||||
|
||||
TstCheckError(t, "", err, ErrTxSigning)
|
||||
}
|
||||
|
@ -839,7 +839,7 @@ func TestSignMultiSigUTXORedeemScriptNotFound(t *testing.T) {
|
|||
msgtx := tx.toMsgTx()
|
||||
|
||||
pkScript, _ := txscript.PayToAddrScript(addr.(*btcutil.AddressScriptHash))
|
||||
err := signMultiSigUTXO(mgr, msgtx, 0, pkScript, []RawSig{RawSig{}})
|
||||
err := signMultiSigUTXO(mgr, msgtx, 0, pkScript, []RawSig{{}})
|
||||
|
||||
TstCheckError(t, "", err, ErrTxSigning)
|
||||
}
|
||||
|
@ -875,7 +875,7 @@ func TestSignMultiSigUTXOWrongRawSigs(t *testing.T) {
|
|||
|
||||
mgr := pool.Manager()
|
||||
tx := createWithdrawalTx(t, pool, []int64{4e6}, []int64{})
|
||||
sigs := []RawSig{RawSig{0x00}, RawSig{0x01}}
|
||||
sigs := []RawSig{{0x00}, {0x01}}
|
||||
|
||||
idx := 0 // The index of the tx input we're going to sign.
|
||||
pkScript := tx.inputs[idx].PkScript
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
// Copyright (c) 2014-2016 The btcsuite developers
|
||||
// Copyright (c) 2014-2017 The btcsuite developers
|
||||
// Use of this source code is governed by an ISC
|
||||
// license that can be found in the LICENSE file.
|
||||
|
||||
|
@ -6,6 +6,7 @@ package waddrmgr
|
|||
|
||||
import (
|
||||
"bytes"
|
||||
"crypto/sha256"
|
||||
"encoding/binary"
|
||||
"fmt"
|
||||
"time"
|
||||
|
@ -14,7 +15,6 @@ import (
|
|||
"github.com/btcsuite/btcd/chaincfg/chainhash"
|
||||
"github.com/btcsuite/btcutil/hdkeychain"
|
||||
"github.com/btcsuite/btcwallet/walletdb"
|
||||
"github.com/btcsuite/fastsha256"
|
||||
)
|
||||
|
||||
const (
|
||||
|
@ -1006,7 +1006,7 @@ func fetchAddressByHash(tx walletdb.Tx, addrHash []byte) (interface{}, error) {
|
|||
func fetchAddressUsed(tx walletdb.Tx, addressID []byte) bool {
|
||||
bucket := tx.RootBucket().Bucket(usedAddrBucketName)
|
||||
|
||||
addrHash := fastsha256.Sum256(addressID)
|
||||
addrHash := sha256.Sum256(addressID)
|
||||
return bucket.Get(addrHash[:]) != nil
|
||||
}
|
||||
|
||||
|
@ -1014,7 +1014,7 @@ func fetchAddressUsed(tx walletdb.Tx, addressID []byte) bool {
|
|||
func markAddressUsed(tx walletdb.Tx, addressID []byte) error {
|
||||
bucket := tx.RootBucket().Bucket(usedAddrBucketName)
|
||||
|
||||
addrHash := fastsha256.Sum256(addressID)
|
||||
addrHash := sha256.Sum256(addressID)
|
||||
val := bucket.Get(addrHash[:])
|
||||
if val != nil {
|
||||
return nil
|
||||
|
@ -1033,7 +1033,7 @@ func markAddressUsed(tx walletdb.Tx, addressID []byte) error {
|
|||
// The caller should prefix the error message with the address which caused the
|
||||
// failure.
|
||||
func fetchAddress(tx walletdb.Tx, addressID []byte) (interface{}, error) {
|
||||
addrHash := fastsha256.Sum256(addressID)
|
||||
addrHash := sha256.Sum256(addressID)
|
||||
return fetchAddressByHash(tx, addrHash[:])
|
||||
}
|
||||
|
||||
|
@ -1045,7 +1045,7 @@ func putAddress(tx walletdb.Tx, addressID []byte, row *dbAddressRow) error {
|
|||
// Write the serialized value keyed by the hash of the address. The
|
||||
// additional hash is used to conceal the actual address while still
|
||||
// allowed keyed lookups.
|
||||
addrHash := fastsha256.Sum256(addressID)
|
||||
addrHash := sha256.Sum256(addressID)
|
||||
err := bucket.Put(addrHash[:], serializeAddressRow(row))
|
||||
if err != nil {
|
||||
str := fmt.Sprintf("failed to store address %x", addressID)
|
||||
|
@ -1151,7 +1151,7 @@ func putScriptAddress(tx walletdb.Tx, addressID []byte, account uint32,
|
|||
func existsAddress(tx walletdb.Tx, addressID []byte) bool {
|
||||
bucket := tx.RootBucket().Bucket(addrBucketName)
|
||||
|
||||
addrHash := fastsha256.Sum256(addressID)
|
||||
addrHash := sha256.Sum256(addressID)
|
||||
return bucket.Get(addrHash[:]) != nil
|
||||
}
|
||||
|
||||
|
@ -1161,7 +1161,7 @@ func existsAddress(tx walletdb.Tx, addressID []byte) bool {
|
|||
func fetchAddrAccount(tx walletdb.Tx, addressID []byte) (uint32, error) {
|
||||
bucket := tx.RootBucket().Bucket(addrAcctIdxBucketName)
|
||||
|
||||
addrHash := fastsha256.Sum256(addressID)
|
||||
addrHash := sha256.Sum256(addressID)
|
||||
val := bucket.Get(addrHash[:])
|
||||
if val == nil {
|
||||
str := "address not found"
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
// Copyright (c) 2015-2016 The btcsuite developers
|
||||
// Copyright (c) 2015-2017 The btcsuite developers
|
||||
// Use of this source code is governed by an ISC
|
||||
// license that can be found in the LICENSE file.
|
||||
|
||||
|
@ -516,8 +516,8 @@ func TestStoreQueries(t *testing.T) {
|
|||
newState = lastState.deepCopy()
|
||||
newState.blocks = [][]TxDetails{
|
||||
newState.blocks[0],
|
||||
[]TxDetails{newState.blocks[1][0]},
|
||||
[]TxDetails{newState.blocks[1][1]},
|
||||
{newState.blocks[1][0]},
|
||||
{newState.blocks[1][1]},
|
||||
}
|
||||
newState.blocks[1][0].Block = b101
|
||||
newState.txDetails[recA.Hash][1].Block = b101
|
||||
|
@ -558,17 +558,17 @@ func TestPreviousPkScripts(t *testing.T) {
|
|||
buildTx := func(prevHash *chainhash.Hash, script0, script1 []byte) *wire.MsgTx {
|
||||
return &wire.MsgTx{
|
||||
TxIn: []*wire.TxIn{
|
||||
&wire.TxIn{PreviousOutPoint: wire.OutPoint{
|
||||
{PreviousOutPoint: wire.OutPoint{
|
||||
Hash: *prevHash,
|
||||
Index: 0,
|
||||
}},
|
||||
&wire.TxIn{PreviousOutPoint: wire.OutPoint{
|
||||
{PreviousOutPoint: wire.OutPoint{
|
||||
Hash: *prevHash, Index: 1,
|
||||
}},
|
||||
},
|
||||
TxOut: []*wire.TxOut{
|
||||
&wire.TxOut{Value: 1e8, PkScript: script0},
|
||||
&wire.TxOut{Value: 1e8, PkScript: script1},
|
||||
{Value: 1e8, PkScript: script0},
|
||||
{Value: 1e8, PkScript: script1},
|
||||
},
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
// Copyright (c) 2013-2016 The btcsuite developers
|
||||
// Copyright (c) 2013-2017 The btcsuite developers
|
||||
// Use of this source code is governed by an ISC
|
||||
// license that can be found in the LICENSE file.
|
||||
|
||||
|
@ -606,7 +606,7 @@ func TestFindingSpentCredits(t *testing.T) {
|
|||
func newCoinBase(outputValues ...int64) *wire.MsgTx {
|
||||
tx := wire.MsgTx{
|
||||
TxIn: []*wire.TxIn{
|
||||
&wire.TxIn{
|
||||
{
|
||||
PreviousOutPoint: wire.OutPoint{Index: ^uint32(0)},
|
||||
},
|
||||
},
|
||||
|
@ -620,7 +620,7 @@ func newCoinBase(outputValues ...int64) *wire.MsgTx {
|
|||
func spendOutput(txHash *chainhash.Hash, index uint32, outputValues ...int64) *wire.MsgTx {
|
||||
tx := wire.MsgTx{
|
||||
TxIn: []*wire.TxIn{
|
||||
&wire.TxIn{
|
||||
{
|
||||
PreviousOutPoint: wire.OutPoint{Hash: *txHash, Index: index},
|
||||
},
|
||||
},
|
||||
|
|
Loading…
Reference in a new issue