Implement Hash for Offer and Refund

This commit is contained in:
Elias Rohrer 2024-03-08 16:43:45 +01:00
parent 3eeb8b82a5
commit 47954e95df
No known key found for this signature in database
GPG key ID: 36153082BDF676FD
2 changed files with 14 additions and 0 deletions

View file

@ -80,6 +80,7 @@ use bitcoin::blockdata::constants::ChainHash;
use bitcoin::network::constants::Network;
use bitcoin::secp256k1::{KeyPair, PublicKey, Secp256k1, self};
use core::convert::TryFrom;
use core::hash::{Hash, Hasher};
use core::num::NonZeroU64;
use core::ops::Deref;
use core::str::FromStr;
@ -591,6 +592,12 @@ impl PartialEq for Offer {
impl Eq for Offer {}
impl Hash for Offer {
fn hash<H: Hasher>(&self, state: &mut H) {
self.bytes.hash(state);
}
}
impl OfferContents {
pub fn chains(&self) -> Vec<ChainHash> {
self.chains.as_ref().cloned().unwrap_or_else(|| vec![self.implied_chain()])

View file

@ -85,6 +85,7 @@ use bitcoin::blockdata::constants::ChainHash;
use bitcoin::network::constants::Network;
use bitcoin::secp256k1::{PublicKey, Secp256k1, self};
use core::convert::TryFrom;
use core::hash::{Hash, Hasher};
use core::ops::Deref;
use core::str::FromStr;
use core::time::Duration;
@ -546,6 +547,12 @@ impl PartialEq for Refund {
impl Eq for Refund {}
impl Hash for Refund {
fn hash<H: Hasher>(&self, state: &mut H) {
self.bytes.hash(state);
}
}
impl RefundContents {
pub fn description(&self) -> PrintableString {
PrintableString(&self.description)