Skip to content

Commit 2209926

Browse files
committed
f - replace invoice_code with invoice_node_id
1 parent ccffd4d commit 2209926

File tree

1 file changed

+5
-13
lines changed

1 file changed

+5
-13
lines changed

lightning/src/offers/invoice.rs

+5-13
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,8 @@ impl<'a> InvoiceBuilder<'a> {
7575
fields: InvoiceFields {
7676
paths, payinfo, created_at, relative_expiry: None, payment_hash,
7777
amount_msats: invoice_request.amount_msats(), fallbacks: None,
78-
features: Bolt12InvoiceFeatures::empty(), code: None,
78+
features: Bolt12InvoiceFeatures::empty(),
79+
signing_pubkey: invoice_request.contents.offer.signing_pubkey(),
7980
},
8081
},
8182
})
@@ -182,7 +183,7 @@ impl<'a> UnsignedInvoice<'a> {
182183
let mut bytes = Vec::new();
183184
unsigned_tlv_stream.write(&mut bytes).unwrap();
184185

185-
let pubkey = self.invoice.signing_pubkey();
186+
let pubkey = self.invoice.fields().signing_pubkey;
186187
let signature = merkle::sign_message(sign, SIGNATURE_TAG, &bytes, pubkey)?;
187188

188189
// Append the signature TLV record to the bytes.
@@ -194,7 +195,7 @@ impl<'a> UnsignedInvoice<'a> {
194195
Ok(Invoice {
195196
bytes,
196197
contents: self.invoice,
197-
signature: Some(signature),
198+
signature,
198199
})
199200
}
200201
}
@@ -376,15 +377,6 @@ impl InvoiceContents {
376377
}
377378
}
378379

379-
fn signing_pubkey(&self) -> PublicKey {
380-
match self {
381-
InvoiceContents::ForOffer { invoice_request, .. } => {
382-
invoice_request.offer.signing_pubkey()
383-
},
384-
InvoiceContents::ForRefund { .. } => unreachable!(),
385-
}
386-
}
387-
388380
fn fields(&self) -> &InvoiceFields {
389381
match self {
390382
InvoiceContents::ForOffer { fields, .. } => fields,
@@ -426,7 +418,7 @@ impl InvoiceFields {
426418
amount: Some(self.amount_msats),
427419
fallbacks: self.fallbacks.as_ref(),
428420
features,
429-
code: self.code.as_ref(),
421+
node_id: Some(&self.signing_pubkey),
430422
}
431423
}
432424
}

0 commit comments

Comments
 (0)