Skip to content

Commit bfdfb9d

Browse files
committed
Implement Readable for Bolt12Invoice
A future InvoiceReceived event will include a Bolt12Invoice. Since Event implements Readable, so must Bolt12Invoice.
1 parent 3edbe76 commit bfdfb9d

File tree

1 file changed

+8
-1
lines changed

1 file changed

+8
-1
lines changed

lightning/src/offers/invoice.rs

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -124,7 +124,7 @@ use crate::offers::parse::{Bolt12ParseError, Bolt12SemanticError, ParsedMessage}
124124
use crate::offers::payer::{PAYER_METADATA_TYPE, PayerTlvStream, PayerTlvStreamRef};
125125
use crate::offers::refund::{IV_BYTES as REFUND_IV_BYTES, Refund, RefundContents};
126126
use crate::offers::signer;
127-
use crate::util::ser::{HighZeroBytesDroppedBigSize, Iterable, SeekReadable, WithoutLength, Writeable, Writer};
127+
use crate::util::ser::{HighZeroBytesDroppedBigSize, Iterable, Readable, SeekReadable, WithoutLength, Writeable, Writer};
128128
use crate::util::string::PrintableString;
129129

130130
#[allow(unused_imports)]
@@ -1205,6 +1205,13 @@ impl Writeable for Bolt12Invoice {
12051205
}
12061206
}
12071207

1208+
impl Readable for Bolt12Invoice {
1209+
fn read<R: io::Read>(reader: &mut R) -> Result<Self, DecodeError> {
1210+
let bytes: WithoutLength<Vec<u8>> = Readable::read(reader)?;
1211+
Self::try_from(bytes.0).map_err(|_| DecodeError::InvalidValue)
1212+
}
1213+
}
1214+
12081215
impl Writeable for InvoiceContents {
12091216
fn write<W: Writer>(&self, writer: &mut W) -> Result<(), io::Error> {
12101217
self.as_tlv_stream().write(writer)

0 commit comments

Comments
 (0)