Skip to content

Commit 47954e9

Browse files
committed
Implement Hash for Offer and Refund
1 parent 3eeb8b8 commit 47954e9

File tree

2 files changed

+14
-0
lines changed

2 files changed

+14
-0
lines changed

lightning/src/offers/offer.rs

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -80,6 +80,7 @@ use bitcoin::blockdata::constants::ChainHash;
8080
use bitcoin::network::constants::Network;
8181
use bitcoin::secp256k1::{KeyPair, PublicKey, Secp256k1, self};
8282
use core::convert::TryFrom;
83+
use core::hash::{Hash, Hasher};
8384
use core::num::NonZeroU64;
8485
use core::ops::Deref;
8586
use core::str::FromStr;
@@ -591,6 +592,12 @@ impl PartialEq for Offer {
591592

592593
impl Eq for Offer {}
593594

595+
impl Hash for Offer {
596+
fn hash<H: Hasher>(&self, state: &mut H) {
597+
self.bytes.hash(state);
598+
}
599+
}
600+
594601
impl OfferContents {
595602
pub fn chains(&self) -> Vec<ChainHash> {
596603
self.chains.as_ref().cloned().unwrap_or_else(|| vec![self.implied_chain()])

lightning/src/offers/refund.rs

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -85,6 +85,7 @@ use bitcoin::blockdata::constants::ChainHash;
8585
use bitcoin::network::constants::Network;
8686
use bitcoin::secp256k1::{PublicKey, Secp256k1, self};
8787
use core::convert::TryFrom;
88+
use core::hash::{Hash, Hasher};
8889
use core::ops::Deref;
8990
use core::str::FromStr;
9091
use core::time::Duration;
@@ -546,6 +547,12 @@ impl PartialEq for Refund {
546547

547548
impl Eq for Refund {}
548549

550+
impl Hash for Refund {
551+
fn hash<H: Hasher>(&self, state: &mut H) {
552+
self.bytes.hash(state);
553+
}
554+
}
555+
549556
impl RefundContents {
550557
pub fn description(&self) -> PrintableString {
551558
PrintableString(&self.description)

0 commit comments

Comments
 (0)