dcrutil: Remove IsForNet from Address interface.

This removes the no longer necessary IsForNet method from the Address
interface and all concrete address implementations.

It also updates the tests accordingly.
This commit is contained in:
Dave Collins 2019-06-14 23:00:06 -05:00
parent 0ba5ac74e5
commit b13eb4511f
No known key found for this signature in database
GPG Key ID: B8904D9D9C93D1F2
2 changed files with 0 additions and 43 deletions

View File

@ -105,10 +105,6 @@ type Address interface {
// hashed to 160 bits from the respective address type.
Hash160() *[ripemd160.Size]byte
// IsForNet returns whether or not the address is associated with the
// passed network.
IsForNet(*chaincfg.Params) bool
// DSA returns the digital signature algorithm for the address.
DSA(*chaincfg.Params) dcrec.SignatureType
@ -237,14 +233,6 @@ func (a *AddressPubKeyHash) ScriptAddress() []byte {
return a.hash[:]
}
// IsForNet returns whether or not the pay-to-pubkey-hash address is associated
// with the passed network.
func (a *AddressPubKeyHash) IsForNet(net *chaincfg.Params) bool {
return a.netID == net.PubKeyHashAddrID ||
a.netID == net.PKHEdwardsAddrID ||
a.netID == net.PKHSchnorrAddrID
}
// 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.
@ -341,12 +329,6 @@ func (a *AddressScriptHash) ScriptAddress() []byte {
return a.hash[:]
}
// IsForNet returns whether or not the pay-to-script-hash address is associated
// with the passed network.
func (a *AddressScriptHash) IsForNet(net *chaincfg.Params) bool {
return a.netID == net.ScriptHashAddrID
}
// 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.
@ -473,12 +455,6 @@ func (a *AddressSecpPubKey) Hash160() *[ripemd160.Size]byte {
return array
}
// IsForNet returns whether or not the pay-to-pubkey address is associated
// with the passed network.
func (a *AddressSecpPubKey) IsForNet(net *chaincfg.Params) bool {
return a.pubKeyHashID == net.PubKeyHashAddrID
}
// String returns the hex-encoded human-readable string for the pay-to-pubkey
// address. This is not the same as calling EncodeAddress.
func (a *AddressSecpPubKey) String() string {
@ -586,12 +562,6 @@ func (a *AddressEdwardsPubKey) Hash160() *[ripemd160.Size]byte {
return array
}
// IsForNet returns whether or not the pay-to-pubkey address is associated
// with the passed network.
func (a *AddressEdwardsPubKey) IsForNet(net *chaincfg.Params) bool {
return a.pubKeyHashID == net.PKHEdwardsAddrID
}
// String returns the hex-encoded human-readable string for the pay-to-pubkey
// address. This is not the same as calling EncodeAddress.
func (a *AddressEdwardsPubKey) String() string {
@ -684,12 +654,6 @@ func (a *AddressSecSchnorrPubKey) Hash160() *[ripemd160.Size]byte {
return array
}
// IsForNet returns whether or not the pay-to-pubkey address is associated
// with the passed network.
func (a *AddressSecSchnorrPubKey) IsForNet(net *chaincfg.Params) bool {
return a.pubKeyHashID == net.PubKeyHashAddrID
}
// String returns the hex-encoded human-readable string for the pay-to-pubkey
// address. This is not the same as calling EncodeAddress.
func (a *AddressSecSchnorrPubKey) String() string {

View File

@ -592,13 +592,6 @@ func TestAddresses(t *testing.T) {
return
}
}
// Ensure the address is for the expected network.
if !decoded.IsForNet(test.net) {
t.Errorf("%v: calculated network does not match expected",
test.name)
return
}
}
if !test.valid {