mirror of
https://github.com/btcsuite/btcd.git
synced 2025-03-23 07:36:18 +01:00
multi: switch project over to using btcec/v2
This commit is contained in:
parent
87e8fe92c9
commit
eee3c3b337
36 changed files with 286 additions and 414 deletions
5
.github/workflows/go.yml
vendored
5
.github/workflows/go.yml
vendored
|
@ -43,6 +43,11 @@ jobs:
|
|||
with:
|
||||
path-to-profile: coverage.txt
|
||||
|
||||
- name: Send btcec
|
||||
uses: shogo82148/actions-goveralls@v1
|
||||
with:
|
||||
path-to-profile: btcec/coverage.txt
|
||||
|
||||
- name: Send btcutil coverage
|
||||
uses: shogo82148/actions-goveralls@v1
|
||||
with:
|
||||
|
|
4
.gitignore
vendored
4
.gitignore
vendored
|
@ -36,3 +36,7 @@ _testmain.go
|
|||
# Code coverage files
|
||||
profile.tmp
|
||||
profile.cov
|
||||
coverage.txt
|
||||
btcec/coverage.txt
|
||||
btcutil/coverage.txt
|
||||
btcutil/psbt/coverage.txt
|
||||
|
|
7
Makefile
7
Makefile
|
@ -79,19 +79,22 @@ check: unit
|
|||
|
||||
unit:
|
||||
@$(call print, "Running unit tests.")
|
||||
$(GOTEST_DEV) ./... -test.timeout=20m
|
||||
$(GOTEST) ./... -test.timeout=20m
|
||||
cd btcec; $(GOTEST_DEV) ./... -test.timeout=20m
|
||||
cd btcutil; $(GOTEST_DEV) ./... -test.timeout=20m
|
||||
cd btcutil/psbt; $(GOTEST_DEV) ./... -test.timeout=20m
|
||||
|
||||
unit-cover: $(GOACC_BIN)
|
||||
@$(call print, "Running unit coverage tests.")
|
||||
$(GOACC_BIN) ./...
|
||||
cd btcec; $(GOACC_BIN) ./...
|
||||
cd btcutil; $(GOACC_BIN) ./...
|
||||
cd btcutil/psbt; $(GOACC_BIN) ./...
|
||||
|
||||
unit-race:
|
||||
@$(call print, "Running unit race tests.")
|
||||
env CGO_ENABLED=1 GORACE="history_size=7 halt_on_errors=1" $(GOTEST) -race -test.timeout=20m ./...
|
||||
cd btcec; env CGO_ENABLED=1 GORACE="history_size=7 halt_on_errors=1" $(GOTEST) -race -test.timeout=20m ./...
|
||||
cd btcutil; env CGO_ENABLED=1 GORACE="history_size=7 halt_on_errors=1" $(GOTEST) -race -test.timeout=20m ./...
|
||||
cd btcutil/psbt; env CGO_ENABLED=1 GORACE="history_size=7 halt_on_errors=1" $(GOTEST) -race -test.timeout=20m ./...
|
||||
|
||||
|
@ -111,7 +114,7 @@ lint: $(LINT_BIN)
|
|||
|
||||
clean:
|
||||
@$(call print, "Cleaning source.$(NC)")
|
||||
$(RM) coverage.txt btcutil/coverage.txt btcutil/psbt/coverage.txt
|
||||
$(RM) coverage.txt btcec/coverage.txt btcutil/coverage.txt btcutil/psbt/coverage.txt
|
||||
|
||||
.PHONY: all \
|
||||
default \
|
||||
|
|
|
@ -5,7 +5,7 @@
|
|||
package blockchain
|
||||
|
||||
import (
|
||||
"github.com/btcsuite/btcd/btcec"
|
||||
"github.com/btcsuite/btcd/btcec/v2"
|
||||
"github.com/btcsuite/btcd/txscript"
|
||||
)
|
||||
|
||||
|
@ -218,7 +218,7 @@ func isPubKey(script []byte) (bool, []byte) {
|
|||
|
||||
// Ensure the public key is valid.
|
||||
serializedPubKey := script[1:34]
|
||||
_, err := btcec.ParsePubKey(serializedPubKey, btcec.S256())
|
||||
_, err := btcec.ParsePubKey(serializedPubKey)
|
||||
if err == nil {
|
||||
return true, serializedPubKey
|
||||
}
|
||||
|
@ -230,7 +230,7 @@ func isPubKey(script []byte) (bool, []byte) {
|
|||
|
||||
// Ensure the public key is valid.
|
||||
serializedPubKey := script[1:66]
|
||||
_, err := btcec.ParsePubKey(serializedPubKey, btcec.S256())
|
||||
_, err := btcec.ParsePubKey(serializedPubKey)
|
||||
if err == nil {
|
||||
return true, serializedPubKey
|
||||
}
|
||||
|
@ -399,7 +399,7 @@ func decompressScript(compressedPkScript []byte) []byte {
|
|||
compressedKey := make([]byte, 33)
|
||||
compressedKey[0] = byte(encodedScriptSize - 2)
|
||||
copy(compressedKey[1:], compressedPkScript[1:])
|
||||
key, err := btcec.ParsePubKey(compressedKey, btcec.S256())
|
||||
key, err := btcec.ParsePubKey(compressedKey)
|
||||
if err != nil {
|
||||
return nil
|
||||
}
|
||||
|
|
|
@ -19,7 +19,7 @@ import (
|
|||
"time"
|
||||
|
||||
"github.com/btcsuite/btcd/blockchain"
|
||||
"github.com/btcsuite/btcd/btcec"
|
||||
"github.com/btcsuite/btcd/btcec/v2"
|
||||
"github.com/btcsuite/btcd/chaincfg"
|
||||
"github.com/btcsuite/btcd/chaincfg/chainhash"
|
||||
"github.com/btcsuite/btcd/txscript"
|
||||
|
@ -198,7 +198,7 @@ type testGenerator struct {
|
|||
// makeTestGenerator returns a test generator instance initialized with the
|
||||
// genesis block as the tip.
|
||||
func makeTestGenerator(params *chaincfg.Params) (testGenerator, error) {
|
||||
privKey, _ := btcec.PrivKeyFromBytes(btcec.S256(), []byte{0x01})
|
||||
privKey, _ := btcec.PrivKeyFromBytes([]byte{0x01})
|
||||
genesis := params.GenesisBlock
|
||||
genesisHash := genesis.BlockHash()
|
||||
return testGenerator{
|
||||
|
|
|
@ -3,7 +3,7 @@ module github.com/btcsuite/btcd/btcec/v2
|
|||
go 1.17
|
||||
|
||||
require (
|
||||
github.com/btcsuite/btcd v0.22.0-beta
|
||||
github.com/btcsuite/btcd v0.22.0-beta.0.20220111032746-97732e52810c
|
||||
github.com/davecgh/go-spew v1.1.1
|
||||
github.com/decred/dcrd/dcrec/secp256k1/v4 v4.0.1
|
||||
)
|
||||
|
|
47
btcec/go.sum
47
btcec/go.sum
|
@ -1,10 +1,10 @@
|
|||
github.com/aead/siphash v1.0.1/go.mod h1:Nywa3cDsYNNK3gaciGTWPwHt0wlpNV15vwmswBAUSII=
|
||||
github.com/btcsuite/btcd v0.20.1-beta/go.mod h1:wVuoA8VJLEcwgqHBwHmzLRazpKxTv13Px/pDuV7OomQ=
|
||||
github.com/btcsuite/btcd v0.22.0-beta h1:LTDpDKUM5EeOFBPM8IXpinEcmZ6FWfNZbE3lfrfdnWo=
|
||||
github.com/btcsuite/btcd v0.22.0-beta/go.mod h1:9n5ntfhhHQBIhUvlhDvD3Qg6fRUj4jkN0VB8L8svzOA=
|
||||
github.com/btcsuite/btcd v0.22.0-beta.0.20220111032746-97732e52810c h1:lnAMg3ra/Gw4AkRMxrxYs8nrprWsHowg8H9zaYsJOo4=
|
||||
github.com/btcsuite/btcd v0.22.0-beta.0.20220111032746-97732e52810c/go.mod h1:tjmYdS6MLJ5/s0Fj4DbLgSbDHbEqLJrtnHecBFkdz5M=
|
||||
github.com/btcsuite/btcd/btcutil v1.0.0/go.mod h1:Uoxwv0pqYWhD//tfTiipkxNfdhG9UrLwaeswfjfdF0A=
|
||||
github.com/btcsuite/btclog v0.0.0-20170628155309-84c8d2346e9f/go.mod h1:TdznJufoqS23FtqVCzL0ZqgP5MqXbb4fg/WgDys70nA=
|
||||
github.com/btcsuite/btcutil v0.0.0-20190425235716-9e5f4b9a998d/go.mod h1:+5NJ2+qvTyV9exUAL/rxXi3DcLg2Ts+ymUAY5y4NvMg=
|
||||
github.com/btcsuite/btcutil v1.0.3-0.20201208143702-a53e38424cce/go.mod h1:0DVlHczLPewLcPGEIeUEzfOJhqGPQ0mJJRDBtD307+o=
|
||||
github.com/btcsuite/go-socks v0.0.0-20170105172521-4720035b7bfd/go.mod h1:HHNXQzUsZCxOoE+CPiyCTO6x34Zs86zZUiwtpXoGdtg=
|
||||
github.com/btcsuite/goleveldb v0.0.0-20160330041536-7834afc9e8cd/go.mod h1:F+uVaaLLH7j4eDXPRvw78tMflu7Ie2bzYOH4Y8rRKBY=
|
||||
github.com/btcsuite/goleveldb v1.0.0/go.mod h1:QiK9vBlgftBg6rWQIj6wFzbPfRjiykIEhBH4obrXJ/I=
|
||||
|
@ -13,37 +13,72 @@ github.com/btcsuite/snappy-go v1.0.0/go.mod h1:8woku9dyThutzjeg+3xrA5iCpBRH8XEEg
|
|||
github.com/btcsuite/websocket v0.0.0-20150119174127-31079b680792/go.mod h1:ghJtEyQwv5/p4Mg4C0fgbePVuGr935/5ddU9Z3TmDRY=
|
||||
github.com/btcsuite/winsvc v1.0.0/go.mod h1:jsenWakMcC0zFBFurPLEAyrnc/teJEM1O46fmI40EZs=
|
||||
github.com/davecgh/go-spew v0.0.0-20171005155431-ecdeabc65495/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
|
||||
github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
|
||||
github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c=
|
||||
github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
|
||||
github.com/decred/dcrd/crypto/blake256 v1.0.0 h1:/8DMNYp9SGi5f0w7uCm6d6M4OU2rGFK09Y2A4Xv7EE0=
|
||||
github.com/decred/dcrd/crypto/blake256 v1.0.0/go.mod h1:sQl2p6Y26YV+ZOcSTP6thNdn47hh8kt6rqSlvmrXFAc=
|
||||
github.com/decred/dcrd/dcrec/secp256k1/v4 v4.0.1 h1:YLtO71vCjJRCBcrPMtQ9nqBsqpA1m5sE92cU+pd5Mcc=
|
||||
github.com/decred/dcrd/dcrec/secp256k1/v4 v4.0.1/go.mod h1:hyedUtir6IdtD/7lIxGeCxkaw7y45JueMRL4DIyJDKs=
|
||||
github.com/decred/dcrd/lru v1.0.0/go.mod h1:mxKOwFd7lFjN2GZYsiz/ecgqR6kkYAl+0pz0tEMk218=
|
||||
github.com/fsnotify/fsnotify v1.4.7/go.mod h1:jwhsz4b93w/PPRr/qN1Yymfu8t87LnFCMoQvtojpjFo=
|
||||
github.com/fsnotify/fsnotify v1.4.9/go.mod h1:znqG4EE+3YCdAaPaxE2ZRY/06pZUdp0tY4IgpuI1SZQ=
|
||||
github.com/golang/protobuf v1.2.0/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U=
|
||||
github.com/golang/protobuf v1.4.0-rc.1/go.mod h1:ceaxUfeHdC40wWswd/P6IGgMaK3YpKi5j83Wpe3EHw8=
|
||||
github.com/golang/protobuf v1.4.0-rc.1.0.20200221234624-67d41d38c208/go.mod h1:xKAWHe0F5eneWXFV3EuXVDTCmh+JuBKY0li0aMyXATA=
|
||||
github.com/golang/protobuf v1.4.0-rc.2/go.mod h1:LlEzMj4AhA7rCAGe4KMBDvJI+AwstrUpVNzEA03Pprs=
|
||||
github.com/golang/protobuf v1.4.0-rc.4.0.20200313231945-b860323f09d0/go.mod h1:WU3c8KckQ9AFe+yFwt9sWVRKCVIyN9cPHBJSNnbL67w=
|
||||
github.com/golang/protobuf v1.4.0/go.mod h1:jodUvKwWbYaEsadDk5Fwe5c77LiNKVO9IDvqG2KuDX0=
|
||||
github.com/golang/protobuf v1.4.2/go.mod h1:oDoupMAO8OvCJWAcko0GGGIgR6R6ocIYbsSw735rRwI=
|
||||
github.com/google/go-cmp v0.3.0/go.mod h1:8QqcDgzrUqlUb/G2PQTWiueGozuR1884gddMywk6iLU=
|
||||
github.com/google/go-cmp v0.3.1/go.mod h1:8QqcDgzrUqlUb/G2PQTWiueGozuR1884gddMywk6iLU=
|
||||
github.com/google/go-cmp v0.4.0/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE=
|
||||
github.com/hpcloud/tail v1.0.0/go.mod h1:ab1qPbhIpdTxEkNHXyeSf5vhxWSCs/tWer42PpOxQnU=
|
||||
github.com/jessevdk/go-flags v0.0.0-20141203071132-1679536dcc89/go.mod h1:4FA24M0QyGHXBuZZK/XkWh8h0e1EYbRYJSGM75WSRxI=
|
||||
github.com/jessevdk/go-flags v1.4.0/go.mod h1:4FA24M0QyGHXBuZZK/XkWh8h0e1EYbRYJSGM75WSRxI=
|
||||
github.com/jrick/logrotate v1.0.0/go.mod h1:LNinyqDIJnpAur+b8yyulnQw/wDuN1+BYKlTRt3OuAQ=
|
||||
github.com/kkdai/bstream v0.0.0-20161212061736-f391b8402d23/go.mod h1:J+Gs4SYgM6CZQHDETBtE9HaSEkGmuNXF86RwHhHUvq4=
|
||||
github.com/nxadm/tail v1.4.4/go.mod h1:kenIhsEOeOJmVchQTgglprH7qJGnHDVpk1VPCcaMI8A=
|
||||
github.com/onsi/ginkgo v1.6.0/go.mod h1:lLunBs/Ym6LB5Z9jYTR76FiuTmxDTDusOGeTQH+WWjE=
|
||||
github.com/onsi/ginkgo v1.7.0/go.mod h1:lLunBs/Ym6LB5Z9jYTR76FiuTmxDTDusOGeTQH+WWjE=
|
||||
github.com/onsi/ginkgo v1.12.1/go.mod h1:zj2OWP4+oCPe1qIXoGWkgMRwljMUYCdkwsT2108oapk=
|
||||
github.com/onsi/ginkgo v1.14.0/go.mod h1:iSB4RoI2tjJc9BBv4NKIKWKya62Rps+oPG/Lv9klQyY=
|
||||
github.com/onsi/gomega v1.4.1/go.mod h1:C1qb7wdrVGGVU+Z6iS04AVkA3Q65CEZX59MT0QO5uiA=
|
||||
github.com/onsi/gomega v1.4.3/go.mod h1:ex+gbHU/CVuBBDIJjb2X0qEXbFg53c61hWP/1CpauHY=
|
||||
github.com/onsi/gomega v1.7.1/go.mod h1:XdKZgCCFLUoM/7CFJVPcG8C1xQ1AJ0vpAezJrB7JYyY=
|
||||
github.com/onsi/gomega v1.10.1/go.mod h1:iN09h71vgCQne3DLsj+A5owkum+a2tYe+TOCB1ybHNo=
|
||||
golang.org/x/crypto v0.0.0-20170930174604-9419663f5a44/go.mod h1:6SG95UA2DQfeDnfUPMdvaQW0Q7yPrPDi9nlGo2tz2b4=
|
||||
golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w=
|
||||
golang.org/x/crypto v0.0.0-20200115085410-6d4e4cb37c7d/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto=
|
||||
golang.org/x/crypto v0.0.0-20200510223506-06a226fb4e37/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto=
|
||||
golang.org/x/crypto v0.0.0-20200622213623-75b288015ac9/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto=
|
||||
golang.org/x/net v0.0.0-20180719180050-a680a1efc54d/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4=
|
||||
golang.org/x/net v0.0.0-20180906233101-161cd47e91fd/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4=
|
||||
golang.org/x/net v0.0.0-20190404232315-eb5bcb51f2a3/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg=
|
||||
golang.org/x/net v0.0.0-20200520004742-59133d7f0dd7/go.mod h1:qpuaurCH72eLCgpAm/N6yyVIVM9cpaDIP3A8BGJEC5A=
|
||||
golang.org/x/net v0.0.0-20200813134508-3edf25e44fcc/go.mod h1:/O7V0waA8r7cgGh81Ro3o1hOxt32SMVPicZroKQ2sZA=
|
||||
golang.org/x/sync v0.0.0-20180314180146-1d60e4601c6f/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
|
||||
golang.org/x/sys v0.0.0-20180909124046-d0be0721c37e/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
|
||||
golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
|
||||
golang.org/x/sys v0.0.0-20190412213103-97732733099d/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
||||
golang.org/x/sys v0.0.0-20190904154756-749cb33beabd/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
||||
golang.org/x/sys v0.0.0-20191005200804-aed5e4c7ecf9/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
||||
golang.org/x/sys v0.0.0-20191120155948-bd437916bb0e/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
||||
golang.org/x/sys v0.0.0-20200323222414-85ca7c5b95cd/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
||||
golang.org/x/sys v0.0.0-20200519105757-fe76b779f299/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
||||
golang.org/x/sys v0.0.0-20200814200057-3d37ad5750ed/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
||||
golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ=
|
||||
golang.org/x/text v0.3.2/go.mod h1:bEr9sfX3Q8Zfm5fL9x+3itogRgK3+ptLWKqgva+5dAk=
|
||||
golang.org/x/text v0.3.3/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ=
|
||||
golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ=
|
||||
golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
|
||||
golang.org/x/xerrors v0.0.0-20200804184101-5ec99f83aff1/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
|
||||
google.golang.org/protobuf v0.0.0-20200109180630-ec00e32a8dfd/go.mod h1:DFci5gLYBciE7Vtevhsrf46CRTquxDuWsQurQQe4oz8=
|
||||
google.golang.org/protobuf v0.0.0-20200221191635-4d8936d0db64/go.mod h1:kwYJMbMJ01Woi6D6+Kah6886xMZcty6N08ah7+eCXa0=
|
||||
google.golang.org/protobuf v0.0.0-20200228230310-ab0ca4ff8a60/go.mod h1:cfTl7dwQJ+fmap5saPgwCLgHXTUD7jkjRqWcaiX5VyM=
|
||||
google.golang.org/protobuf v1.20.1-0.20200309200217-e05f789c0967/go.mod h1:A+miEFZTKqfCUM6K7xSMQL9OKL/b6hQv+e19PK+JZNE=
|
||||
google.golang.org/protobuf v1.21.0/go.mod h1:47Nbq4nVaFHyn7ilMalzfO3qCViNmqZ2kzikPIcrTAo=
|
||||
google.golang.org/protobuf v1.23.0/go.mod h1:EGpADcykh3NcUnDUJcl1+ZksZNG86OlYog2l/sGQquU=
|
||||
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
|
||||
gopkg.in/fsnotify.v1 v1.4.7/go.mod h1:Tz8NjZHkW78fSQdbUxIjBTcgA1z1m8ZHf0WmKUhAMys=
|
||||
gopkg.in/tomb.v1 v1.0.0-20141024135613-dd632973f1e7/go.mod h1:dt/ZhP58zS4L8KSrWDmTeBkI65Dw0HsyUHuEVlX15mw=
|
||||
gopkg.in/yaml.v2 v2.2.1/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI=
|
||||
gopkg.in/yaml.v2 v2.2.4/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI=
|
||||
gopkg.in/yaml.v2 v2.3.0/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI=
|
||||
|
|
|
@ -11,10 +11,10 @@ import (
|
|||
"fmt"
|
||||
"strings"
|
||||
|
||||
"github.com/btcsuite/btcd/btcec"
|
||||
"github.com/btcsuite/btcd/chaincfg"
|
||||
"github.com/btcsuite/btcd/btcec/v2"
|
||||
"github.com/btcsuite/btcd/btcutil/base58"
|
||||
"github.com/btcsuite/btcd/btcutil/bech32"
|
||||
"github.com/btcsuite/btcd/chaincfg"
|
||||
"golang.org/x/crypto/ripemd160"
|
||||
)
|
||||
|
||||
|
@ -417,10 +417,6 @@ const (
|
|||
// PKFCompressed indicates the pay-to-pubkey address format is a
|
||||
// compressed public key.
|
||||
PKFCompressed
|
||||
|
||||
// PKFHybrid indicates the pay-to-pubkey address format is a hybrid
|
||||
// public key.
|
||||
PKFHybrid
|
||||
)
|
||||
|
||||
// AddressPubKey is an Address for a pay-to-pubkey transaction.
|
||||
|
@ -434,7 +430,7 @@ type AddressPubKey struct {
|
|||
// address. The serializedPubKey parameter must be a valid pubkey and can be
|
||||
// uncompressed, compressed, or hybrid.
|
||||
func NewAddressPubKey(serializedPubKey []byte, net *chaincfg.Params) (*AddressPubKey, error) {
|
||||
pubKey, err := btcec.ParsePubKey(serializedPubKey, btcec.S256())
|
||||
pubKey, err := btcec.ParsePubKey(serializedPubKey)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
@ -447,8 +443,6 @@ func NewAddressPubKey(serializedPubKey []byte, net *chaincfg.Params) (*AddressPu
|
|||
switch serializedPubKey[0] {
|
||||
case 0x02, 0x03:
|
||||
pkFormat = PKFCompressed
|
||||
case 0x06, 0x07:
|
||||
pkFormat = PKFHybrid
|
||||
}
|
||||
|
||||
return &AddressPubKey{
|
||||
|
@ -469,9 +463,6 @@ func (a *AddressPubKey) serialize() []byte {
|
|||
|
||||
case PKFCompressed:
|
||||
return a.pubKey.SerializeCompressed()
|
||||
|
||||
case PKFHybrid:
|
||||
return a.pubKey.SerializeHybrid()
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -12,9 +12,9 @@ import (
|
|||
"strings"
|
||||
"testing"
|
||||
|
||||
"github.com/btcsuite/btcd/btcutil"
|
||||
"github.com/btcsuite/btcd/chaincfg"
|
||||
"github.com/btcsuite/btcd/wire"
|
||||
"github.com/btcsuite/btcd/btcutil"
|
||||
"golang.org/x/crypto/ripemd160"
|
||||
)
|
||||
|
||||
|
@ -338,64 +338,6 @@ func TestAddresses(t *testing.T) {
|
|||
},
|
||||
net: &chaincfg.MainNetParams,
|
||||
},
|
||||
{
|
||||
name: "mainnet p2pk hybrid (0x06)",
|
||||
addr: "06192d74d0cb94344c9569c2e77901573d8d7903c3ebec3a957724895dca52c6b4" +
|
||||
"0d45264838c0bd96852662ce6a847b197376830160c6d2eb5e6a4c44d33f453e",
|
||||
encoded: "1Ja5rs7XBZnK88EuLVcFqYGMEbBitzchmX",
|
||||
valid: true,
|
||||
result: btcutil.TstAddressPubKey(
|
||||
[]byte{
|
||||
0x06, 0x19, 0x2d, 0x74, 0xd0, 0xcb, 0x94, 0x34, 0x4c, 0x95,
|
||||
0x69, 0xc2, 0xe7, 0x79, 0x01, 0x57, 0x3d, 0x8d, 0x79, 0x03,
|
||||
0xc3, 0xeb, 0xec, 0x3a, 0x95, 0x77, 0x24, 0x89, 0x5d, 0xca,
|
||||
0x52, 0xc6, 0xb4, 0x0d, 0x45, 0x26, 0x48, 0x38, 0xc0, 0xbd,
|
||||
0x96, 0x85, 0x26, 0x62, 0xce, 0x6a, 0x84, 0x7b, 0x19, 0x73,
|
||||
0x76, 0x83, 0x01, 0x60, 0xc6, 0xd2, 0xeb, 0x5e, 0x6a, 0x4c,
|
||||
0x44, 0xd3, 0x3f, 0x45, 0x3e},
|
||||
btcutil.PKFHybrid, chaincfg.MainNetParams.PubKeyHashAddrID),
|
||||
f: func() (btcutil.Address, error) {
|
||||
serializedPubKey := []byte{
|
||||
0x06, 0x19, 0x2d, 0x74, 0xd0, 0xcb, 0x94, 0x34, 0x4c, 0x95,
|
||||
0x69, 0xc2, 0xe7, 0x79, 0x01, 0x57, 0x3d, 0x8d, 0x79, 0x03,
|
||||
0xc3, 0xeb, 0xec, 0x3a, 0x95, 0x77, 0x24, 0x89, 0x5d, 0xca,
|
||||
0x52, 0xc6, 0xb4, 0x0d, 0x45, 0x26, 0x48, 0x38, 0xc0, 0xbd,
|
||||
0x96, 0x85, 0x26, 0x62, 0xce, 0x6a, 0x84, 0x7b, 0x19, 0x73,
|
||||
0x76, 0x83, 0x01, 0x60, 0xc6, 0xd2, 0xeb, 0x5e, 0x6a, 0x4c,
|
||||
0x44, 0xd3, 0x3f, 0x45, 0x3e}
|
||||
return btcutil.NewAddressPubKey(serializedPubKey, &chaincfg.MainNetParams)
|
||||
},
|
||||
net: &chaincfg.MainNetParams,
|
||||
},
|
||||
{
|
||||
name: "mainnet p2pk hybrid (0x07)",
|
||||
addr: "07b0bd634234abbb1ba1e986e884185c61cf43e001f9137f23c2c409273eb16e65" +
|
||||
"37a576782eba668a7ef8bd3b3cfb1edb7117ab65129b8a2e681f3c1e0908ef7b",
|
||||
encoded: "1ExqMmf6yMxcBMzHjbj41wbqYuqoX6uBLG",
|
||||
valid: true,
|
||||
result: btcutil.TstAddressPubKey(
|
||||
[]byte{
|
||||
0x07, 0xb0, 0xbd, 0x63, 0x42, 0x34, 0xab, 0xbb, 0x1b, 0xa1,
|
||||
0xe9, 0x86, 0xe8, 0x84, 0x18, 0x5c, 0x61, 0xcf, 0x43, 0xe0,
|
||||
0x01, 0xf9, 0x13, 0x7f, 0x23, 0xc2, 0xc4, 0x09, 0x27, 0x3e,
|
||||
0xb1, 0x6e, 0x65, 0x37, 0xa5, 0x76, 0x78, 0x2e, 0xba, 0x66,
|
||||
0x8a, 0x7e, 0xf8, 0xbd, 0x3b, 0x3c, 0xfb, 0x1e, 0xdb, 0x71,
|
||||
0x17, 0xab, 0x65, 0x12, 0x9b, 0x8a, 0x2e, 0x68, 0x1f, 0x3c,
|
||||
0x1e, 0x09, 0x08, 0xef, 0x7b},
|
||||
btcutil.PKFHybrid, chaincfg.MainNetParams.PubKeyHashAddrID),
|
||||
f: func() (btcutil.Address, error) {
|
||||
serializedPubKey := []byte{
|
||||
0x07, 0xb0, 0xbd, 0x63, 0x42, 0x34, 0xab, 0xbb, 0x1b, 0xa1,
|
||||
0xe9, 0x86, 0xe8, 0x84, 0x18, 0x5c, 0x61, 0xcf, 0x43, 0xe0,
|
||||
0x01, 0xf9, 0x13, 0x7f, 0x23, 0xc2, 0xc4, 0x09, 0x27, 0x3e,
|
||||
0xb1, 0x6e, 0x65, 0x37, 0xa5, 0x76, 0x78, 0x2e, 0xba, 0x66,
|
||||
0x8a, 0x7e, 0xf8, 0xbd, 0x3b, 0x3c, 0xfb, 0x1e, 0xdb, 0x71,
|
||||
0x17, 0xab, 0x65, 0x12, 0x9b, 0x8a, 0x2e, 0x68, 0x1f, 0x3c,
|
||||
0x1e, 0x09, 0x08, 0xef, 0x7b}
|
||||
return btcutil.NewAddressPubKey(serializedPubKey, &chaincfg.MainNetParams)
|
||||
},
|
||||
net: &chaincfg.MainNetParams,
|
||||
},
|
||||
{
|
||||
name: "testnet p2pk compressed (0x02)",
|
||||
addr: "02192d74d0cb94344c9569c2e77901573d8d7903c3ebec3a957724895dca52c6b4",
|
||||
|
@ -469,64 +411,6 @@ func TestAddresses(t *testing.T) {
|
|||
},
|
||||
net: &chaincfg.TestNet3Params,
|
||||
},
|
||||
{
|
||||
name: "testnet p2pk hybrid (0x06)",
|
||||
addr: "06192d74d0cb94344c9569c2e77901573d8d7903c3ebec3a957724895dca52c6b" +
|
||||
"40d45264838c0bd96852662ce6a847b197376830160c6d2eb5e6a4c44d33f453e",
|
||||
encoded: "my639vCVzbDZuEiX44adfTUg6anRomZLEP",
|
||||
valid: true,
|
||||
result: btcutil.TstAddressPubKey(
|
||||
[]byte{
|
||||
0x06, 0x19, 0x2d, 0x74, 0xd0, 0xcb, 0x94, 0x34, 0x4c, 0x95,
|
||||
0x69, 0xc2, 0xe7, 0x79, 0x01, 0x57, 0x3d, 0x8d, 0x79, 0x03,
|
||||
0xc3, 0xeb, 0xec, 0x3a, 0x95, 0x77, 0x24, 0x89, 0x5d, 0xca,
|
||||
0x52, 0xc6, 0xb4, 0x0d, 0x45, 0x26, 0x48, 0x38, 0xc0, 0xbd,
|
||||
0x96, 0x85, 0x26, 0x62, 0xce, 0x6a, 0x84, 0x7b, 0x19, 0x73,
|
||||
0x76, 0x83, 0x01, 0x60, 0xc6, 0xd2, 0xeb, 0x5e, 0x6a, 0x4c,
|
||||
0x44, 0xd3, 0x3f, 0x45, 0x3e},
|
||||
btcutil.PKFHybrid, chaincfg.TestNet3Params.PubKeyHashAddrID),
|
||||
f: func() (btcutil.Address, error) {
|
||||
serializedPubKey := []byte{
|
||||
0x06, 0x19, 0x2d, 0x74, 0xd0, 0xcb, 0x94, 0x34, 0x4c, 0x95,
|
||||
0x69, 0xc2, 0xe7, 0x79, 0x01, 0x57, 0x3d, 0x8d, 0x79, 0x03,
|
||||
0xc3, 0xeb, 0xec, 0x3a, 0x95, 0x77, 0x24, 0x89, 0x5d, 0xca,
|
||||
0x52, 0xc6, 0xb4, 0x0d, 0x45, 0x26, 0x48, 0x38, 0xc0, 0xbd,
|
||||
0x96, 0x85, 0x26, 0x62, 0xce, 0x6a, 0x84, 0x7b, 0x19, 0x73,
|
||||
0x76, 0x83, 0x01, 0x60, 0xc6, 0xd2, 0xeb, 0x5e, 0x6a, 0x4c,
|
||||
0x44, 0xd3, 0x3f, 0x45, 0x3e}
|
||||
return btcutil.NewAddressPubKey(serializedPubKey, &chaincfg.TestNet3Params)
|
||||
},
|
||||
net: &chaincfg.TestNet3Params,
|
||||
},
|
||||
{
|
||||
name: "testnet p2pk hybrid (0x07)",
|
||||
addr: "07b0bd634234abbb1ba1e986e884185c61cf43e001f9137f23c2c409273eb16e6" +
|
||||
"537a576782eba668a7ef8bd3b3cfb1edb7117ab65129b8a2e681f3c1e0908ef7b",
|
||||
encoded: "muUnepk5nPPrxUTuTAhRqrpAQuSWS5fVii",
|
||||
valid: true,
|
||||
result: btcutil.TstAddressPubKey(
|
||||
[]byte{
|
||||
0x07, 0xb0, 0xbd, 0x63, 0x42, 0x34, 0xab, 0xbb, 0x1b, 0xa1,
|
||||
0xe9, 0x86, 0xe8, 0x84, 0x18, 0x5c, 0x61, 0xcf, 0x43, 0xe0,
|
||||
0x01, 0xf9, 0x13, 0x7f, 0x23, 0xc2, 0xc4, 0x09, 0x27, 0x3e,
|
||||
0xb1, 0x6e, 0x65, 0x37, 0xa5, 0x76, 0x78, 0x2e, 0xba, 0x66,
|
||||
0x8a, 0x7e, 0xf8, 0xbd, 0x3b, 0x3c, 0xfb, 0x1e, 0xdb, 0x71,
|
||||
0x17, 0xab, 0x65, 0x12, 0x9b, 0x8a, 0x2e, 0x68, 0x1f, 0x3c,
|
||||
0x1e, 0x09, 0x08, 0xef, 0x7b},
|
||||
btcutil.PKFHybrid, chaincfg.TestNet3Params.PubKeyHashAddrID),
|
||||
f: func() (btcutil.Address, error) {
|
||||
serializedPubKey := []byte{
|
||||
0x07, 0xb0, 0xbd, 0x63, 0x42, 0x34, 0xab, 0xbb, 0x1b, 0xa1,
|
||||
0xe9, 0x86, 0xe8, 0x84, 0x18, 0x5c, 0x61, 0xcf, 0x43, 0xe0,
|
||||
0x01, 0xf9, 0x13, 0x7f, 0x23, 0xc2, 0xc4, 0x09, 0x27, 0x3e,
|
||||
0xb1, 0x6e, 0x65, 0x37, 0xa5, 0x76, 0x78, 0x2e, 0xba, 0x66,
|
||||
0x8a, 0x7e, 0xf8, 0xbd, 0x3b, 0x3c, 0xfb, 0x1e, 0xdb, 0x71,
|
||||
0x17, 0xab, 0x65, 0x12, 0x9b, 0x8a, 0x2e, 0x68, 0x1f, 0x3c,
|
||||
0x1e, 0x09, 0x08, 0xef, 0x7b}
|
||||
return btcutil.NewAddressPubKey(serializedPubKey, &chaincfg.TestNet3Params)
|
||||
},
|
||||
net: &chaincfg.TestNet3Params,
|
||||
},
|
||||
// Segwit address tests.
|
||||
{
|
||||
name: "segwit mainnet p2wpkh v0",
|
||||
|
|
|
@ -5,9 +5,13 @@ go 1.16
|
|||
require (
|
||||
github.com/aead/siphash v1.0.1
|
||||
github.com/btcsuite/btcd v0.22.0-beta.0.20220111032746-97732e52810c
|
||||
github.com/btcsuite/btcd/btcec/v2 v2.0.0
|
||||
github.com/davecgh/go-spew v1.1.1
|
||||
github.com/decred/dcrd/dcrec/secp256k1/v4 v4.0.1
|
||||
github.com/kkdai/bstream v0.0.0-20161212061736-f391b8402d23
|
||||
golang.org/x/crypto v0.0.0-20200622213623-75b288015ac9
|
||||
)
|
||||
|
||||
replace github.com/btcsuite/btcd/btcec/v2 => ../btcec
|
||||
|
||||
replace github.com/btcsuite/btcd => ../
|
||||
|
|
|
@ -12,64 +12,24 @@ github.com/btcsuite/websocket v0.0.0-20150119174127-31079b680792/go.mod h1:ghJtE
|
|||
github.com/btcsuite/winsvc v1.0.0/go.mod h1:jsenWakMcC0zFBFurPLEAyrnc/teJEM1O46fmI40EZs=
|
||||
github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c=
|
||||
github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
|
||||
github.com/decred/dcrd/crypto/blake256 v1.0.0 h1:/8DMNYp9SGi5f0w7uCm6d6M4OU2rGFK09Y2A4Xv7EE0=
|
||||
github.com/decred/dcrd/crypto/blake256 v1.0.0/go.mod h1:sQl2p6Y26YV+ZOcSTP6thNdn47hh8kt6rqSlvmrXFAc=
|
||||
github.com/decred/dcrd/dcrec/secp256k1/v4 v4.0.1 h1:YLtO71vCjJRCBcrPMtQ9nqBsqpA1m5sE92cU+pd5Mcc=
|
||||
github.com/decred/dcrd/dcrec/secp256k1/v4 v4.0.1/go.mod h1:hyedUtir6IdtD/7lIxGeCxkaw7y45JueMRL4DIyJDKs=
|
||||
github.com/decred/dcrd/lru v1.0.0/go.mod h1:mxKOwFd7lFjN2GZYsiz/ecgqR6kkYAl+0pz0tEMk218=
|
||||
github.com/fsnotify/fsnotify v1.4.7/go.mod h1:jwhsz4b93w/PPRr/qN1Yymfu8t87LnFCMoQvtojpjFo=
|
||||
github.com/fsnotify/fsnotify v1.4.9/go.mod h1:znqG4EE+3YCdAaPaxE2ZRY/06pZUdp0tY4IgpuI1SZQ=
|
||||
github.com/golang/protobuf v1.2.0/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U=
|
||||
github.com/golang/protobuf v1.4.0-rc.1/go.mod h1:ceaxUfeHdC40wWswd/P6IGgMaK3YpKi5j83Wpe3EHw8=
|
||||
github.com/golang/protobuf v1.4.0-rc.1.0.20200221234624-67d41d38c208/go.mod h1:xKAWHe0F5eneWXFV3EuXVDTCmh+JuBKY0li0aMyXATA=
|
||||
github.com/golang/protobuf v1.4.0-rc.2/go.mod h1:LlEzMj4AhA7rCAGe4KMBDvJI+AwstrUpVNzEA03Pprs=
|
||||
github.com/golang/protobuf v1.4.0-rc.4.0.20200313231945-b860323f09d0/go.mod h1:WU3c8KckQ9AFe+yFwt9sWVRKCVIyN9cPHBJSNnbL67w=
|
||||
github.com/golang/protobuf v1.4.0/go.mod h1:jodUvKwWbYaEsadDk5Fwe5c77LiNKVO9IDvqG2KuDX0=
|
||||
github.com/golang/protobuf v1.4.2/go.mod h1:oDoupMAO8OvCJWAcko0GGGIgR6R6ocIYbsSw735rRwI=
|
||||
github.com/google/go-cmp v0.3.0/go.mod h1:8QqcDgzrUqlUb/G2PQTWiueGozuR1884gddMywk6iLU=
|
||||
github.com/google/go-cmp v0.3.1/go.mod h1:8QqcDgzrUqlUb/G2PQTWiueGozuR1884gddMywk6iLU=
|
||||
github.com/google/go-cmp v0.4.0/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE=
|
||||
github.com/hpcloud/tail v1.0.0/go.mod h1:ab1qPbhIpdTxEkNHXyeSf5vhxWSCs/tWer42PpOxQnU=
|
||||
github.com/jessevdk/go-flags v1.4.0/go.mod h1:4FA24M0QyGHXBuZZK/XkWh8h0e1EYbRYJSGM75WSRxI=
|
||||
github.com/jrick/logrotate v1.0.0/go.mod h1:LNinyqDIJnpAur+b8yyulnQw/wDuN1+BYKlTRt3OuAQ=
|
||||
github.com/kkdai/bstream v0.0.0-20161212061736-f391b8402d23 h1:FOOIBWrEkLgmlgGfMuZT83xIwfPDxEI2OHu6xUmJMFE=
|
||||
github.com/kkdai/bstream v0.0.0-20161212061736-f391b8402d23/go.mod h1:J+Gs4SYgM6CZQHDETBtE9HaSEkGmuNXF86RwHhHUvq4=
|
||||
github.com/nxadm/tail v1.4.4/go.mod h1:kenIhsEOeOJmVchQTgglprH7qJGnHDVpk1VPCcaMI8A=
|
||||
github.com/onsi/ginkgo v1.6.0/go.mod h1:lLunBs/Ym6LB5Z9jYTR76FiuTmxDTDusOGeTQH+WWjE=
|
||||
github.com/onsi/ginkgo v1.12.1/go.mod h1:zj2OWP4+oCPe1qIXoGWkgMRwljMUYCdkwsT2108oapk=
|
||||
github.com/onsi/ginkgo v1.14.0/go.mod h1:iSB4RoI2tjJc9BBv4NKIKWKya62Rps+oPG/Lv9klQyY=
|
||||
github.com/onsi/gomega v1.4.1/go.mod h1:C1qb7wdrVGGVU+Z6iS04AVkA3Q65CEZX59MT0QO5uiA=
|
||||
github.com/onsi/gomega v1.7.1/go.mod h1:XdKZgCCFLUoM/7CFJVPcG8C1xQ1AJ0vpAezJrB7JYyY=
|
||||
github.com/onsi/gomega v1.10.1/go.mod h1:iN09h71vgCQne3DLsj+A5owkum+a2tYe+TOCB1ybHNo=
|
||||
golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w=
|
||||
golang.org/x/crypto v0.0.0-20200622213623-75b288015ac9 h1:psW17arqaxU48Z5kZ0CQnkZWQJsqcURM6tKiBApRjXI=
|
||||
golang.org/x/crypto v0.0.0-20200622213623-75b288015ac9/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto=
|
||||
golang.org/x/net v0.0.0-20180719180050-a680a1efc54d/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4=
|
||||
golang.org/x/net v0.0.0-20180906233101-161cd47e91fd/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4=
|
||||
golang.org/x/net v0.0.0-20190404232315-eb5bcb51f2a3/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg=
|
||||
golang.org/x/net v0.0.0-20200520004742-59133d7f0dd7/go.mod h1:qpuaurCH72eLCgpAm/N6yyVIVM9cpaDIP3A8BGJEC5A=
|
||||
golang.org/x/net v0.0.0-20200813134508-3edf25e44fcc/go.mod h1:/O7V0waA8r7cgGh81Ro3o1hOxt32SMVPicZroKQ2sZA=
|
||||
golang.org/x/sync v0.0.0-20180314180146-1d60e4601c6f/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
|
||||
golang.org/x/sys v0.0.0-20180909124046-d0be0721c37e/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
|
||||
golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
|
||||
golang.org/x/sys v0.0.0-20190412213103-97732733099d/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
||||
golang.org/x/sys v0.0.0-20190904154756-749cb33beabd/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
||||
golang.org/x/sys v0.0.0-20191005200804-aed5e4c7ecf9/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
||||
golang.org/x/sys v0.0.0-20191120155948-bd437916bb0e/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
||||
golang.org/x/sys v0.0.0-20200323222414-85ca7c5b95cd/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
||||
golang.org/x/sys v0.0.0-20200519105757-fe76b779f299/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
||||
golang.org/x/sys v0.0.0-20200814200057-3d37ad5750ed/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
||||
golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ=
|
||||
golang.org/x/text v0.3.2/go.mod h1:bEr9sfX3Q8Zfm5fL9x+3itogRgK3+ptLWKqgva+5dAk=
|
||||
golang.org/x/text v0.3.3/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ=
|
||||
golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ=
|
||||
golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
|
||||
golang.org/x/xerrors v0.0.0-20200804184101-5ec99f83aff1/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
|
||||
google.golang.org/protobuf v0.0.0-20200109180630-ec00e32a8dfd/go.mod h1:DFci5gLYBciE7Vtevhsrf46CRTquxDuWsQurQQe4oz8=
|
||||
google.golang.org/protobuf v0.0.0-20200221191635-4d8936d0db64/go.mod h1:kwYJMbMJ01Woi6D6+Kah6886xMZcty6N08ah7+eCXa0=
|
||||
google.golang.org/protobuf v0.0.0-20200228230310-ab0ca4ff8a60/go.mod h1:cfTl7dwQJ+fmap5saPgwCLgHXTUD7jkjRqWcaiX5VyM=
|
||||
google.golang.org/protobuf v1.20.1-0.20200309200217-e05f789c0967/go.mod h1:A+miEFZTKqfCUM6K7xSMQL9OKL/b6hQv+e19PK+JZNE=
|
||||
google.golang.org/protobuf v1.21.0/go.mod h1:47Nbq4nVaFHyn7ilMalzfO3qCViNmqZ2kzikPIcrTAo=
|
||||
google.golang.org/protobuf v1.23.0/go.mod h1:EGpADcykh3NcUnDUJcl1+ZksZNG86OlYog2l/sGQquU=
|
||||
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
|
||||
gopkg.in/fsnotify.v1 v1.4.7/go.mod h1:Tz8NjZHkW78fSQdbUxIjBTcgA1z1m8ZHf0WmKUhAMys=
|
||||
gopkg.in/tomb.v1 v1.0.0-20141024135613-dd632973f1e7/go.mod h1:dt/ZhP58zS4L8KSrWDmTeBkI65Dw0HsyUHuEVlX15mw=
|
||||
gopkg.in/yaml.v2 v2.2.1/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI=
|
||||
gopkg.in/yaml.v2 v2.2.4/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI=
|
||||
gopkg.in/yaml.v2 v2.3.0/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI=
|
||||
|
|
|
@ -18,11 +18,11 @@ import (
|
|||
"fmt"
|
||||
"math/big"
|
||||
|
||||
"github.com/btcsuite/btcd/btcec"
|
||||
"github.com/btcsuite/btcd/chaincfg"
|
||||
"github.com/btcsuite/btcd/chaincfg/chainhash"
|
||||
"github.com/btcsuite/btcd/btcec/v2"
|
||||
"github.com/btcsuite/btcd/btcutil"
|
||||
"github.com/btcsuite/btcd/btcutil/base58"
|
||||
"github.com/btcsuite/btcd/chaincfg"
|
||||
"github.com/btcsuite/btcd/chaincfg/chainhash"
|
||||
)
|
||||
|
||||
const (
|
||||
|
@ -154,8 +154,7 @@ func (k *ExtendedKey) pubKeyBytes() []byte {
|
|||
// This is a private extended key, so calculate and memoize the public
|
||||
// key if needed.
|
||||
if len(k.pubKey) == 0 {
|
||||
pkx, pky := btcec.S256().ScalarBaseMult(k.key)
|
||||
pubKey := btcec.PublicKey{Curve: btcec.S256(), X: pkx, Y: pky}
|
||||
_, pubKey := btcec.PrivKeyFromBytes(k.key)
|
||||
k.pubKey = pubKey.SerializeCompressed()
|
||||
}
|
||||
|
||||
|
@ -292,8 +291,8 @@ func (k *ExtendedKey) Derive(i uint32) (*ExtendedKey, error) {
|
|||
// chance (< 1 in 2^127) this condition will not hold, and in that case,
|
||||
// a child extended key can't be created for this index and the caller
|
||||
// should simply increment to the next index.
|
||||
ilNum := new(big.Int).SetBytes(il)
|
||||
if ilNum.Cmp(btcec.S256().N) >= 0 || ilNum.Sign() == 0 {
|
||||
var ilNum btcec.ModNScalar
|
||||
if overflow := ilNum.SetByteSlice(il); overflow {
|
||||
return nil, ErrInvalidChild
|
||||
}
|
||||
|
||||
|
@ -313,35 +312,66 @@ func (k *ExtendedKey) Derive(i uint32) (*ExtendedKey, error) {
|
|||
// derive the final child key.
|
||||
//
|
||||
// childKey = parse256(Il) + parenKey
|
||||
keyNum := new(big.Int).SetBytes(k.key)
|
||||
ilNum.Add(ilNum, keyNum)
|
||||
ilNum.Mod(ilNum, btcec.S256().N)
|
||||
childKey = ilNum.Bytes()
|
||||
var keyNum btcec.ModNScalar
|
||||
if overflow := keyNum.SetByteSlice(k.key); overflow {
|
||||
return nil, ErrInvalidChild
|
||||
}
|
||||
|
||||
childKeyBytes := ilNum.Add(&keyNum).Bytes()
|
||||
childKey = childKeyBytes[:]
|
||||
|
||||
// Strip leading zeroes from childKey, to match the expectation
|
||||
// as the old big.Int usage in this area of the codebase.
|
||||
for len(childKey) > 0 && childKey[0] == 0x00 {
|
||||
childKey = childKey[1:]
|
||||
}
|
||||
|
||||
isPrivate = true
|
||||
} else {
|
||||
// Case #3.
|
||||
// Calculate the corresponding intermediate public key for
|
||||
// intermediate private key.
|
||||
ilx, ily := btcec.S256().ScalarBaseMult(il)
|
||||
if ilx.Sign() == 0 || ily.Sign() == 0 {
|
||||
// Calculate the corresponding intermediate public key for thek
|
||||
// intermediate private key: ilJ = ilScalar*G
|
||||
var (
|
||||
ilScalar btcec.ModNScalar
|
||||
ilJ btcec.JacobianPoint
|
||||
)
|
||||
if overflow := ilScalar.SetByteSlice(il); overflow {
|
||||
return nil, ErrInvalidChild
|
||||
}
|
||||
btcec.ScalarBaseMultNonConst(&ilScalar, &ilJ)
|
||||
|
||||
if (ilJ.X.IsZero() && ilJ.Y.IsZero()) || ilJ.Z.IsZero() {
|
||||
return nil, ErrInvalidChild
|
||||
}
|
||||
|
||||
// Convert the serialized compressed parent public key into X
|
||||
// and Y coordinates so it can be added to the intermediate
|
||||
// public key.
|
||||
pubKey, err := btcec.ParsePubKey(k.key, btcec.S256())
|
||||
pubKey, err := btcec.ParsePubKey(k.key)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
// Convert the public key to jacobian coordinates, as that's
|
||||
// what our main add/double methods use.
|
||||
var pubKeyJ btcec.JacobianPoint
|
||||
pubKey.AsJacobian(&pubKeyJ)
|
||||
|
||||
// Add the intermediate public key to the parent public key to
|
||||
// derive the final child key.
|
||||
//
|
||||
// childKey = serP(point(parse256(Il)) + parentKey)
|
||||
childX, childY := btcec.S256().Add(ilx, ily, pubKey.X, pubKey.Y)
|
||||
pk := btcec.PublicKey{Curve: btcec.S256(), X: childX, Y: childY}
|
||||
childKey = pk.SerializeCompressed()
|
||||
var childKeyPubJ btcec.JacobianPoint
|
||||
btcec.AddNonConst(&ilJ, &pubKeyJ, &childKeyPubJ)
|
||||
|
||||
// Convert the new child public key back to affine coordinates
|
||||
// so we can serialize it in compressed format.
|
||||
childKeyPubJ.ToAffine()
|
||||
childKeyPub := btcec.NewPublicKey(
|
||||
&childKeyPubJ.X, &childKeyPubJ.Y,
|
||||
)
|
||||
|
||||
childKey = childKeyPub.SerializeCompressed()
|
||||
}
|
||||
|
||||
// The fingerprint of the parent for the derived child is the first 4
|
||||
|
@ -400,19 +430,36 @@ func (k *ExtendedKey) DeriveNonStandard(i uint32) (*ExtendedKey, error) {
|
|||
childKey = ilNum.Bytes()
|
||||
isPrivate = true
|
||||
} else {
|
||||
ilx, ily := btcec.S256().ScalarBaseMult(il)
|
||||
if ilx.Sign() == 0 || ily.Sign() == 0 {
|
||||
var (
|
||||
ilScalar btcec.ModNScalar
|
||||
ilJ btcec.JacobianPoint
|
||||
)
|
||||
if overflow := ilScalar.SetByteSlice(il); overflow {
|
||||
return nil, ErrInvalidChild
|
||||
}
|
||||
btcec.ScalarBaseMultNonConst(&ilScalar, &ilJ)
|
||||
|
||||
if (ilJ.X.IsZero() && ilJ.Y.IsZero()) || ilJ.Z.IsZero() {
|
||||
return nil, ErrInvalidChild
|
||||
}
|
||||
|
||||
pubKey, err := btcec.ParsePubKey(k.key, btcec.S256())
|
||||
pubKey, err := btcec.ParsePubKey(k.key)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
childX, childY := btcec.S256().Add(ilx, ily, pubKey.X, pubKey.Y)
|
||||
pk := btcec.PublicKey{Curve: btcec.S256(), X: childX, Y: childY}
|
||||
childKey = pk.SerializeCompressed()
|
||||
var pubKeyJ btcec.JacobianPoint
|
||||
pubKey.AsJacobian(&pubKeyJ)
|
||||
|
||||
var childKeyPubJ btcec.JacobianPoint
|
||||
btcec.AddNonConst(&ilJ, &pubKeyJ, &childKeyPubJ)
|
||||
|
||||
childKeyPubJ.ToAffine()
|
||||
childKeyPub := btcec.NewPublicKey(
|
||||
&childKeyPubJ.X, &childKeyPubJ.Y,
|
||||
)
|
||||
|
||||
childKey = childKeyPub.SerializeCompressed()
|
||||
}
|
||||
|
||||
parentFP := btcutil.Hash160(k.pubKeyBytes())[:4]
|
||||
|
@ -488,7 +535,7 @@ func (k *ExtendedKey) CloneWithVersion(version []byte) (*ExtendedKey, error) {
|
|||
|
||||
// ECPubKey converts the extended key to a btcec public key and returns it.
|
||||
func (k *ExtendedKey) ECPubKey() (*btcec.PublicKey, error) {
|
||||
return btcec.ParsePubKey(k.pubKeyBytes(), btcec.S256())
|
||||
return btcec.ParsePubKey(k.pubKeyBytes())
|
||||
}
|
||||
|
||||
// ECPrivKey converts the extended key to a btcec private key and returns it.
|
||||
|
@ -500,7 +547,7 @@ func (k *ExtendedKey) ECPrivKey() (*btcec.PrivateKey, error) {
|
|||
return nil, ErrNotPrivExtKey
|
||||
}
|
||||
|
||||
privKey, _ := btcec.PrivKeyFromBytes(btcec.S256(), k.key)
|
||||
privKey, _ := btcec.PrivKeyFromBytes(k.key)
|
||||
return privKey, nil
|
||||
}
|
||||
|
||||
|
@ -674,7 +721,7 @@ func NewKeyFromString(key string) (*ExtendedKey, error) {
|
|||
} else {
|
||||
// Ensure the public key parses correctly and is actually on the
|
||||
// secp256k1 curve.
|
||||
_, err := btcec.ParsePubKey(keyData, btcec.S256())
|
||||
_, err := btcec.ParsePubKey(keyData)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
|
|
@ -18,6 +18,7 @@ import (
|
|||
"testing"
|
||||
|
||||
"github.com/btcsuite/btcd/chaincfg"
|
||||
secp_ecdsa "github.com/decred/dcrd/dcrec/secp256k1/v4"
|
||||
)
|
||||
|
||||
// TestBIP0032Vectors tests the vectors provided by [BIP32] to ensure the
|
||||
|
@ -878,7 +879,7 @@ func TestErrors(t *testing.T) {
|
|||
{
|
||||
name: "pubkey not on curve",
|
||||
key: "xpub661MyMwAqRbcFtXgS5sYJABqqG9YLmC4Q1Rdap9gSE8NqtwybGhePY2gZ1hr9Rwbk95YadvBkQXxzHBSngB8ndpW6QH7zhhsXZ2jHyZqPjk",
|
||||
err: errors.New("invalid square root"),
|
||||
err: secp_ecdsa.ErrPubKeyNotOnCurve,
|
||||
},
|
||||
{
|
||||
name: "unsupported version",
|
||||
|
@ -891,7 +892,7 @@ func TestErrors(t *testing.T) {
|
|||
|
||||
for i, test := range tests {
|
||||
extKey, err := NewKeyFromString(test.key)
|
||||
if !reflect.DeepEqual(err, test.err) {
|
||||
if !errors.Is(err, test.err) {
|
||||
t.Errorf("NewKeyFromString #%d (%s): mismatched error "+
|
||||
"-- got: %v, want: %v", i, test.name, err,
|
||||
test.err)
|
||||
|
@ -900,7 +901,7 @@ func TestErrors(t *testing.T) {
|
|||
|
||||
if test.neuter {
|
||||
_, err := extKey.Neuter()
|
||||
if !reflect.DeepEqual(err, test.neuterErr) {
|
||||
if !errors.Is(err, test.neuterErr) {
|
||||
t.Errorf("Neuter #%d (%s): mismatched error "+
|
||||
"-- got: %v, want: %v", i, test.name,
|
||||
err, test.neuterErr)
|
||||
|
@ -972,9 +973,9 @@ func TestZero(t *testing.T) {
|
|||
return false
|
||||
}
|
||||
|
||||
wantErr = errors.New("pubkey string is empty")
|
||||
wantErr = secp_ecdsa.ErrPubKeyInvalidLen
|
||||
_, err = key.ECPubKey()
|
||||
if !reflect.DeepEqual(err, wantErr) {
|
||||
if !errors.Is(err, wantErr) {
|
||||
t.Errorf("ECPubKey #%d (%s): mismatched error: want "+
|
||||
"%v, got %v", i, testName, wantErr, err)
|
||||
return false
|
||||
|
|
|
@ -12,7 +12,7 @@ interface. The functions are only exported while the tests are being run.
|
|||
package btcutil
|
||||
|
||||
import (
|
||||
"github.com/btcsuite/btcd/btcec"
|
||||
"github.com/btcsuite/btcd/btcec/v2"
|
||||
"github.com/btcsuite/btcd/btcutil/base58"
|
||||
"github.com/btcsuite/btcd/btcutil/bech32"
|
||||
"golang.org/x/crypto/ripemd160"
|
||||
|
@ -99,7 +99,7 @@ func TstAddressTaproot(version byte, program [32]byte,
|
|||
func TstAddressPubKey(serializedPubKey []byte, pubKeyFormat PubKeyFormat,
|
||||
netID byte) *AddressPubKey {
|
||||
|
||||
pubKey, _ := btcec.ParsePubKey(serializedPubKey, btcec.S256())
|
||||
pubKey, _ := btcec.ParsePubKey(serializedPubKey)
|
||||
return &AddressPubKey{
|
||||
pubKeyFormat: pubKeyFormat,
|
||||
pubKey: pubKey,
|
||||
|
|
|
@ -4,15 +4,19 @@ go 1.17
|
|||
|
||||
require (
|
||||
github.com/btcsuite/btcd v0.22.0-beta.0.20220111032746-97732e52810c
|
||||
github.com/btcsuite/btcd/btcec/v2 v2.0.0
|
||||
github.com/btcsuite/btcd/btcutil v1.0.0
|
||||
github.com/davecgh/go-spew v1.1.1
|
||||
)
|
||||
|
||||
require (
|
||||
github.com/btcsuite/btclog v0.0.0-20170628155309-84c8d2346e9f // indirect
|
||||
github.com/decred/dcrd/dcrec/secp256k1/v4 v4.0.1 // indirect
|
||||
golang.org/x/crypto v0.0.0-20200622213623-75b288015ac9 // indirect
|
||||
)
|
||||
|
||||
replace github.com/btcsuite/btcd/btcec/v2 => ../../btcec
|
||||
|
||||
replace github.com/btcsuite/btcd/btcutil => ../
|
||||
|
||||
replace github.com/btcsuite/btcd => ../..
|
||||
|
|
|
@ -8,63 +8,23 @@ github.com/btcsuite/websocket v0.0.0-20150119174127-31079b680792/go.mod h1:ghJtE
|
|||
github.com/btcsuite/winsvc v1.0.0/go.mod h1:jsenWakMcC0zFBFurPLEAyrnc/teJEM1O46fmI40EZs=
|
||||
github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c=
|
||||
github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
|
||||
github.com/decred/dcrd/crypto/blake256 v1.0.0 h1:/8DMNYp9SGi5f0w7uCm6d6M4OU2rGFK09Y2A4Xv7EE0=
|
||||
github.com/decred/dcrd/crypto/blake256 v1.0.0/go.mod h1:sQl2p6Y26YV+ZOcSTP6thNdn47hh8kt6rqSlvmrXFAc=
|
||||
github.com/decred/dcrd/dcrec/secp256k1/v4 v4.0.1 h1:YLtO71vCjJRCBcrPMtQ9nqBsqpA1m5sE92cU+pd5Mcc=
|
||||
github.com/decred/dcrd/dcrec/secp256k1/v4 v4.0.1/go.mod h1:hyedUtir6IdtD/7lIxGeCxkaw7y45JueMRL4DIyJDKs=
|
||||
github.com/decred/dcrd/lru v1.0.0/go.mod h1:mxKOwFd7lFjN2GZYsiz/ecgqR6kkYAl+0pz0tEMk218=
|
||||
github.com/fsnotify/fsnotify v1.4.7/go.mod h1:jwhsz4b93w/PPRr/qN1Yymfu8t87LnFCMoQvtojpjFo=
|
||||
github.com/fsnotify/fsnotify v1.4.9/go.mod h1:znqG4EE+3YCdAaPaxE2ZRY/06pZUdp0tY4IgpuI1SZQ=
|
||||
github.com/golang/protobuf v1.2.0/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U=
|
||||
github.com/golang/protobuf v1.4.0-rc.1/go.mod h1:ceaxUfeHdC40wWswd/P6IGgMaK3YpKi5j83Wpe3EHw8=
|
||||
github.com/golang/protobuf v1.4.0-rc.1.0.20200221234624-67d41d38c208/go.mod h1:xKAWHe0F5eneWXFV3EuXVDTCmh+JuBKY0li0aMyXATA=
|
||||
github.com/golang/protobuf v1.4.0-rc.2/go.mod h1:LlEzMj4AhA7rCAGe4KMBDvJI+AwstrUpVNzEA03Pprs=
|
||||
github.com/golang/protobuf v1.4.0-rc.4.0.20200313231945-b860323f09d0/go.mod h1:WU3c8KckQ9AFe+yFwt9sWVRKCVIyN9cPHBJSNnbL67w=
|
||||
github.com/golang/protobuf v1.4.0/go.mod h1:jodUvKwWbYaEsadDk5Fwe5c77LiNKVO9IDvqG2KuDX0=
|
||||
github.com/golang/protobuf v1.4.2/go.mod h1:oDoupMAO8OvCJWAcko0GGGIgR6R6ocIYbsSw735rRwI=
|
||||
github.com/google/go-cmp v0.3.0/go.mod h1:8QqcDgzrUqlUb/G2PQTWiueGozuR1884gddMywk6iLU=
|
||||
github.com/google/go-cmp v0.3.1/go.mod h1:8QqcDgzrUqlUb/G2PQTWiueGozuR1884gddMywk6iLU=
|
||||
github.com/google/go-cmp v0.4.0/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE=
|
||||
github.com/hpcloud/tail v1.0.0/go.mod h1:ab1qPbhIpdTxEkNHXyeSf5vhxWSCs/tWer42PpOxQnU=
|
||||
github.com/jessevdk/go-flags v1.4.0/go.mod h1:4FA24M0QyGHXBuZZK/XkWh8h0e1EYbRYJSGM75WSRxI=
|
||||
github.com/jrick/logrotate v1.0.0/go.mod h1:LNinyqDIJnpAur+b8yyulnQw/wDuN1+BYKlTRt3OuAQ=
|
||||
github.com/kkdai/bstream v0.0.0-20161212061736-f391b8402d23/go.mod h1:J+Gs4SYgM6CZQHDETBtE9HaSEkGmuNXF86RwHhHUvq4=
|
||||
github.com/nxadm/tail v1.4.4/go.mod h1:kenIhsEOeOJmVchQTgglprH7qJGnHDVpk1VPCcaMI8A=
|
||||
github.com/onsi/ginkgo v1.6.0/go.mod h1:lLunBs/Ym6LB5Z9jYTR76FiuTmxDTDusOGeTQH+WWjE=
|
||||
github.com/onsi/ginkgo v1.12.1/go.mod h1:zj2OWP4+oCPe1qIXoGWkgMRwljMUYCdkwsT2108oapk=
|
||||
github.com/onsi/ginkgo v1.14.0/go.mod h1:iSB4RoI2tjJc9BBv4NKIKWKya62Rps+oPG/Lv9klQyY=
|
||||
github.com/onsi/gomega v1.4.1/go.mod h1:C1qb7wdrVGGVU+Z6iS04AVkA3Q65CEZX59MT0QO5uiA=
|
||||
github.com/onsi/gomega v1.7.1/go.mod h1:XdKZgCCFLUoM/7CFJVPcG8C1xQ1AJ0vpAezJrB7JYyY=
|
||||
github.com/onsi/gomega v1.10.1/go.mod h1:iN09h71vgCQne3DLsj+A5owkum+a2tYe+TOCB1ybHNo=
|
||||
golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w=
|
||||
golang.org/x/crypto v0.0.0-20200622213623-75b288015ac9 h1:psW17arqaxU48Z5kZ0CQnkZWQJsqcURM6tKiBApRjXI=
|
||||
golang.org/x/crypto v0.0.0-20200622213623-75b288015ac9/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto=
|
||||
golang.org/x/net v0.0.0-20180719180050-a680a1efc54d/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4=
|
||||
golang.org/x/net v0.0.0-20180906233101-161cd47e91fd/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4=
|
||||
golang.org/x/net v0.0.0-20190404232315-eb5bcb51f2a3/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg=
|
||||
golang.org/x/net v0.0.0-20200520004742-59133d7f0dd7/go.mod h1:qpuaurCH72eLCgpAm/N6yyVIVM9cpaDIP3A8BGJEC5A=
|
||||
golang.org/x/net v0.0.0-20200813134508-3edf25e44fcc/go.mod h1:/O7V0waA8r7cgGh81Ro3o1hOxt32SMVPicZroKQ2sZA=
|
||||
golang.org/x/sync v0.0.0-20180314180146-1d60e4601c6f/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
|
||||
golang.org/x/sys v0.0.0-20180909124046-d0be0721c37e/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
|
||||
golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
|
||||
golang.org/x/sys v0.0.0-20190412213103-97732733099d/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
||||
golang.org/x/sys v0.0.0-20190904154756-749cb33beabd/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
||||
golang.org/x/sys v0.0.0-20191005200804-aed5e4c7ecf9/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
||||
golang.org/x/sys v0.0.0-20191120155948-bd437916bb0e/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
||||
golang.org/x/sys v0.0.0-20200323222414-85ca7c5b95cd/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
||||
golang.org/x/sys v0.0.0-20200519105757-fe76b779f299/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
||||
golang.org/x/sys v0.0.0-20200814200057-3d37ad5750ed/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
||||
golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ=
|
||||
golang.org/x/text v0.3.2/go.mod h1:bEr9sfX3Q8Zfm5fL9x+3itogRgK3+ptLWKqgva+5dAk=
|
||||
golang.org/x/text v0.3.3/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ=
|
||||
golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ=
|
||||
golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
|
||||
golang.org/x/xerrors v0.0.0-20200804184101-5ec99f83aff1/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
|
||||
google.golang.org/protobuf v0.0.0-20200109180630-ec00e32a8dfd/go.mod h1:DFci5gLYBciE7Vtevhsrf46CRTquxDuWsQurQQe4oz8=
|
||||
google.golang.org/protobuf v0.0.0-20200221191635-4d8936d0db64/go.mod h1:kwYJMbMJ01Woi6D6+Kah6886xMZcty6N08ah7+eCXa0=
|
||||
google.golang.org/protobuf v0.0.0-20200228230310-ab0ca4ff8a60/go.mod h1:cfTl7dwQJ+fmap5saPgwCLgHXTUD7jkjRqWcaiX5VyM=
|
||||
google.golang.org/protobuf v1.20.1-0.20200309200217-e05f789c0967/go.mod h1:A+miEFZTKqfCUM6K7xSMQL9OKL/b6hQv+e19PK+JZNE=
|
||||
google.golang.org/protobuf v1.21.0/go.mod h1:47Nbq4nVaFHyn7ilMalzfO3qCViNmqZ2kzikPIcrTAo=
|
||||
google.golang.org/protobuf v1.23.0/go.mod h1:EGpADcykh3NcUnDUJcl1+ZksZNG86OlYog2l/sGQquU=
|
||||
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
|
||||
gopkg.in/fsnotify.v1 v1.4.7/go.mod h1:Tz8NjZHkW78fSQdbUxIjBTcgA1z1m8ZHf0WmKUhAMys=
|
||||
gopkg.in/tomb.v1 v1.0.0-20141024135613-dd632973f1e7/go.mod h1:dt/ZhP58zS4L8KSrWDmTeBkI65Dw0HsyUHuEVlX15mw=
|
||||
gopkg.in/yaml.v2 v2.2.1/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI=
|
||||
gopkg.in/yaml.v2 v2.2.4/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI=
|
||||
gopkg.in/yaml.v2 v2.3.0/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI=
|
||||
|
|
|
@ -3,7 +3,7 @@ package psbt
|
|||
import (
|
||||
"bytes"
|
||||
|
||||
"github.com/btcsuite/btcd/btcec"
|
||||
"github.com/btcsuite/btcd/btcec/v2"
|
||||
)
|
||||
|
||||
// PartialSig encapsulate a (BTC public key, ECDSA signature)
|
||||
|
@ -30,7 +30,7 @@ func (s PartialSigSorter) Less(i, j int) bool {
|
|||
// validatePubkey checks if pubKey is *any* valid pubKey serialization in a
|
||||
// Bitcoin context (compressed/uncomp. OK).
|
||||
func validatePubkey(pubKey []byte) bool {
|
||||
_, err := btcec.ParsePubKey(pubKey, btcec.S256())
|
||||
_, err := btcec.ParsePubKey(pubKey)
|
||||
return err == nil
|
||||
}
|
||||
|
||||
|
@ -38,7 +38,7 @@ func validatePubkey(pubKey []byte) bool {
|
|||
// ECDSA signature, including the sighash flag. It does *not* of course
|
||||
// validate the signature against any message or public key.
|
||||
func validateSignature(sig []byte) bool {
|
||||
_, err := btcec.ParseDERSignature(sig, btcec.S256())
|
||||
_, err := btcec.ParseDERSignature(sig)
|
||||
return err == nil
|
||||
}
|
||||
|
||||
|
|
|
@ -8,10 +8,10 @@ import (
|
|||
"bytes"
|
||||
"errors"
|
||||
|
||||
"github.com/btcsuite/btcd/btcec"
|
||||
"github.com/btcsuite/btcd/btcec/v2"
|
||||
"github.com/btcsuite/btcd/btcutil/base58"
|
||||
"github.com/btcsuite/btcd/chaincfg"
|
||||
"github.com/btcsuite/btcd/chaincfg/chainhash"
|
||||
"github.com/btcsuite/btcd/btcutil/base58"
|
||||
)
|
||||
|
||||
// ErrMalformedPrivateKey describes an error where a WIF-encoded private
|
||||
|
@ -117,7 +117,7 @@ func DecodeWIF(wif string) (*WIF, error) {
|
|||
|
||||
netID := decoded[0]
|
||||
privKeyBytes := decoded[1 : 1+btcec.PrivKeyBytesLen]
|
||||
privKey, _ := btcec.PrivKeyFromBytes(btcec.S256(), privKeyBytes)
|
||||
privKey, _ := btcec.PrivKeyFromBytes(privKeyBytes)
|
||||
return &WIF{privKey, compress, netID}, nil
|
||||
}
|
||||
|
||||
|
@ -136,9 +136,7 @@ func (w *WIF) String() string {
|
|||
|
||||
a := make([]byte, 0, encodeLen)
|
||||
a = append(a, w.netID)
|
||||
// Pad and append bytes manually, instead of using Serialize, to
|
||||
// avoid another call to make.
|
||||
a = paddedAppend(btcec.PrivKeyBytesLen, a, w.PrivKey.D.Bytes())
|
||||
a = append(a, w.PrivKey.Serialize()...)
|
||||
if w.CompressPubKey {
|
||||
a = append(a, compressMagic)
|
||||
}
|
||||
|
@ -151,19 +149,9 @@ func (w *WIF) String() string {
|
|||
// exported private key in either a compressed or uncompressed format. The
|
||||
// serialization format chosen depends on the value of w.CompressPubKey.
|
||||
func (w *WIF) SerializePubKey() []byte {
|
||||
pk := (*btcec.PublicKey)(&w.PrivKey.PublicKey)
|
||||
pk := w.PrivKey.PubKey()
|
||||
if w.CompressPubKey {
|
||||
return pk.SerializeCompressed()
|
||||
}
|
||||
return pk.SerializeUncompressed()
|
||||
}
|
||||
|
||||
// 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...)
|
||||
}
|
||||
|
|
|
@ -9,9 +9,9 @@ import (
|
|||
"encoding/hex"
|
||||
"testing"
|
||||
|
||||
"github.com/btcsuite/btcd/btcec"
|
||||
"github.com/btcsuite/btcd/chaincfg"
|
||||
"github.com/btcsuite/btcd/btcec/v2"
|
||||
. "github.com/btcsuite/btcd/btcutil"
|
||||
"github.com/btcsuite/btcd/chaincfg"
|
||||
)
|
||||
|
||||
func TestEncodeDecodeWIF(t *testing.T) {
|
||||
|
@ -67,7 +67,7 @@ func TestEncodeDecodeWIF(t *testing.T) {
|
|||
validCase := validCase
|
||||
|
||||
t.Run(validCase.name, func(t *testing.T) {
|
||||
priv, _ := btcec.PrivKeyFromBytes(btcec.S256(), validCase.privateKey)
|
||||
priv, _ := btcec.PrivKeyFromBytes(validCase.privateKey)
|
||||
wif, err := NewWIF(priv, validCase.net, validCase.compress)
|
||||
if err != nil {
|
||||
t.Fatalf("NewWIF failed: expected no error, got '%v'", err)
|
||||
|
@ -145,7 +145,7 @@ func TestEncodeDecodeWIF(t *testing.T) {
|
|||
0x60, 0x0b, 0x2f, 0xe5, 0x0b, 0x7c, 0xae, 0x11,
|
||||
0xec, 0x86, 0xd3, 0xbf, 0x1f, 0xbe, 0x47, 0x1b,
|
||||
0xe8, 0x98, 0x27, 0xe1, 0x9d, 0x72, 0xaa, 0x1d}
|
||||
priv, _ := btcec.PrivKeyFromBytes(btcec.S256(), privateKey)
|
||||
priv, _ := btcec.PrivKeyFromBytes(privateKey)
|
||||
|
||||
wif, err := NewWIF(priv, nil, true)
|
||||
|
||||
|
|
4
go.mod
4
go.mod
|
@ -1,6 +1,7 @@
|
|||
module github.com/btcsuite/btcd
|
||||
|
||||
require (
|
||||
github.com/btcsuite/btcd/btcec/v2 v2.0.0
|
||||
github.com/btcsuite/btcd/btcutil v1.0.0
|
||||
github.com/btcsuite/btclog v0.0.0-20170628155309-84c8d2346e9f
|
||||
github.com/btcsuite/go-socks v0.0.0-20170105172521-4720035b7bfd
|
||||
|
@ -17,9 +18,12 @@ require (
|
|||
require (
|
||||
github.com/aead/siphash v1.0.1 // indirect
|
||||
github.com/btcsuite/snappy-go v1.0.0 // indirect
|
||||
github.com/decred/dcrd/dcrec/secp256k1/v4 v4.0.1 // indirect
|
||||
github.com/kkdai/bstream v0.0.0-20161212061736-f391b8402d23 // indirect
|
||||
)
|
||||
|
||||
replace github.com/btcsuite/btcd/btcutil => ./btcutil
|
||||
|
||||
replace github.com/btcsuite/btcd/btcec/v2 => ./btcec
|
||||
|
||||
go 1.17
|
||||
|
|
4
go.sum
4
go.sum
|
@ -15,6 +15,10 @@ github.com/btcsuite/winsvc v1.0.0 h1:J9B4L7e3oqhXOcm+2IuNApwzQec85lE+QaikUcCs+dk
|
|||
github.com/btcsuite/winsvc v1.0.0/go.mod h1:jsenWakMcC0zFBFurPLEAyrnc/teJEM1O46fmI40EZs=
|
||||
github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c=
|
||||
github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
|
||||
github.com/decred/dcrd/crypto/blake256 v1.0.0 h1:/8DMNYp9SGi5f0w7uCm6d6M4OU2rGFK09Y2A4Xv7EE0=
|
||||
github.com/decred/dcrd/crypto/blake256 v1.0.0/go.mod h1:sQl2p6Y26YV+ZOcSTP6thNdn47hh8kt6rqSlvmrXFAc=
|
||||
github.com/decred/dcrd/dcrec/secp256k1/v4 v4.0.1 h1:YLtO71vCjJRCBcrPMtQ9nqBsqpA1m5sE92cU+pd5Mcc=
|
||||
github.com/decred/dcrd/dcrec/secp256k1/v4 v4.0.1/go.mod h1:hyedUtir6IdtD/7lIxGeCxkaw7y45JueMRL4DIyJDKs=
|
||||
github.com/decred/dcrd/lru v1.0.0 h1:Kbsb1SFDsIlaupWPwsPp+dkxiBY1frcS07PCPgotKz8=
|
||||
github.com/decred/dcrd/lru v1.0.0/go.mod h1:mxKOwFd7lFjN2GZYsiz/ecgqR6kkYAl+0pz0tEMk218=
|
||||
github.com/fsnotify/fsnotify v1.4.7/go.mod h1:jwhsz4b93w/PPRr/qN1Yymfu8t87LnFCMoQvtojpjFo=
|
||||
|
|
|
@ -3,6 +3,7 @@
|
|||
// license that can be found in the LICENSE file.
|
||||
|
||||
// This file is ignored during the regular tests due to the following build tag.
|
||||
//go:build rpctest
|
||||
// +build rpctest
|
||||
|
||||
package integration
|
||||
|
@ -15,7 +16,7 @@ import (
|
|||
"time"
|
||||
|
||||
"github.com/btcsuite/btcd/blockchain"
|
||||
"github.com/btcsuite/btcd/btcec"
|
||||
"github.com/btcsuite/btcd/btcec/v2"
|
||||
"github.com/btcsuite/btcd/chaincfg"
|
||||
"github.com/btcsuite/btcd/chaincfg/chainhash"
|
||||
"github.com/btcsuite/btcd/integration/rpctest"
|
||||
|
@ -35,7 +36,7 @@ func makeTestOutput(r *rpctest.Harness, t *testing.T,
|
|||
|
||||
// Create a fresh key, then send some coins to an address spendable by
|
||||
// that key.
|
||||
key, err := btcec.NewPrivateKey(btcec.S256())
|
||||
key, err := btcec.NewPrivateKey()
|
||||
if err != nil {
|
||||
return nil, nil, nil, err
|
||||
}
|
||||
|
|
|
@ -3,6 +3,7 @@
|
|||
// license that can be found in the LICENSE file.
|
||||
|
||||
// This file is ignored during the regular tests due to the following build tag.
|
||||
//go:build rpctest
|
||||
// +build rpctest
|
||||
|
||||
package integration
|
||||
|
|
|
@ -11,14 +11,14 @@ import (
|
|||
"sync"
|
||||
|
||||
"github.com/btcsuite/btcd/blockchain"
|
||||
"github.com/btcsuite/btcd/btcec"
|
||||
"github.com/btcsuite/btcd/btcec/v2"
|
||||
"github.com/btcsuite/btcd/btcutil"
|
||||
"github.com/btcsuite/btcd/btcutil/hdkeychain"
|
||||
"github.com/btcsuite/btcd/chaincfg"
|
||||
"github.com/btcsuite/btcd/chaincfg/chainhash"
|
||||
"github.com/btcsuite/btcd/rpcclient"
|
||||
"github.com/btcsuite/btcd/txscript"
|
||||
"github.com/btcsuite/btcd/wire"
|
||||
"github.com/btcsuite/btcd/btcutil"
|
||||
"github.com/btcsuite/btcd/btcutil/hdkeychain"
|
||||
)
|
||||
|
||||
var (
|
||||
|
@ -133,6 +133,7 @@ func newMemWallet(net *chaincfg.Params, harnessID uint32) (*memWallet, error) {
|
|||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
coinbaseAddr, err := keyToAddr(coinbaseKey, net)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
|
@ -514,11 +515,13 @@ func (m *memWallet) CreateTransaction(outputs []*wire.TxOut,
|
|||
return nil, err
|
||||
}
|
||||
|
||||
privKey, err := extendedKey.ECPrivKey()
|
||||
privKeyOld, err := extendedKey.ECPrivKey()
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
privKey, _ := btcec.PrivKeyFromBytes(privKeyOld.Serialize())
|
||||
|
||||
sigScript, err := txscript.SignatureScript(tx, i, utxo.pkScript,
|
||||
txscript.SigHashAll, privKey, true)
|
||||
if err != nil {
|
||||
|
|
|
@ -3,6 +3,7 @@
|
|||
// license that can be found in the LICENSE file.
|
||||
|
||||
// This file is ignored during the regular tests due to the following build tag.
|
||||
//go:build rpctest
|
||||
// +build rpctest
|
||||
|
||||
package rpctest
|
||||
|
|
|
@ -13,7 +13,7 @@ import (
|
|||
"time"
|
||||
|
||||
"github.com/btcsuite/btcd/blockchain"
|
||||
"github.com/btcsuite/btcd/btcec"
|
||||
"github.com/btcsuite/btcd/btcec/v2"
|
||||
"github.com/btcsuite/btcd/chaincfg"
|
||||
"github.com/btcsuite/btcd/chaincfg/chainhash"
|
||||
"github.com/btcsuite/btcd/txscript"
|
||||
|
@ -291,7 +291,7 @@ func newPoolHarness(chainParams *chaincfg.Params) (*poolHarness, []spendableOutp
|
|||
if err != nil {
|
||||
return nil, nil, err
|
||||
}
|
||||
signKey, signPub := btcec.PrivKeyFromBytes(btcec.S256(), keyBytes)
|
||||
signKey, signPub := btcec.PrivKeyFromBytes(keyBytes)
|
||||
|
||||
// Generate associated pay-to-script-hash address and resulting payment
|
||||
// script.
|
||||
|
|
|
@ -9,7 +9,7 @@ import (
|
|||
"testing"
|
||||
"time"
|
||||
|
||||
"github.com/btcsuite/btcd/btcec"
|
||||
"github.com/btcsuite/btcd/btcec/v2"
|
||||
"github.com/btcsuite/btcd/chaincfg"
|
||||
"github.com/btcsuite/btcd/chaincfg/chainhash"
|
||||
"github.com/btcsuite/btcd/txscript"
|
||||
|
@ -98,7 +98,7 @@ func TestCalcMinRequiredTxRelayFee(t *testing.T) {
|
|||
func TestCheckPkScriptStandard(t *testing.T) {
|
||||
var pubKeys [][]byte
|
||||
for i := 0; i < 4; i++ {
|
||||
pk, err := btcec.NewPrivateKey(btcec.S256())
|
||||
pk, err := btcec.NewPrivateKey()
|
||||
if err != nil {
|
||||
t.Fatalf("TestCheckPkScriptStandard NewPrivateKey failed: %v",
|
||||
err)
|
||||
|
|
|
@ -29,7 +29,7 @@ import (
|
|||
|
||||
"github.com/btcsuite/btcd/blockchain"
|
||||
"github.com/btcsuite/btcd/blockchain/indexers"
|
||||
"github.com/btcsuite/btcd/btcec"
|
||||
"github.com/btcsuite/btcd/btcec/v2"
|
||||
"github.com/btcsuite/btcd/btcjson"
|
||||
"github.com/btcsuite/btcd/btcutil"
|
||||
"github.com/btcsuite/btcd/chaincfg"
|
||||
|
@ -3520,7 +3520,7 @@ func handleSignMessageWithPrivKey(s *rpcServer, cmd interface{}, closeChan <-cha
|
|||
wire.WriteVarString(&buf, 0, c.Message)
|
||||
messageHash := chainhash.DoubleHashB(buf.Bytes())
|
||||
|
||||
sig, err := btcec.SignCompact(btcec.S256(), wif.PrivKey,
|
||||
sig, err := btcec.SignCompact(wif.PrivKey,
|
||||
messageHash, wif.CompressPubKey)
|
||||
if err != nil {
|
||||
return nil, &btcjson.RPCError{
|
||||
|
@ -3715,7 +3715,7 @@ func handleVerifyMessage(s *rpcServer, cmd interface{}, closeChan <-chan struct{
|
|||
wire.WriteVarString(&buf, 0, messageSignatureHeader)
|
||||
wire.WriteVarString(&buf, 0, c.Message)
|
||||
expectedMessageHash := chainhash.DoubleHashB(buf.Bytes())
|
||||
pk, wasCompressed, err := btcec.RecoverCompact(btcec.S256(), sig,
|
||||
pk, wasCompressed, err := btcec.RecoverCompact(sig,
|
||||
expectedMessageHash)
|
||||
if err != nil {
|
||||
// Mirror Bitcoin Core behavior, which treats error in
|
||||
|
|
|
@ -12,7 +12,7 @@ import (
|
|||
"math/big"
|
||||
"strings"
|
||||
|
||||
"github.com/btcsuite/btcd/btcec"
|
||||
"github.com/btcsuite/btcd/btcec/v2"
|
||||
"github.com/btcsuite/btcd/wire"
|
||||
)
|
||||
|
||||
|
|
|
@ -9,7 +9,7 @@ import (
|
|||
"encoding/hex"
|
||||
"fmt"
|
||||
|
||||
"github.com/btcsuite/btcd/btcec"
|
||||
"github.com/btcsuite/btcd/btcec/v2"
|
||||
"github.com/btcsuite/btcd/chaincfg"
|
||||
"github.com/btcsuite/btcd/chaincfg/chainhash"
|
||||
"github.com/btcsuite/btcd/txscript"
|
||||
|
@ -90,7 +90,7 @@ func ExampleSignTxOutput() {
|
|||
fmt.Println(err)
|
||||
return
|
||||
}
|
||||
privKey, pubKey := btcec.PrivKeyFromBytes(btcec.S256(), privKeyBytes)
|
||||
privKey, pubKey := btcec.PrivKeyFromBytes(privKeyBytes)
|
||||
pubKeyHash := btcutil.Hash160(pubKey.SerializeCompressed())
|
||||
addr, err := btcutil.NewAddressPubKeyHash(pubKeyHash,
|
||||
&chaincfg.MainNetParams)
|
||||
|
|
|
@ -15,7 +15,7 @@ import (
|
|||
|
||||
"golang.org/x/crypto/ripemd160"
|
||||
|
||||
"github.com/btcsuite/btcd/btcec"
|
||||
"github.com/btcsuite/btcd/btcec/v2"
|
||||
"github.com/btcsuite/btcd/chaincfg/chainhash"
|
||||
"github.com/btcsuite/btcd/wire"
|
||||
)
|
||||
|
@ -1929,7 +1929,7 @@ func opcodeCheckSig(op *opcode, data []byte, vm *Engine) error {
|
|||
hash = calcSignatureHash(subScript, hashType, &vm.tx, vm.txIdx)
|
||||
}
|
||||
|
||||
pubKey, err := btcec.ParsePubKey(pkBytes, btcec.S256())
|
||||
pubKey, err := btcec.ParsePubKey(pkBytes)
|
||||
if err != nil {
|
||||
vm.dstack.PushBool(false)
|
||||
return nil
|
||||
|
@ -1939,9 +1939,9 @@ func opcodeCheckSig(op *opcode, data []byte, vm *Engine) error {
|
|||
if vm.hasFlag(ScriptVerifyStrictEncoding) ||
|
||||
vm.hasFlag(ScriptVerifyDERSignatures) {
|
||||
|
||||
signature, err = btcec.ParseDERSignature(sigBytes, btcec.S256())
|
||||
signature, err = btcec.ParseDERSignature(sigBytes)
|
||||
} else {
|
||||
signature, err = btcec.ParseSignature(sigBytes, btcec.S256())
|
||||
signature, err = btcec.ParseSignature(sigBytes)
|
||||
}
|
||||
if err != nil {
|
||||
vm.dstack.PushBool(false)
|
||||
|
@ -2148,11 +2148,9 @@ func opcodeCheckMultiSig(op *opcode, data []byte, vm *Engine) error {
|
|||
if vm.hasFlag(ScriptVerifyStrictEncoding) ||
|
||||
vm.hasFlag(ScriptVerifyDERSignatures) {
|
||||
|
||||
parsedSig, err = btcec.ParseDERSignature(signature,
|
||||
btcec.S256())
|
||||
parsedSig, err = btcec.ParseDERSignature(signature)
|
||||
} else {
|
||||
parsedSig, err = btcec.ParseSignature(signature,
|
||||
btcec.S256())
|
||||
parsedSig, err = btcec.ParseSignature(signature)
|
||||
}
|
||||
sigInfo.parsed = true
|
||||
if err != nil {
|
||||
|
@ -2174,7 +2172,7 @@ func opcodeCheckMultiSig(op *opcode, data []byte, vm *Engine) error {
|
|||
}
|
||||
|
||||
// Parse the pubkey.
|
||||
parsedPubKey, err := btcec.ParsePubKey(pubKey, btcec.S256())
|
||||
parsedPubKey, err := btcec.ParsePubKey(pubKey)
|
||||
if err != nil {
|
||||
continue
|
||||
}
|
||||
|
|
|
@ -5,7 +5,7 @@ import (
|
|||
"errors"
|
||||
"fmt"
|
||||
|
||||
"github.com/btcsuite/btcd/btcec"
|
||||
"github.com/btcsuite/btcd/btcec/v2"
|
||||
"github.com/btcsuite/btcd/chaincfg"
|
||||
"github.com/btcsuite/btcd/wire"
|
||||
"github.com/btcsuite/btcd/btcutil"
|
||||
|
|
|
@ -7,7 +7,7 @@ package txscript
|
|||
import (
|
||||
"sync"
|
||||
|
||||
"github.com/btcsuite/btcd/btcec"
|
||||
"github.com/btcsuite/btcd/btcec/v2"
|
||||
"github.com/btcsuite/btcd/chaincfg/chainhash"
|
||||
)
|
||||
|
||||
|
|
|
@ -8,7 +8,7 @@ import (
|
|||
"crypto/rand"
|
||||
"testing"
|
||||
|
||||
"github.com/btcsuite/btcd/btcec"
|
||||
"github.com/btcsuite/btcd/btcec/v2"
|
||||
"github.com/btcsuite/btcd/chaincfg/chainhash"
|
||||
)
|
||||
|
||||
|
@ -16,7 +16,7 @@ import (
|
|||
// public key and the public key. This function is used to generate randomized
|
||||
// test data.
|
||||
func genRandomSig() (*chainhash.Hash, *btcec.Signature, *btcec.PublicKey, error) {
|
||||
privKey, err := btcec.NewPrivateKey(btcec.S256())
|
||||
privKey, err := btcec.NewPrivateKey()
|
||||
if err != nil {
|
||||
return nil, nil, nil, err
|
||||
}
|
||||
|
@ -26,10 +26,7 @@ func genRandomSig() (*chainhash.Hash, *btcec.Signature, *btcec.PublicKey, error)
|
|||
return nil, nil, nil, err
|
||||
}
|
||||
|
||||
sig, err := privKey.Sign(msgHash[:])
|
||||
if err != nil {
|
||||
return nil, nil, nil, err
|
||||
}
|
||||
sig := btcec.Sign(privKey, msgHash[:])
|
||||
|
||||
return &msgHash, sig, privKey.PubKey(), nil
|
||||
}
|
||||
|
@ -49,8 +46,8 @@ func TestSigCacheAddExists(t *testing.T) {
|
|||
sigCache.Add(*msg1, sig1, key1)
|
||||
|
||||
// The previously added triplet should now be found within the sigcache.
|
||||
sig1Copy, _ := btcec.ParseSignature(sig1.Serialize(), btcec.S256())
|
||||
key1Copy, _ := btcec.ParsePubKey(key1.SerializeCompressed(), btcec.S256())
|
||||
sig1Copy, _ := btcec.ParseSignature(sig1.Serialize())
|
||||
key1Copy, _ := btcec.ParsePubKey(key1.SerializeCompressed())
|
||||
if !sigCache.Exists(*msg1, sig1Copy, key1Copy) {
|
||||
t.Errorf("previously added item not found in signature cache")
|
||||
}
|
||||
|
@ -73,8 +70,14 @@ func TestSigCacheAddEvictEntry(t *testing.T) {
|
|||
|
||||
sigCache.Add(*msg, sig, key)
|
||||
|
||||
sigCopy, _ := btcec.ParseSignature(sig.Serialize(), btcec.S256())
|
||||
keyCopy, _ := btcec.ParsePubKey(key.SerializeCompressed(), btcec.S256())
|
||||
sigCopy, err := btcec.ParseSignature(sig.Serialize())
|
||||
if err != nil {
|
||||
t.Fatalf("unable to parse sig: %v", err)
|
||||
}
|
||||
keyCopy, err := btcec.ParsePubKey(key.SerializeCompressed())
|
||||
if err != nil {
|
||||
t.Fatalf("unable to parse key: %v", err)
|
||||
}
|
||||
if !sigCache.Exists(*msg, sigCopy, keyCopy) {
|
||||
t.Errorf("previously added item not found in signature" +
|
||||
"cache")
|
||||
|
@ -102,8 +105,8 @@ func TestSigCacheAddEvictEntry(t *testing.T) {
|
|||
}
|
||||
|
||||
// The entry added above should be found within the sigcache.
|
||||
sigNewCopy, _ := btcec.ParseSignature(sigNew.Serialize(), btcec.S256())
|
||||
keyNewCopy, _ := btcec.ParsePubKey(keyNew.SerializeCompressed(), btcec.S256())
|
||||
sigNewCopy, _ := btcec.ParseSignature(sigNew.Serialize())
|
||||
keyNewCopy, _ := btcec.ParsePubKey(keyNew.SerializeCompressed())
|
||||
if !sigCache.Exists(*msgNew, sigNewCopy, keyNewCopy) {
|
||||
t.Fatalf("previously added item not found in signature cache")
|
||||
}
|
||||
|
@ -125,8 +128,8 @@ func TestSigCacheAddMaxEntriesZeroOrNegative(t *testing.T) {
|
|||
sigCache.Add(*msg1, sig1, key1)
|
||||
|
||||
// The generated triplet should not be found.
|
||||
sig1Copy, _ := btcec.ParseSignature(sig1.Serialize(), btcec.S256())
|
||||
key1Copy, _ := btcec.ParsePubKey(key1.SerializeCompressed(), btcec.S256())
|
||||
sig1Copy, _ := btcec.ParseSignature(sig1.Serialize())
|
||||
key1Copy, _ := btcec.ParsePubKey(key1.SerializeCompressed())
|
||||
if sigCache.Exists(*msg1, sig1Copy, key1Copy) {
|
||||
t.Errorf("previously added signature found in sigcache, but" +
|
||||
"shouldn't have been")
|
||||
|
|
|
@ -6,12 +6,11 @@ package txscript
|
|||
|
||||
import (
|
||||
"errors"
|
||||
"fmt"
|
||||
|
||||
"github.com/btcsuite/btcd/btcec"
|
||||
"github.com/btcsuite/btcd/btcec/v2"
|
||||
"github.com/btcsuite/btcd/btcutil"
|
||||
"github.com/btcsuite/btcd/chaincfg"
|
||||
"github.com/btcsuite/btcd/wire"
|
||||
"github.com/btcsuite/btcd/btcutil"
|
||||
)
|
||||
|
||||
// RawTxInWitnessSignature returns the serialized ECDA signature for the input
|
||||
|
@ -28,10 +27,7 @@ func RawTxInWitnessSignature(tx *wire.MsgTx, sigHashes *TxSigHashes, idx int,
|
|||
return nil, err
|
||||
}
|
||||
|
||||
signature, err := key.Sign(hash)
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("cannot sign tx input: %s", err)
|
||||
}
|
||||
signature := btcec.Sign(key, hash)
|
||||
|
||||
return append(signature.Serialize(), byte(hashType)), nil
|
||||
}
|
||||
|
@ -51,7 +47,7 @@ func WitnessSignature(tx *wire.MsgTx, sigHashes *TxSigHashes, idx int, amt int64
|
|||
return nil, err
|
||||
}
|
||||
|
||||
pk := (*btcec.PublicKey)(&privKey.PublicKey)
|
||||
pk := privKey.PubKey()
|
||||
var pkData []byte
|
||||
if compress {
|
||||
pkData = pk.SerializeCompressed()
|
||||
|
@ -73,10 +69,7 @@ func RawTxInSignature(tx *wire.MsgTx, idx int, subScript []byte,
|
|||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
signature, err := key.Sign(hash)
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("cannot sign tx input: %s", err)
|
||||
}
|
||||
signature := btcec.Sign(key, hash)
|
||||
|
||||
return append(signature.Serialize(), byte(hashType)), nil
|
||||
}
|
||||
|
@ -95,7 +88,7 @@ func SignatureScript(tx *wire.MsgTx, idx int, subscript []byte, hashType SigHash
|
|||
return nil, err
|
||||
}
|
||||
|
||||
pk := (*btcec.PublicKey)(&privKey.PublicKey)
|
||||
pk := privKey.PubKey()
|
||||
var pkData []byte
|
||||
if compress {
|
||||
pkData = pk.SerializeCompressed()
|
||||
|
@ -270,7 +263,7 @@ sigLoop:
|
|||
tSig := sig[:len(sig)-1]
|
||||
hashType := SigHashType(sig[len(sig)-1])
|
||||
|
||||
pSig, err := btcec.ParseDERSignature(tSig, btcec.S256())
|
||||
pSig, err := btcec.ParseDERSignature(tSig)
|
||||
if err != nil {
|
||||
continue
|
||||
}
|
||||
|
|
|
@ -9,7 +9,7 @@ import (
|
|||
"fmt"
|
||||
"testing"
|
||||
|
||||
"github.com/btcsuite/btcd/btcec"
|
||||
"github.com/btcsuite/btcd/btcec/v2"
|
||||
"github.com/btcsuite/btcd/chaincfg"
|
||||
"github.com/btcsuite/btcd/chaincfg/chainhash"
|
||||
"github.com/btcsuite/btcd/wire"
|
||||
|
@ -143,15 +143,14 @@ func TestSignTxOutput(t *testing.T) {
|
|||
for _, hashType := range hashTypes {
|
||||
for i := range tx.TxIn {
|
||||
msg := fmt.Sprintf("%d:%d", hashType, i)
|
||||
key, err := btcec.NewPrivateKey(btcec.S256())
|
||||
key, err := btcec.NewPrivateKey()
|
||||
if err != nil {
|
||||
t.Errorf("failed to make privKey for %s: %v",
|
||||
msg, err)
|
||||
break
|
||||
}
|
||||
|
||||
pk := (*btcec.PublicKey)(&key.PublicKey).
|
||||
SerializeUncompressed()
|
||||
pk := key.PubKey().SerializeUncompressed()
|
||||
address, err := btcutil.NewAddressPubKeyHash(
|
||||
btcutil.Hash160(pk), &chaincfg.TestNet3Params)
|
||||
if err != nil {
|
||||
|
@ -180,15 +179,14 @@ func TestSignTxOutput(t *testing.T) {
|
|||
for _, hashType := range hashTypes {
|
||||
for i := range tx.TxIn {
|
||||
msg := fmt.Sprintf("%d:%d", hashType, i)
|
||||
key, err := btcec.NewPrivateKey(btcec.S256())
|
||||
key, err := btcec.NewPrivateKey()
|
||||
if err != nil {
|
||||
t.Errorf("failed to make privKey for %s: %v",
|
||||
msg, err)
|
||||
break
|
||||
}
|
||||
|
||||
pk := (*btcec.PublicKey)(&key.PublicKey).
|
||||
SerializeUncompressed()
|
||||
pk := key.PubKey().SerializeUncompressed()
|
||||
address, err := btcutil.NewAddressPubKeyHash(
|
||||
btcutil.Hash160(pk), &chaincfg.TestNet3Params)
|
||||
if err != nil {
|
||||
|
@ -241,15 +239,14 @@ func TestSignTxOutput(t *testing.T) {
|
|||
for i := range tx.TxIn {
|
||||
msg := fmt.Sprintf("%d:%d", hashType, i)
|
||||
|
||||
key, err := btcec.NewPrivateKey(btcec.S256())
|
||||
key, err := btcec.NewPrivateKey()
|
||||
if err != nil {
|
||||
t.Errorf("failed to make privKey for %s: %v",
|
||||
msg, err)
|
||||
break
|
||||
}
|
||||
|
||||
pk := (*btcec.PublicKey)(&key.PublicKey).
|
||||
SerializeCompressed()
|
||||
pk := key.PubKey().SerializeCompressed()
|
||||
address, err := btcutil.NewAddressPubKeyHash(
|
||||
btcutil.Hash160(pk), &chaincfg.TestNet3Params)
|
||||
if err != nil {
|
||||
|
@ -280,15 +277,14 @@ func TestSignTxOutput(t *testing.T) {
|
|||
for i := range tx.TxIn {
|
||||
msg := fmt.Sprintf("%d:%d", hashType, i)
|
||||
|
||||
key, err := btcec.NewPrivateKey(btcec.S256())
|
||||
key, err := btcec.NewPrivateKey()
|
||||
if err != nil {
|
||||
t.Errorf("failed to make privKey for %s: %v",
|
||||
msg, err)
|
||||
break
|
||||
}
|
||||
|
||||
pk := (*btcec.PublicKey)(&key.PublicKey).
|
||||
SerializeCompressed()
|
||||
pk := key.PubKey().SerializeCompressed()
|
||||
address, err := btcutil.NewAddressPubKeyHash(
|
||||
btcutil.Hash160(pk), &chaincfg.TestNet3Params)
|
||||
if err != nil {
|
||||
|
@ -342,15 +338,14 @@ func TestSignTxOutput(t *testing.T) {
|
|||
for i := range tx.TxIn {
|
||||
msg := fmt.Sprintf("%d:%d", hashType, i)
|
||||
|
||||
key, err := btcec.NewPrivateKey(btcec.S256())
|
||||
key, err := btcec.NewPrivateKey()
|
||||
if err != nil {
|
||||
t.Errorf("failed to make privKey for %s: %v",
|
||||
msg, err)
|
||||
break
|
||||
}
|
||||
|
||||
pk := (*btcec.PublicKey)(&key.PublicKey).
|
||||
SerializeUncompressed()
|
||||
pk := key.PubKey().SerializeUncompressed()
|
||||
address, err := btcutil.NewAddressPubKey(pk,
|
||||
&chaincfg.TestNet3Params)
|
||||
if err != nil {
|
||||
|
@ -381,15 +376,14 @@ func TestSignTxOutput(t *testing.T) {
|
|||
for i := range tx.TxIn {
|
||||
msg := fmt.Sprintf("%d:%d", hashType, i)
|
||||
|
||||
key, err := btcec.NewPrivateKey(btcec.S256())
|
||||
key, err := btcec.NewPrivateKey()
|
||||
if err != nil {
|
||||
t.Errorf("failed to make privKey for %s: %v",
|
||||
msg, err)
|
||||
break
|
||||
}
|
||||
|
||||
pk := (*btcec.PublicKey)(&key.PublicKey).
|
||||
SerializeUncompressed()
|
||||
pk := key.PubKey().SerializeUncompressed()
|
||||
address, err := btcutil.NewAddressPubKey(pk,
|
||||
&chaincfg.TestNet3Params)
|
||||
if err != nil {
|
||||
|
@ -442,15 +436,14 @@ func TestSignTxOutput(t *testing.T) {
|
|||
for i := range tx.TxIn {
|
||||
msg := fmt.Sprintf("%d:%d", hashType, i)
|
||||
|
||||
key, err := btcec.NewPrivateKey(btcec.S256())
|
||||
key, err := btcec.NewPrivateKey()
|
||||
if err != nil {
|
||||
t.Errorf("failed to make privKey for %s: %v",
|
||||
msg, err)
|
||||
break
|
||||
}
|
||||
|
||||
pk := (*btcec.PublicKey)(&key.PublicKey).
|
||||
SerializeCompressed()
|
||||
pk := key.PubKey().SerializeCompressed()
|
||||
address, err := btcutil.NewAddressPubKey(pk,
|
||||
&chaincfg.TestNet3Params)
|
||||
if err != nil {
|
||||
|
@ -481,15 +474,14 @@ func TestSignTxOutput(t *testing.T) {
|
|||
for i := range tx.TxIn {
|
||||
msg := fmt.Sprintf("%d:%d", hashType, i)
|
||||
|
||||
key, err := btcec.NewPrivateKey(btcec.S256())
|
||||
key, err := btcec.NewPrivateKey()
|
||||
if err != nil {
|
||||
t.Errorf("failed to make privKey for %s: %v",
|
||||
msg, err)
|
||||
break
|
||||
}
|
||||
|
||||
pk := (*btcec.PublicKey)(&key.PublicKey).
|
||||
SerializeCompressed()
|
||||
pk := key.PubKey().SerializeCompressed()
|
||||
address, err := btcutil.NewAddressPubKey(pk,
|
||||
&chaincfg.TestNet3Params)
|
||||
if err != nil {
|
||||
|
@ -543,15 +535,14 @@ func TestSignTxOutput(t *testing.T) {
|
|||
for _, hashType := range hashTypes {
|
||||
for i := range tx.TxIn {
|
||||
msg := fmt.Sprintf("%d:%d", hashType, i)
|
||||
key, err := btcec.NewPrivateKey(btcec.S256())
|
||||
key, err := btcec.NewPrivateKey()
|
||||
if err != nil {
|
||||
t.Errorf("failed to make privKey for %s: %v",
|
||||
msg, err)
|
||||
break
|
||||
}
|
||||
|
||||
pk := (*btcec.PublicKey)(&key.PublicKey).
|
||||
SerializeUncompressed()
|
||||
pk := key.PubKey().SerializeUncompressed()
|
||||
address, err := btcutil.NewAddressPubKeyHash(
|
||||
btcutil.Hash160(pk), &chaincfg.TestNet3Params)
|
||||
if err != nil {
|
||||
|
@ -600,15 +591,14 @@ func TestSignTxOutput(t *testing.T) {
|
|||
for _, hashType := range hashTypes {
|
||||
for i := range tx.TxIn {
|
||||
msg := fmt.Sprintf("%d:%d", hashType, i)
|
||||
key, err := btcec.NewPrivateKey(btcec.S256())
|
||||
key, err := btcec.NewPrivateKey()
|
||||
if err != nil {
|
||||
t.Errorf("failed to make privKey for %s: %v",
|
||||
msg, err)
|
||||
break
|
||||
}
|
||||
|
||||
pk := (*btcec.PublicKey)(&key.PublicKey).
|
||||
SerializeUncompressed()
|
||||
pk := key.PubKey().SerializeUncompressed()
|
||||
address, err := btcutil.NewAddressPubKeyHash(
|
||||
btcutil.Hash160(pk), &chaincfg.TestNet3Params)
|
||||
if err != nil {
|
||||
|
@ -683,15 +673,14 @@ func TestSignTxOutput(t *testing.T) {
|
|||
for i := range tx.TxIn {
|
||||
msg := fmt.Sprintf("%d:%d", hashType, i)
|
||||
|
||||
key, err := btcec.NewPrivateKey(btcec.S256())
|
||||
key, err := btcec.NewPrivateKey()
|
||||
if err != nil {
|
||||
t.Errorf("failed to make privKey for %s: %v",
|
||||
msg, err)
|
||||
break
|
||||
}
|
||||
|
||||
pk := (*btcec.PublicKey)(&key.PublicKey).
|
||||
SerializeCompressed()
|
||||
pk := key.PubKey().SerializeCompressed()
|
||||
address, err := btcutil.NewAddressPubKeyHash(
|
||||
btcutil.Hash160(pk), &chaincfg.TestNet3Params)
|
||||
if err != nil {
|
||||
|
@ -740,15 +729,14 @@ func TestSignTxOutput(t *testing.T) {
|
|||
for i := range tx.TxIn {
|
||||
msg := fmt.Sprintf("%d:%d", hashType, i)
|
||||
|
||||
key, err := btcec.NewPrivateKey(btcec.S256())
|
||||
key, err := btcec.NewPrivateKey()
|
||||
if err != nil {
|
||||
t.Errorf("failed to make privKey for %s: %v",
|
||||
msg, err)
|
||||
break
|
||||
}
|
||||
|
||||
pk := (*btcec.PublicKey)(&key.PublicKey).
|
||||
SerializeCompressed()
|
||||
pk := key.PubKey().SerializeCompressed()
|
||||
address, err := btcutil.NewAddressPubKeyHash(
|
||||
btcutil.Hash160(pk), &chaincfg.TestNet3Params)
|
||||
if err != nil {
|
||||
|
@ -822,15 +810,14 @@ func TestSignTxOutput(t *testing.T) {
|
|||
for i := range tx.TxIn {
|
||||
msg := fmt.Sprintf("%d:%d", hashType, i)
|
||||
|
||||
key, err := btcec.NewPrivateKey(btcec.S256())
|
||||
key, err := btcec.NewPrivateKey()
|
||||
if err != nil {
|
||||
t.Errorf("failed to make privKey for %s: %v",
|
||||
msg, err)
|
||||
break
|
||||
}
|
||||
|
||||
pk := (*btcec.PublicKey)(&key.PublicKey).
|
||||
SerializeUncompressed()
|
||||
pk := key.PubKey().SerializeUncompressed()
|
||||
address, err := btcutil.NewAddressPubKey(pk,
|
||||
&chaincfg.TestNet3Params)
|
||||
if err != nil {
|
||||
|
@ -879,15 +866,14 @@ func TestSignTxOutput(t *testing.T) {
|
|||
for i := range tx.TxIn {
|
||||
msg := fmt.Sprintf("%d:%d", hashType, i)
|
||||
|
||||
key, err := btcec.NewPrivateKey(btcec.S256())
|
||||
key, err := btcec.NewPrivateKey()
|
||||
if err != nil {
|
||||
t.Errorf("failed to make privKey for %s: %v",
|
||||
msg, err)
|
||||
break
|
||||
}
|
||||
|
||||
pk := (*btcec.PublicKey)(&key.PublicKey).
|
||||
SerializeUncompressed()
|
||||
pk := key.PubKey().SerializeUncompressed()
|
||||
address, err := btcutil.NewAddressPubKey(pk,
|
||||
&chaincfg.TestNet3Params)
|
||||
if err != nil {
|
||||
|
@ -960,15 +946,14 @@ func TestSignTxOutput(t *testing.T) {
|
|||
for i := range tx.TxIn {
|
||||
msg := fmt.Sprintf("%d:%d", hashType, i)
|
||||
|
||||
key, err := btcec.NewPrivateKey(btcec.S256())
|
||||
key, err := btcec.NewPrivateKey()
|
||||
if err != nil {
|
||||
t.Errorf("failed to make privKey for %s: %v",
|
||||
msg, err)
|
||||
break
|
||||
}
|
||||
|
||||
pk := (*btcec.PublicKey)(&key.PublicKey).
|
||||
SerializeCompressed()
|
||||
pk := key.PubKey().SerializeCompressed()
|
||||
address, err := btcutil.NewAddressPubKey(pk,
|
||||
&chaincfg.TestNet3Params)
|
||||
if err != nil {
|
||||
|
@ -1016,15 +1001,14 @@ func TestSignTxOutput(t *testing.T) {
|
|||
for i := range tx.TxIn {
|
||||
msg := fmt.Sprintf("%d:%d", hashType, i)
|
||||
|
||||
key, err := btcec.NewPrivateKey(btcec.S256())
|
||||
key, err := btcec.NewPrivateKey()
|
||||
if err != nil {
|
||||
t.Errorf("failed to make privKey for %s: %v",
|
||||
msg, err)
|
||||
break
|
||||
}
|
||||
|
||||
pk := (*btcec.PublicKey)(&key.PublicKey).
|
||||
SerializeCompressed()
|
||||
pk := key.PubKey().SerializeCompressed()
|
||||
address, err := btcutil.NewAddressPubKey(pk,
|
||||
&chaincfg.TestNet3Params)
|
||||
if err != nil {
|
||||
|
@ -1097,15 +1081,14 @@ func TestSignTxOutput(t *testing.T) {
|
|||
for i := range tx.TxIn {
|
||||
msg := fmt.Sprintf("%d:%d", hashType, i)
|
||||
|
||||
key1, err := btcec.NewPrivateKey(btcec.S256())
|
||||
key1, err := btcec.NewPrivateKey()
|
||||
if err != nil {
|
||||
t.Errorf("failed to make privKey for %s: %v",
|
||||
msg, err)
|
||||
break
|
||||
}
|
||||
|
||||
pk1 := (*btcec.PublicKey)(&key1.PublicKey).
|
||||
SerializeCompressed()
|
||||
pk1 := key1.PubKey().SerializeCompressed()
|
||||
address1, err := btcutil.NewAddressPubKey(pk1,
|
||||
&chaincfg.TestNet3Params)
|
||||
if err != nil {
|
||||
|
@ -1114,15 +1097,14 @@ func TestSignTxOutput(t *testing.T) {
|
|||
break
|
||||
}
|
||||
|
||||
key2, err := btcec.NewPrivateKey(btcec.S256())
|
||||
key2, err := btcec.NewPrivateKey()
|
||||
if err != nil {
|
||||
t.Errorf("failed to make privKey 2 for %s: %v",
|
||||
msg, err)
|
||||
break
|
||||
}
|
||||
|
||||
pk2 := (*btcec.PublicKey)(&key2.PublicKey).
|
||||
SerializeCompressed()
|
||||
pk2 := key2.PubKey().SerializeCompressed()
|
||||
address2, err := btcutil.NewAddressPubKey(pk2,
|
||||
&chaincfg.TestNet3Params)
|
||||
if err != nil {
|
||||
|
@ -1173,15 +1155,14 @@ func TestSignTxOutput(t *testing.T) {
|
|||
for i := range tx.TxIn {
|
||||
msg := fmt.Sprintf("%d:%d", hashType, i)
|
||||
|
||||
key1, err := btcec.NewPrivateKey(btcec.S256())
|
||||
key1, err := btcec.NewPrivateKey()
|
||||
if err != nil {
|
||||
t.Errorf("failed to make privKey for %s: %v",
|
||||
msg, err)
|
||||
break
|
||||
}
|
||||
|
||||
pk1 := (*btcec.PublicKey)(&key1.PublicKey).
|
||||
SerializeCompressed()
|
||||
pk1 := key1.PubKey().SerializeCompressed()
|
||||
address1, err := btcutil.NewAddressPubKey(pk1,
|
||||
&chaincfg.TestNet3Params)
|
||||
if err != nil {
|
||||
|
@ -1190,15 +1171,14 @@ func TestSignTxOutput(t *testing.T) {
|
|||
break
|
||||
}
|
||||
|
||||
key2, err := btcec.NewPrivateKey(btcec.S256())
|
||||
key2, err := btcec.NewPrivateKey()
|
||||
if err != nil {
|
||||
t.Errorf("failed to make privKey 2 for %s: %v",
|
||||
msg, err)
|
||||
break
|
||||
}
|
||||
|
||||
pk2 := (*btcec.PublicKey)(&key2.PublicKey).
|
||||
SerializeCompressed()
|
||||
pk2 := key2.PubKey().SerializeCompressed()
|
||||
address2, err := btcutil.NewAddressPubKey(pk2,
|
||||
&chaincfg.TestNet3Params)
|
||||
if err != nil {
|
||||
|
@ -1279,15 +1259,14 @@ func TestSignTxOutput(t *testing.T) {
|
|||
for i := range tx.TxIn {
|
||||
msg := fmt.Sprintf("%d:%d", hashType, i)
|
||||
|
||||
key1, err := btcec.NewPrivateKey(btcec.S256())
|
||||
key1, err := btcec.NewPrivateKey()
|
||||
if err != nil {
|
||||
t.Errorf("failed to make privKey for %s: %v",
|
||||
msg, err)
|
||||
break
|
||||
}
|
||||
|
||||
pk1 := (*btcec.PublicKey)(&key1.PublicKey).
|
||||
SerializeCompressed()
|
||||
pk1 := key1.PubKey().SerializeCompressed()
|
||||
address1, err := btcutil.NewAddressPubKey(pk1,
|
||||
&chaincfg.TestNet3Params)
|
||||
if err != nil {
|
||||
|
@ -1296,15 +1275,14 @@ func TestSignTxOutput(t *testing.T) {
|
|||
break
|
||||
}
|
||||
|
||||
key2, err := btcec.NewPrivateKey(btcec.S256())
|
||||
key2, err := btcec.NewPrivateKey()
|
||||
if err != nil {
|
||||
t.Errorf("failed to make privKey 2 for %s: %v",
|
||||
msg, err)
|
||||
break
|
||||
}
|
||||
|
||||
pk2 := (*btcec.PublicKey)(&key2.PublicKey).
|
||||
SerializeCompressed()
|
||||
pk2 := key2.PubKey().SerializeCompressed()
|
||||
address2, err := btcutil.NewAddressPubKey(pk2,
|
||||
&chaincfg.TestNet3Params)
|
||||
if err != nil {
|
||||
|
@ -1635,7 +1613,7 @@ var sigScriptTests = []tstSigScript{
|
|||
func TestSignatureScript(t *testing.T) {
|
||||
t.Parallel()
|
||||
|
||||
privKey, _ := btcec.PrivKeyFromBytes(btcec.S256(), privKeyD)
|
||||
privKey, _ := btcec.PrivKeyFromBytes(privKeyD)
|
||||
|
||||
nexttest:
|
||||
for i := range sigScriptTests {
|
||||
|
|
Loading…
Add table
Reference in a new issue