-
Notifications
You must be signed in to change notification settings - Fork 2.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
25 changed files
with
288 additions
and
236 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
190 changes: 95 additions & 95 deletions
190
btcutil/address_test.go → btcutil/address/address_test.go
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
module github.com/btcsuite/btcd/btcutil/address | ||
|
||
require ( | ||
github.com/btcsuite/btcd/btcec/v2 v2.1.3 | ||
github.com/btcsuite/btcd/chaincfg v1.0.0 | ||
github.com/btcsuite/btcd/wire v1.0.0 | ||
golang.org/x/crypto v0.0.0-20220210151621-f4118a5b28e2 | ||
) | ||
|
||
require ( | ||
github.com/btcsuite/btcd/chaincfg/chainhash v1.0.1 // indirect | ||
github.com/decred/dcrd/dcrec/secp256k1/v4 v4.0.1 // indirect | ||
) | ||
|
||
// TODO(guggero): Remove this as soon as we have a tagged version of chaincfg. | ||
replace github.com/btcsuite/btcd/chaincfg => ../../chaincfg | ||
|
||
// TODO(guggero): Remove this as soon as we have a tagged version of wire. | ||
replace github.com/btcsuite/btcd/wire => ../../wire | ||
|
||
go 1.17 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
github.com/btcsuite/btcd/btcec/v2 v2.1.3 h1:xM/n3yIhHAhHy04z4i43C8p4ehixJZMsnrVJkgl+MTE= | ||
github.com/btcsuite/btcd/btcec/v2 v2.1.3/go.mod h1:ctjw4H1kknNJmRN4iP1R7bTQ+v3GJkZBd6mui8ZsAZE= | ||
github.com/btcsuite/btcd/chaincfg/chainhash v1.0.0/go.mod h1:7SFka0XMvUgj3hfZtydOrQY2mwhPclbT2snogU7SQQc= | ||
github.com/btcsuite/btcd/chaincfg/chainhash v1.0.1 h1:q0rUy8C/TYNBQS1+CGKw68tLOFYSNEs0TFnxxnS9+4U= | ||
github.com/btcsuite/btcd/chaincfg/chainhash v1.0.1/go.mod h1:7SFka0XMvUgj3hfZtydOrQY2mwhPclbT2snogU7SQQc= | ||
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/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= | ||
golang.org/x/crypto v0.0.0-20220210151621-f4118a5b28e2 h1:XdAboW3BNMv9ocSCOk/u1MFioZGzCNkiJZ19v9Oe3Ig= | ||
golang.org/x/crypto v0.0.0-20220210151621-f4118a5b28e2/go.mod h1:IxCIyHEi3zRg3s0A5j5BB6A9Jmi73HwBIUl50j+osU4= | ||
golang.org/x/net v0.0.0-20211112202133-69e39bad7dc2/go.mod h1:9nx3DQGgdP8bBQD5qxJ1jj9UTztislL4KSBs9R2vV5Y= | ||
golang.org/x/sys v0.0.0-20201119102817-f84b799fce68/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= | ||
golang.org/x/sys v0.0.0-20210423082822-04245dca01da/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= | ||
golang.org/x/sys v0.0.0-20210615035016-665e8c7367d1/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= | ||
golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo= | ||
golang.org/x/text v0.3.6/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ= | ||
golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ= |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,134 @@ | ||
// 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. | ||
|
||
/* | ||
This test file is part of the btcutil package rather than than the | ||
btcutil_test package so it can bridge access to the internals to properly test | ||
cases which are either not possible or can't reliably be tested via the public | ||
interface. The functions are only exported while the tests are being run. | ||
*/ | ||
|
||
package address | ||
|
||
import ( | ||
"github.com/btcsuite/btcd/btcec/v2" | ||
"github.com/btcsuite/btcd/btcutil/address/base58" | ||
"github.com/btcsuite/btcd/btcutil/address/bech32" | ||
"golang.org/x/crypto/ripemd160" | ||
) | ||
|
||
// TstAddressPubKeyHash makes an AddressPubKeyHash, setting the | ||
// unexported fields with the parameters hash and netID. | ||
func TstAddressPubKeyHash(hash [ripemd160.Size]byte, | ||
netID byte) *AddressPubKeyHash { | ||
|
||
return &AddressPubKeyHash{ | ||
hash: hash, | ||
netID: netID, | ||
} | ||
} | ||
|
||
// TstAddressScriptHash makes an AddressScriptHash, setting the | ||
// unexported fields with the parameters hash and netID. | ||
func TstAddressScriptHash(hash [ripemd160.Size]byte, | ||
netID byte) *AddressScriptHash { | ||
|
||
return &AddressScriptHash{ | ||
hash: hash, | ||
netID: netID, | ||
} | ||
} | ||
|
||
// TstAddressWitnessPubKeyHash creates an AddressWitnessPubKeyHash, initiating | ||
// the fields as given. | ||
func TstAddressWitnessPubKeyHash(version byte, program [20]byte, | ||
hrp string) *AddressWitnessPubKeyHash { | ||
|
||
return &AddressWitnessPubKeyHash{ | ||
AddressSegWit{ | ||
hrp: hrp, | ||
witnessVersion: version, | ||
witnessProgram: program[:], | ||
}, | ||
} | ||
} | ||
|
||
// TstAddressWitnessScriptHash creates an AddressWitnessScriptHash, initiating | ||
// the fields as given. | ||
func TstAddressWitnessScriptHash(version byte, program [32]byte, | ||
hrp string) *AddressWitnessScriptHash { | ||
|
||
return &AddressWitnessScriptHash{ | ||
AddressSegWit{ | ||
hrp: hrp, | ||
witnessVersion: version, | ||
witnessProgram: program[:], | ||
}, | ||
} | ||
} | ||
|
||
// TstAddressTaproot creates an AddressTaproot, initiating the fields as given. | ||
func TstAddressTaproot(version byte, program [32]byte, | ||
hrp string) *AddressTaproot { | ||
|
||
return &AddressTaproot{ | ||
AddressSegWit{ | ||
hrp: hrp, | ||
witnessVersion: version, | ||
witnessProgram: program[:], | ||
}, | ||
} | ||
} | ||
|
||
// TstAddressPubKey makes an AddressPubKey, setting the unexported fields with | ||
// the parameters. | ||
func TstAddressPubKey(serializedPubKey []byte, pubKeyFormat PubKeyFormat, | ||
netID byte) *AddressPubKey { | ||
|
||
pubKey, _ := btcec.ParsePubKey(serializedPubKey) | ||
return &AddressPubKey{ | ||
pubKeyFormat: pubKeyFormat, | ||
pubKey: pubKey, | ||
pubKeyHashID: netID, | ||
} | ||
} | ||
|
||
// TstAddressSAddr returns the expected script address bytes for | ||
// P2PKH and P2SH bitcoin addresses. | ||
func TstAddressSAddr(addr string) []byte { | ||
decoded := base58.Decode(addr) | ||
return decoded[1 : 1+ripemd160.Size] | ||
} | ||
|
||
// TstAddressSegwitSAddr returns the expected witness program bytes for | ||
// bech32 encoded P2WPKH and P2WSH bitcoin addresses. | ||
func TstAddressSegwitSAddr(addr string) []byte { | ||
_, data, err := bech32.Decode(addr) | ||
if err != nil { | ||
return []byte{} | ||
} | ||
|
||
// First byte is version, rest is base 32 encoded data. | ||
data, err = bech32.ConvertBits(data[1:], 5, 8, false) | ||
if err != nil { | ||
return []byte{} | ||
} | ||
return data | ||
} | ||
|
||
// TstAddressTaprootSAddr returns the expected witness program bytes for a | ||
// bech32m encoded P2TR bitcoin address. | ||
func TstAddressTaprootSAddr(addr string) []byte { | ||
_, data, err := bech32.Decode(addr) | ||
if err != nil { | ||
return []byte{} | ||
} | ||
|
||
// First byte is version, rest is base 32 encoded data. | ||
data, err = bech32.ConvertBits(data[1:], 5, 8, false) | ||
if err != nil { | ||
return []byte{} | ||
} | ||
return data | ||
} |
Oops, something went wrong.