Add a String function to each address.
This allows the addresses to be treated as fmt.Stringer for easy printing. There is no difference between String and EncodeAddress (in fact String just calls EncodeAddress).
This commit is contained in:
parent
8c022bae3a
commit
8928b361d4
1 changed files with 14 additions and 0 deletions
14
address.go
14
address.go
|
@ -180,6 +180,13 @@ func (a *AddressPubKeyHash) Net() btcwire.BitcoinNet {
|
|||
return a.net
|
||||
}
|
||||
|
||||
// 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()
|
||||
}
|
||||
|
||||
// AddressScriptHash is an Address for a pay-to-script-hash (P2SH)
|
||||
// transaction.
|
||||
type AddressScriptHash struct {
|
||||
|
@ -239,3 +246,10 @@ func (a *AddressScriptHash) ScriptAddress() []byte {
|
|||
func (a *AddressScriptHash) Net() btcwire.BitcoinNet {
|
||||
return a.net
|
||||
}
|
||||
|
||||
// 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()
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue