Override correct equals functions (#1621)

* Override correct equals functions

* Remove no longer needed function
This commit is contained in:
Ben Carman 2020-07-06 06:37:19 -05:00 committed by GitHub
parent 60deb25f35
commit 16dd256716
3 changed files with 15 additions and 9 deletions

View file

@ -43,10 +43,13 @@ case class PSBT(
import org.bitcoins.core.psbt.InputPSBTRecord._
import org.bitcoins.core.psbt.PSBTInputKeyId._
// Need to define these so when we compare the PSBTs
// Need to define this so when we compare the PSBTs
// the map lexicographical ordering is enforced
def ==(p: PSBT): Boolean = this.bytes == p.bytes
def !=(p: PSBT): Boolean = !(this == p)
override def equals(other: Any): Boolean =
other match {
case p: PSBT => this.bytes == p.bytes
case _ => other.equals(this)
}
private val inputBytes: ByteVector =
inputMaps.foldLeft(ByteVector.empty)(_ ++ _.bytes)

View file

@ -10,8 +10,11 @@ sealed abstract class ECDigitalSignature {
require(s.signum == 1 || s.signum == 0, s"s must not be negative, got $s")
def hex: String = CryptoBytesUtil.encodeHex(bytes)
def ==(p: ECDigitalSignature): Boolean = this.bytes == p.bytes
def !=(p: ECDigitalSignature): Boolean = !(this == p)
override def equals(other: Any): Boolean =
other match {
case sig: ECDigitalSignature => bytes == sig.bytes
case _ => other.equals(this)
}
def bytes: ByteVector

View file

@ -38,15 +38,15 @@ case class BIP39KeyManager(
password = BIP39Seed.EMPTY_PASSWORD)
}
def ==(km: KeyManager): Boolean =
km match {
override def equals(other: Any): Boolean =
other match {
case bip39Km: BIP39KeyManager =>
mnemonic == bip39Km.mnemonic &&
kmParams == bip39Km.kmParams &&
bip39PasswordOpt == bip39Km.bip39PasswordOpt &&
creationTime.getEpochSecond == bip39Km.creationTime.getEpochSecond
case _: KeyManager =>
km == this
case _ =>
other.equals(this)
}
private val privVersion: ExtKeyPrivVersion =