@@ -265,7 +265,6 @@ impl Offer {
265
265
self . send_invoice . as_ref ( )
266
266
}
267
267
268
- #[ cfg( test) ]
269
268
fn as_bytes ( & self ) -> & [ u8 ] {
270
269
& self . bytes
271
270
}
@@ -363,8 +362,8 @@ impl_writeable!(OnionMessagePath, { node_id, encrypted_recipient_data });
363
362
364
363
type Empty = ( ) ;
365
364
366
- /// An offer parsed from a bech32-encoded string as a TLV stream and the corresponding bytes. The
367
- /// latter is used to compute the offer id .
365
+ /// An ` offer` parsed from a bech32-encoded string as a TLV stream and the corresponding bytes. The
366
+ /// latter is used to reflect fields in an `invoice_request`, some of which may be unknown .
368
367
struct ParsedOffer ( OfferTlvStream , Vec < u8 > ) ;
369
368
370
369
/// Error when parsing a bech32 encoded message using [`str::parse`].
@@ -434,7 +433,7 @@ impl TryFrom<ParsedOffer> for Offer {
434
433
let ParsedOffer ( OfferTlvStream {
435
434
chains, metadata, currency, amount, description, features, absolute_expiry, paths,
436
435
issuer, quantity_min, quantity_max, node_id, send_invoice,
437
- } , data ) = offer;
436
+ } , bytes ) = offer;
438
437
439
438
let supported_chains = [
440
439
genesis_block ( Network :: Bitcoin ) . block_hash ( ) ,
@@ -499,10 +498,8 @@ impl TryFrom<ParsedOffer> for Offer {
499
498
500
499
let send_invoice = send_invoice. map ( |_| SendInvoice ) ;
501
500
502
- let id = merkle:: root_hash ( & data) ;
503
-
504
501
Ok ( Offer {
505
- id , chains, metadata, amount, description, features, absolute_expiry, issuer, paths,
502
+ bytes , chains, metadata, amount, description, features, absolute_expiry, issuer, paths,
506
503
quantity_min, quantity_max, node_id, send_invoice,
507
504
} )
508
505
}
@@ -537,7 +534,7 @@ impl FromStr for ParsedOffer {
537
534
impl core:: fmt:: Display for Offer {
538
535
fn fmt ( & self , f : & mut core:: fmt:: Formatter ) -> Result < ( ) , core:: fmt:: Error > {
539
536
use bitcoin:: bech32:: ToBase32 ;
540
- let data = self . to_bytes ( ) . to_base32 ( ) ;
537
+ let data = self . as_bytes ( ) . to_base32 ( ) ;
541
538
bech32:: encode_without_checksum_to_fmt ( f, OFFER_BECH32_HRP , data) . expect ( "HRP is valid" ) . unwrap ( ) ;
542
539
543
540
Ok ( ( ) )
0 commit comments