From 47954e95dff860d2a578f7d9f35f3599ac314926 Mon Sep 17 00:00:00 2001 From: Elias Rohrer Date: Fri, 8 Mar 2024 16:43:45 +0100 Subject: [PATCH] Implement `Hash` for `Offer` and `Refund` --- lightning/src/offers/offer.rs | 7 +++++++ lightning/src/offers/refund.rs | 7 +++++++ 2 files changed, 14 insertions(+) diff --git a/lightning/src/offers/offer.rs b/lightning/src/offers/offer.rs index d2be5b056..d71ec2afd 100644 --- a/lightning/src/offers/offer.rs +++ b/lightning/src/offers/offer.rs @@ -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(&self, state: &mut H) { + self.bytes.hash(state); + } +} + impl OfferContents { pub fn chains(&self) -> Vec { self.chains.as_ref().cloned().unwrap_or_else(|| vec![self.implied_chain()]) diff --git a/lightning/src/offers/refund.rs b/lightning/src/offers/refund.rs index db42c7457..5107e31d8 100644 --- a/lightning/src/offers/refund.rs +++ b/lightning/src/offers/refund.rs @@ -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(&self, state: &mut H) { + self.bytes.hash(state); + } +} + impl RefundContents { pub fn description(&self) -> PrintableString { PrintableString(&self.description) -- 2.39.5