@@ -161,13 +161,12 @@ impl<'a> InvoiceBuilder<'a, ExplicitSigningPubkey> {
161
161
created_at : Duration , payment_hash : PaymentHash
162
162
) -> Result < Self , SemanticError > {
163
163
let amount_msats = Self :: check_amount_msats ( invoice_request) ?;
164
+ let signing_pubkey = invoice_request. contents . inner . offer . signing_pubkey ( ) ;
164
165
let contents = InvoiceContents :: ForOffer {
165
166
invoice_request : invoice_request. contents . clone ( ) ,
166
- fields : InvoiceFields {
167
- payment_paths, created_at, relative_expiry : None , payment_hash, amount_msats,
168
- fallbacks : None , features : Bolt12InvoiceFeatures :: empty ( ) ,
169
- signing_pubkey : invoice_request. contents . inner . offer . signing_pubkey ( ) ,
170
- } ,
167
+ fields : Self :: fields (
168
+ payment_paths, created_at, payment_hash, amount_msats, signing_pubkey
169
+ ) ,
171
170
} ;
172
171
173
172
Self :: new ( & invoice_request. bytes , contents, None )
@@ -177,13 +176,12 @@ impl<'a> InvoiceBuilder<'a, ExplicitSigningPubkey> {
177
176
refund : & ' a Refund , payment_paths : Vec < ( BlindedPath , BlindedPayInfo ) > , created_at : Duration ,
178
177
payment_hash : PaymentHash , signing_pubkey : PublicKey
179
178
) -> Result < Self , SemanticError > {
179
+ let amount_msats = refund. amount_msats ( ) ;
180
180
let contents = InvoiceContents :: ForRefund {
181
181
refund : refund. contents . clone ( ) ,
182
- fields : InvoiceFields {
183
- payment_paths, created_at, relative_expiry : None , payment_hash,
184
- amount_msats : refund. amount_msats ( ) , fallbacks : None ,
185
- features : Bolt12InvoiceFeatures :: empty ( ) , signing_pubkey,
186
- } ,
182
+ fields : Self :: fields (
183
+ payment_paths, created_at, payment_hash, amount_msats, signing_pubkey
184
+ ) ,
187
185
} ;
188
186
189
187
Self :: new ( & refund. bytes , contents, None )
@@ -196,13 +194,12 @@ impl<'a> InvoiceBuilder<'a, DerivedSigningPubkey> {
196
194
created_at : Duration , payment_hash : PaymentHash , keys : KeyPair
197
195
) -> Result < Self , SemanticError > {
198
196
let amount_msats = Self :: check_amount_msats ( invoice_request) ?;
197
+ let signing_pubkey = invoice_request. contents . inner . offer . signing_pubkey ( ) ;
199
198
let contents = InvoiceContents :: ForOffer {
200
199
invoice_request : invoice_request. contents . clone ( ) ,
201
- fields : InvoiceFields {
202
- payment_paths, created_at, relative_expiry : None , payment_hash, amount_msats,
203
- fallbacks : None , features : Bolt12InvoiceFeatures :: empty ( ) ,
204
- signing_pubkey : invoice_request. contents . inner . offer . signing_pubkey ( ) ,
205
- } ,
200
+ fields : Self :: fields (
201
+ payment_paths, created_at, payment_hash, amount_msats, signing_pubkey
202
+ ) ,
206
203
} ;
207
204
208
205
Self :: new ( & invoice_request. bytes , contents, Some ( keys) )
@@ -212,13 +209,13 @@ impl<'a> InvoiceBuilder<'a, DerivedSigningPubkey> {
212
209
refund : & ' a Refund , payment_paths : Vec < ( BlindedPath , BlindedPayInfo ) > , created_at : Duration ,
213
210
payment_hash : PaymentHash , keys : KeyPair ,
214
211
) -> Result < Self , SemanticError > {
212
+ let amount_msats = refund. amount_msats ( ) ;
213
+ let signing_pubkey = keys. public_key ( ) ;
215
214
let contents = InvoiceContents :: ForRefund {
216
215
refund : refund. contents . clone ( ) ,
217
- fields : InvoiceFields {
218
- payment_paths, created_at, relative_expiry : None , payment_hash,
219
- amount_msats : refund. amount_msats ( ) , fallbacks : None ,
220
- features : Bolt12InvoiceFeatures :: empty ( ) , signing_pubkey : keys. public_key ( ) ,
221
- } ,
216
+ fields : Self :: fields (
217
+ payment_paths, created_at, payment_hash, amount_msats, signing_pubkey
218
+ ) ,
222
219
} ;
223
220
224
221
Self :: new ( & refund. bytes , contents, Some ( keys) )
@@ -240,6 +237,16 @@ impl<'a, S: SigningPubkeyStrategy> InvoiceBuilder<'a, S> {
240
237
}
241
238
}
242
239
240
+ fn fields (
241
+ payment_paths : Vec < ( BlindedPath , BlindedPayInfo ) > , created_at : Duration ,
242
+ payment_hash : PaymentHash , amount_msats : u64 , signing_pubkey : PublicKey
243
+ ) -> InvoiceFields {
244
+ InvoiceFields {
245
+ payment_paths, created_at, relative_expiry : None , payment_hash, amount_msats,
246
+ fallbacks : None , features : Bolt12InvoiceFeatures :: empty ( ) , signing_pubkey,
247
+ }
248
+ }
249
+
243
250
fn new (
244
251
invreq_bytes : & ' a Vec < u8 > , contents : InvoiceContents , keys : Option < KeyPair >
245
252
) -> Result < Self , SemanticError > {
0 commit comments