comparing NetworkUncheck addresses

Signed-off-by: Harshil Jani <harshiljani2002@gmail.com>

implementation of PartialEq<Address> for Address<NetworkUnchecked>

Signed-off-by: Harshil Jani <harshiljani2002@gmail.com>
This commit is contained in:
Harshil Jani 2023-03-28 12:20:11 +05:30
parent dc72dfb9f2
commit 046bda321b
1 changed files with 11 additions and 0 deletions

View File

@ -1057,6 +1057,17 @@ impl Address<NetworkUnchecked> {
pub fn assume_checked(self) -> Address { Address::new(self.network, self.payload) } pub fn assume_checked(self) -> Address { Address::new(self.network, self.payload) }
} }
// For NetworkUnchecked , it compare Addresses and if network and payload matches then return true.
impl PartialEq<Address<NetworkUnchecked>> for Address {
fn eq(&self, other: &Address<NetworkUnchecked>) -> bool {
self.network == other.network && self.payload == other.payload
}
}
impl PartialEq<Address> for Address<NetworkUnchecked> {
fn eq(&self, other: &Address) -> bool { other == self }
}
impl From<Address> for script::ScriptBuf { impl From<Address> for script::ScriptBuf {
fn from(a: Address) -> Self { a.script_pubkey() } fn from(a: Address) -> Self { a.script_pubkey() }
} }