2014-01-03 17:10:25 +01:00
|
|
|
// Copyright (c) 2013, 2014 Conformal Systems LLC.
|
|
|
|
// Use of this source code is governed by an ISC
|
|
|
|
// license that can be found in the LICENSE file.
|
|
|
|
|
|
|
|
package btcutil
|
|
|
|
|
|
|
|
import (
|
|
|
|
"bytes"
|
2014-01-04 21:58:37 +01:00
|
|
|
"encoding/hex"
|
2014-01-03 17:10:25 +01:00
|
|
|
"errors"
|
2014-07-03 02:29:48 +02:00
|
|
|
|
|
|
|
"code.google.com/p/go.crypto/ripemd160"
|
2014-01-04 21:58:37 +01:00
|
|
|
"github.com/conformal/btcec"
|
2014-05-28 00:06:00 +02:00
|
|
|
"github.com/conformal/btcnet"
|
2014-01-03 17:10:25 +01:00
|
|
|
"github.com/conformal/btcwire"
|
|
|
|
)
|
|
|
|
|
|
|
|
var (
|
|
|
|
// ErrChecksumMismatch describes an error where decoding failed due
|
|
|
|
// to a bad checksum.
|
|
|
|
ErrChecksumMismatch = errors.New("checksum mismatch")
|
|
|
|
|
2014-05-28 00:06:00 +02:00
|
|
|
// ErrUnknownAddressType describes an error where an address can not
|
|
|
|
// decoded as a specific address type due to the string encoding
|
|
|
|
// begining with an identifier byte unknown to any standard or
|
|
|
|
// registered (via btcnet.Register) network.
|
|
|
|
ErrUnknownAddressType = errors.New("unknown address type")
|
|
|
|
|
|
|
|
// ErrAddressCollision describes an error where an address can not
|
|
|
|
// be uniquely determined as either a pay-to-pubkey-hash or
|
|
|
|
// pay-to-script-hash address since the leading identifier is used for
|
|
|
|
// describing both address kinds, but for different networks. Rather
|
|
|
|
// than assuming or defaulting to one or the other, this error is
|
|
|
|
// returned and the caller must decide how to decode the address.
|
|
|
|
ErrAddressCollision = errors.New("address collision")
|
2014-01-03 17:10:25 +01:00
|
|
|
)
|
|
|
|
|
2014-01-05 19:54:59 +01:00
|
|
|
// encodeAddress returns a human-readable payment address given a ripemd160 hash
|
2014-05-28 00:06:00 +02:00
|
|
|
// and netID which encodes the bitcoin network and address type. It is used
|
2014-01-05 19:54:59 +01:00
|
|
|
// in both pay-to-pubkey-hash (P2PKH) and pay-to-script-hash (P2SH) address
|
|
|
|
// encoding.
|
|
|
|
func encodeAddress(hash160 []byte, netID byte) string {
|
2014-05-28 00:06:00 +02:00
|
|
|
// Format is 1 byte for a network and address class (i.e. P2PKH vs
|
|
|
|
// P2SH), 20 bytes for a RIPEMD160 hash, and 4 bytes of checksum.
|
|
|
|
b := make([]byte, 0, 1+ripemd160.Size+4)
|
|
|
|
b = append(b, netID)
|
|
|
|
b = append(b, hash160...)
|
|
|
|
cksum := btcwire.DoubleSha256(b)[:4]
|
|
|
|
b = append(b, cksum...)
|
2014-01-05 19:54:59 +01:00
|
|
|
return Base58Encode(b)
|
|
|
|
}
|
|
|
|
|
2014-01-03 17:10:25 +01:00
|
|
|
// Address is an interface type for any type of destination a transaction
|
|
|
|
// output may spend to. This includes pay-to-pubkey (P2PK), pay-to-pubkey-hash
|
|
|
|
// (P2PKH), and pay-to-script-hash (P2SH). Address is designed to be generic
|
|
|
|
// enough that other kinds of addresses may be added in the future without
|
|
|
|
// changing the decoding and encoding API.
|
|
|
|
type Address interface {
|
2014-06-13 03:11:24 +02:00
|
|
|
// String returns the string encoding of the transaction output
|
|
|
|
// destination.
|
|
|
|
//
|
|
|
|
// Please note that String differs subtly from EncodeAddress: String
|
|
|
|
// will return the value as a string without any conversion, while
|
|
|
|
// EncodeAddress may convert destination types (for example,
|
|
|
|
// converting pubkeys to P2PKH addresses) before encoding as a
|
|
|
|
// payment address string.
|
|
|
|
String() string
|
|
|
|
|
|
|
|
// EncodeAddress returns the string encoding of the payment address
|
|
|
|
// associated with the Address value. See the comment on String
|
|
|
|
// for how this method differs from String.
|
2014-01-03 17:10:25 +01:00
|
|
|
EncodeAddress() string
|
|
|
|
|
|
|
|
// ScriptAddress returns the raw bytes of the address to be used
|
|
|
|
// when inserting the address into a txout's script.
|
|
|
|
ScriptAddress() []byte
|
2014-02-26 20:51:49 +01:00
|
|
|
|
|
|
|
// IsForNet returns whether or not the address is associated with the
|
|
|
|
// passed bitcoin network.
|
2014-05-28 00:06:00 +02:00
|
|
|
IsForNet(*btcnet.Params) bool
|
2014-01-03 17:10:25 +01:00
|
|
|
}
|
|
|
|
|
2014-03-19 02:11:24 +01:00
|
|
|
// DecodeAddress decodes the string encoding of an address and returns
|
2014-01-03 17:10:25 +01:00
|
|
|
// the Address if addr is a valid encoding for a known address type.
|
2014-03-19 02:18:44 +01:00
|
|
|
//
|
|
|
|
// The bitcoin network the address is associated with is extracted if possible.
|
|
|
|
// When the address does not encode the network, such as in the case of a raw
|
|
|
|
// public key, the address will be associated with the passed defaultNet.
|
2014-05-28 00:06:00 +02:00
|
|
|
func DecodeAddress(addr string, defaultNet *btcnet.Params) (Address, error) {
|
2014-03-19 02:18:44 +01:00
|
|
|
// Serialized public keys are either 65 bytes (130 hex chars) if
|
|
|
|
// uncompressed/hybrid or 33 bytes (66 hex chars) if compressed.
|
|
|
|
if len(addr) == 130 || len(addr) == 66 {
|
|
|
|
serializedPubKey, err := hex.DecodeString(addr)
|
|
|
|
if err != nil {
|
|
|
|
return nil, err
|
|
|
|
}
|
|
|
|
return NewAddressPubKey(serializedPubKey, defaultNet)
|
|
|
|
}
|
2014-01-03 17:10:25 +01:00
|
|
|
|
|
|
|
// Switch on decoded length to determine the type.
|
2014-03-19 02:18:44 +01:00
|
|
|
decoded := Base58Decode(addr)
|
2014-01-03 17:10:25 +01:00
|
|
|
switch len(decoded) {
|
|
|
|
case 1 + ripemd160.Size + 4: // P2PKH or P2SH
|
|
|
|
// Verify hash checksum. Checksum is calculated as the first
|
|
|
|
// four bytes of double SHA256 of the network byte and hash.
|
|
|
|
tosum := decoded[:ripemd160.Size+1]
|
|
|
|
cksum := btcwire.DoubleSha256(tosum)[:4]
|
|
|
|
if !bytes.Equal(cksum, decoded[len(decoded)-4:]) {
|
|
|
|
return nil, ErrChecksumMismatch
|
|
|
|
}
|
|
|
|
|
2014-05-28 00:06:00 +02:00
|
|
|
netID := decoded[0]
|
|
|
|
isP2PKH := btcnet.IsPubKeyHashAddrID(netID)
|
|
|
|
isP2SH := btcnet.IsScriptHashAddrID(netID)
|
|
|
|
switch hash160 := decoded[1 : ripemd160.Size+1]; {
|
|
|
|
case isP2PKH && isP2SH:
|
|
|
|
return nil, ErrAddressCollision
|
|
|
|
case isP2PKH:
|
|
|
|
return newAddressPubKeyHash(hash160, netID)
|
|
|
|
case isP2SH:
|
|
|
|
return newAddressScriptHashFromHash(hash160, netID)
|
|
|
|
default:
|
|
|
|
return nil, ErrUnknownAddressType
|
2014-01-03 17:10:25 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
default:
|
|
|
|
return nil, errors.New("decoded address is of unknown size")
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// AddressPubKeyHash is an Address for a pay-to-pubkey-hash (P2PKH)
|
|
|
|
// transaction.
|
|
|
|
type AddressPubKeyHash struct {
|
2014-02-26 20:51:49 +01:00
|
|
|
hash [ripemd160.Size]byte
|
|
|
|
netID byte
|
2014-01-03 17:10:25 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
// NewAddressPubKeyHash returns a new AddressPubKeyHash. pkHash must
|
2014-03-29 01:29:30 +01:00
|
|
|
// be 20 bytes.
|
2014-05-28 00:06:00 +02:00
|
|
|
func NewAddressPubKeyHash(pkHash []byte, net *btcnet.Params) (*AddressPubKeyHash, error) {
|
|
|
|
return newAddressPubKeyHash(pkHash, net.PubKeyHashAddrID)
|
|
|
|
}
|
|
|
|
|
|
|
|
// newAddressPubKeyHash is the internal API to create a pubkey hash address
|
|
|
|
// with a known leading identifier byte for a network, rather than looking
|
|
|
|
// it up through its parameters. This is useful when creating a new address
|
|
|
|
// structure from a string encoding where the identifer byte is already
|
|
|
|
// known.
|
|
|
|
func newAddressPubKeyHash(pkHash []byte, netID byte) (*AddressPubKeyHash, error) {
|
2014-01-03 17:10:25 +01:00
|
|
|
// Check for a valid pubkey hash length.
|
|
|
|
if len(pkHash) != ripemd160.Size {
|
|
|
|
return nil, errors.New("pkHash must be 20 bytes")
|
|
|
|
}
|
|
|
|
|
2014-02-26 20:51:49 +01:00
|
|
|
addr := &AddressPubKeyHash{netID: netID}
|
|
|
|
copy(addr.hash[:], pkHash)
|
|
|
|
return addr, nil
|
|
|
|
}
|
|
|
|
|
|
|
|
// EncodeAddress returns the string encoding of a pay-to-pubkey-hash
|
|
|
|
// address. Part of the Address interface.
|
|
|
|
func (a *AddressPubKeyHash) EncodeAddress() string {
|
|
|
|
return encodeAddress(a.hash[:], a.netID)
|
2014-01-03 17:10:25 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
// ScriptAddress returns the bytes to be included in a txout script to pay
|
|
|
|
// to a pubkey hash. Part of the Address interface.
|
|
|
|
func (a *AddressPubKeyHash) ScriptAddress() []byte {
|
|
|
|
return a.hash[:]
|
|
|
|
}
|
|
|
|
|
2014-02-26 20:51:49 +01:00
|
|
|
// IsForNet returns whether or not the pay-to-pubkey-hash address is associated
|
|
|
|
// with the passed bitcoin network.
|
2014-05-28 00:06:00 +02:00
|
|
|
func (a *AddressPubKeyHash) IsForNet(net *btcnet.Params) bool {
|
|
|
|
return a.netID == net.PubKeyHashAddrID
|
2014-01-03 17:10:25 +01:00
|
|
|
}
|
|
|
|
|
2014-01-05 20:47:23 +01:00
|
|
|
// String returns a human-readable string for the pay-to-pubkey-hash address.
|
|
|
|
// This is equivalent to calling EncodeAddress, but is provided so the type can
|
|
|
|
// be used as a fmt.Stringer.
|
|
|
|
func (a *AddressPubKeyHash) String() string {
|
|
|
|
return a.EncodeAddress()
|
|
|
|
}
|
|
|
|
|
2014-04-20 22:01:48 +02:00
|
|
|
// Hash160 returns the underlying array of the pubkey hash. This can be useful
|
|
|
|
// when an array is more appropiate than a slice (for example, when used as map
|
|
|
|
// keys).
|
|
|
|
func (a *AddressPubKeyHash) Hash160() *[ripemd160.Size]byte {
|
|
|
|
return &a.hash
|
|
|
|
}
|
|
|
|
|
2014-01-03 17:10:25 +01:00
|
|
|
// AddressScriptHash is an Address for a pay-to-script-hash (P2SH)
|
|
|
|
// transaction.
|
|
|
|
type AddressScriptHash struct {
|
2014-02-26 20:51:49 +01:00
|
|
|
hash [ripemd160.Size]byte
|
|
|
|
netID byte
|
2014-01-03 17:10:25 +01:00
|
|
|
}
|
|
|
|
|
2014-05-28 00:06:00 +02:00
|
|
|
// NewAddressScriptHash returns a new AddressScriptHash.
|
|
|
|
func NewAddressScriptHash(serializedScript []byte, net *btcnet.Params) (*AddressScriptHash, error) {
|
2014-01-03 17:10:25 +01:00
|
|
|
scriptHash := Hash160(serializedScript)
|
2014-05-28 00:06:00 +02:00
|
|
|
return newAddressScriptHashFromHash(scriptHash, net.ScriptHashAddrID)
|
2014-01-03 17:10:25 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
// NewAddressScriptHashFromHash returns a new AddressScriptHash. scriptHash
|
2014-03-29 01:29:30 +01:00
|
|
|
// must be 20 bytes.
|
2014-05-28 00:06:00 +02:00
|
|
|
func NewAddressScriptHashFromHash(scriptHash []byte, net *btcnet.Params) (*AddressScriptHash, error) {
|
|
|
|
return newAddressScriptHashFromHash(scriptHash, net.ScriptHashAddrID)
|
|
|
|
}
|
|
|
|
|
|
|
|
// newAddressScriptHashFromHash is the internal API to create a script hash
|
|
|
|
// address with a known leading identifier byte for a network, rather than
|
|
|
|
// looking it up through its parameters. This is useful when creating a new
|
|
|
|
// address structure from a string encoding where the identifer byte is already
|
|
|
|
// known.
|
|
|
|
func newAddressScriptHashFromHash(scriptHash []byte, netID byte) (*AddressScriptHash, error) {
|
2014-01-03 17:10:25 +01:00
|
|
|
// Check for a valid script hash length.
|
|
|
|
if len(scriptHash) != ripemd160.Size {
|
|
|
|
return nil, errors.New("scriptHash must be 20 bytes")
|
|
|
|
}
|
|
|
|
|
2014-02-26 20:51:49 +01:00
|
|
|
addr := &AddressScriptHash{netID: netID}
|
|
|
|
copy(addr.hash[:], scriptHash)
|
|
|
|
return addr, nil
|
|
|
|
}
|
|
|
|
|
|
|
|
// EncodeAddress returns the string encoding of a pay-to-script-hash
|
|
|
|
// address. Part of the Address interface.
|
|
|
|
func (a *AddressScriptHash) EncodeAddress() string {
|
|
|
|
return encodeAddress(a.hash[:], a.netID)
|
2014-01-03 17:10:25 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
// ScriptAddress returns the bytes to be included in a txout script to pay
|
|
|
|
// to a script hash. Part of the Address interface.
|
|
|
|
func (a *AddressScriptHash) ScriptAddress() []byte {
|
|
|
|
return a.hash[:]
|
|
|
|
}
|
|
|
|
|
2014-02-26 20:51:49 +01:00
|
|
|
// IsForNet returns whether or not the pay-to-script-hash address is associated
|
|
|
|
// with the passed bitcoin network.
|
2014-05-28 00:06:00 +02:00
|
|
|
func (a *AddressScriptHash) IsForNet(net *btcnet.Params) bool {
|
|
|
|
return a.netID == net.ScriptHashAddrID
|
2014-01-03 17:10:25 +01:00
|
|
|
}
|
2014-01-05 20:47:23 +01:00
|
|
|
|
|
|
|
// String returns a human-readable string for the pay-to-script-hash address.
|
|
|
|
// This is equivalent to calling EncodeAddress, but is provided so the type can
|
|
|
|
// be used as a fmt.Stringer.
|
|
|
|
func (a *AddressScriptHash) String() string {
|
|
|
|
return a.EncodeAddress()
|
|
|
|
}
|
2014-01-04 21:58:37 +01:00
|
|
|
|
2014-04-20 22:01:48 +02:00
|
|
|
// Hash160 returns the underlying array of the script hash. This can be useful
|
|
|
|
// when an array is more appropiate than a slice (for example, when used as map
|
|
|
|
// keys).
|
|
|
|
func (a *AddressScriptHash) Hash160() *[ripemd160.Size]byte {
|
|
|
|
return &a.hash
|
|
|
|
}
|
|
|
|
|
2014-01-04 21:58:37 +01:00
|
|
|
// PubKeyFormat describes what format to use for a pay-to-pubkey address.
|
|
|
|
type PubKeyFormat int
|
|
|
|
|
|
|
|
const (
|
|
|
|
// PKFUncompressed indicates the pay-to-pubkey address format is an
|
|
|
|
// uncompressed public key.
|
|
|
|
PKFUncompressed PubKeyFormat = iota
|
|
|
|
|
|
|
|
// 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.
|
|
|
|
type AddressPubKey struct {
|
|
|
|
pubKeyFormat PubKeyFormat
|
|
|
|
pubKey *btcec.PublicKey
|
2014-05-28 00:06:00 +02:00
|
|
|
pubKeyHashID byte
|
2014-01-04 21:58:37 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
// NewAddressPubKey returns a new AddressPubKey which represents a pay-to-pubkey
|
|
|
|
// address. The serializedPubKey parameter must be a valid pubkey and can be
|
2014-03-29 01:29:30 +01:00
|
|
|
// uncompressed, compressed, or hybrid.
|
2014-05-28 00:06:00 +02:00
|
|
|
func NewAddressPubKey(serializedPubKey []byte, net *btcnet.Params) (*AddressPubKey, error) {
|
2014-01-04 21:58:37 +01:00
|
|
|
pubKey, err := btcec.ParsePubKey(serializedPubKey, btcec.S256())
|
|
|
|
if err != nil {
|
|
|
|
return nil, err
|
|
|
|
}
|
|
|
|
|
|
|
|
// Set the format of the pubkey. This probably should be returned
|
|
|
|
// from btcec, but do it here to avoid API churn. We already know the
|
|
|
|
// pubkey is valid since it parsed above, so it's safe to simply examine
|
|
|
|
// the leading byte to get the format.
|
|
|
|
pkFormat := PKFUncompressed
|
|
|
|
switch serializedPubKey[0] {
|
2014-05-28 00:06:00 +02:00
|
|
|
case 0x02, 0x03:
|
2014-01-04 21:58:37 +01:00
|
|
|
pkFormat = PKFCompressed
|
2014-05-28 00:06:00 +02:00
|
|
|
case 0x06, 0x07:
|
2014-01-04 21:58:37 +01:00
|
|
|
pkFormat = PKFHybrid
|
|
|
|
}
|
|
|
|
|
2014-02-26 20:51:49 +01:00
|
|
|
return &AddressPubKey{
|
|
|
|
pubKeyFormat: pkFormat,
|
2014-05-28 00:06:00 +02:00
|
|
|
pubKey: pubKey,
|
|
|
|
pubKeyHashID: net.PubKeyHashAddrID,
|
2014-02-26 20:51:49 +01:00
|
|
|
}, nil
|
2014-01-04 21:58:37 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
// serialize returns the serialization of the public key according to the
|
|
|
|
// format associated with the address.
|
|
|
|
func (a *AddressPubKey) serialize() []byte {
|
|
|
|
switch a.pubKeyFormat {
|
|
|
|
default:
|
|
|
|
fallthrough
|
|
|
|
case PKFUncompressed:
|
2014-05-28 00:06:00 +02:00
|
|
|
return a.pubKey.SerializeUncompressed()
|
2014-01-04 21:58:37 +01:00
|
|
|
|
|
|
|
case PKFCompressed:
|
2014-05-28 00:06:00 +02:00
|
|
|
return a.pubKey.SerializeCompressed()
|
2014-01-04 21:58:37 +01:00
|
|
|
|
|
|
|
case PKFHybrid:
|
2014-05-28 00:06:00 +02:00
|
|
|
return a.pubKey.SerializeHybrid()
|
2014-01-04 21:58:37 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// EncodeAddress returns the string encoding of the public key as a
|
|
|
|
// pay-to-pubkey-hash. Note that the public key format (uncompressed,
|
|
|
|
// compressed, etc) will change the resulting address. This is expected since
|
|
|
|
// pay-to-pubkey-hash is a hash of the serialized public key which obviously
|
|
|
|
// differs with the format. At the time of this writing, most Bitcoin addresses
|
|
|
|
// are pay-to-pubkey-hash constructed from the uncompressed public key.
|
|
|
|
//
|
|
|
|
// Part of the Address interface.
|
|
|
|
func (a *AddressPubKey) EncodeAddress() string {
|
2014-05-28 00:06:00 +02:00
|
|
|
return encodeAddress(Hash160(a.serialize()), a.pubKeyHashID)
|
2014-01-04 21:58:37 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
// ScriptAddress returns the bytes to be included in a txout script to pay
|
|
|
|
// to a public key. Setting the public key format will affect the output of
|
|
|
|
// this function accordingly. Part of the Address interface.
|
|
|
|
func (a *AddressPubKey) ScriptAddress() []byte {
|
|
|
|
return a.serialize()
|
|
|
|
}
|
|
|
|
|
2014-02-26 20:51:49 +01:00
|
|
|
// IsForNet returns whether or not the pay-to-pubkey address is associated
|
|
|
|
// with the passed bitcoin network.
|
2014-05-28 00:06:00 +02:00
|
|
|
func (a *AddressPubKey) IsForNet(net *btcnet.Params) bool {
|
|
|
|
return a.pubKeyHashID == net.PubKeyHashAddrID
|
2014-01-04 21:58:37 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
// String returns the hex-encoded human-readable string for the pay-to-pubkey
|
|
|
|
// address. This is not the same as calling EncodeAddress.
|
|
|
|
func (a *AddressPubKey) String() string {
|
|
|
|
return hex.EncodeToString(a.serialize())
|
|
|
|
}
|
|
|
|
|
2014-04-12 19:02:54 +02:00
|
|
|
// Format returns the format (uncompressed, compressed, etc) of the
|
2014-01-04 21:58:37 +01:00
|
|
|
// pay-to-pubkey address.
|
|
|
|
func (a *AddressPubKey) Format() PubKeyFormat {
|
|
|
|
return a.pubKeyFormat
|
|
|
|
}
|
|
|
|
|
|
|
|
// SetFormat sets the format (uncompressed, compressed, etc) of the
|
|
|
|
// pay-to-pubkey address.
|
|
|
|
func (a *AddressPubKey) SetFormat(pkFormat PubKeyFormat) {
|
|
|
|
a.pubKeyFormat = pkFormat
|
|
|
|
}
|
|
|
|
|
|
|
|
// AddressPubKeyHash returns the pay-to-pubkey address converted to a
|
|
|
|
// pay-to-pubkey-hash address. Note that the public key format (uncompressed,
|
|
|
|
// compressed, etc) will change the resulting address. This is expected since
|
|
|
|
// pay-to-pubkey-hash is a hash of the serialized public key which obviously
|
|
|
|
// differs with the format. At the time of this writing, most Bitcoin addresses
|
|
|
|
// are pay-to-pubkey-hash constructed from the uncompressed public key.
|
|
|
|
func (a *AddressPubKey) AddressPubKeyHash() *AddressPubKeyHash {
|
2014-05-28 00:06:00 +02:00
|
|
|
addr := &AddressPubKeyHash{netID: a.pubKeyHashID}
|
2014-02-26 20:51:49 +01:00
|
|
|
copy(addr.hash[:], Hash160(a.serialize()))
|
2014-01-04 21:58:37 +01:00
|
|
|
return addr
|
|
|
|
}
|
2014-03-19 02:29:32 +01:00
|
|
|
|
2014-04-24 02:23:43 +02:00
|
|
|
// PubKey returns the underlying public key for the address.
|
|
|
|
func (a *AddressPubKey) PubKey() *btcec.PublicKey {
|
|
|
|
return a.pubKey
|
|
|
|
}
|