Skip to content

Commit d7b6d0d

Browse files
committed
f - replace invoice_code with invoice_node_id
1 parent 16ead4f commit d7b6d0d

File tree

1 file changed

+5
-13
lines changed

1 file changed

+5
-13
lines changed

lightning/src/offers/invoice.rs

Lines changed: 5 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,8 @@ impl<'a> InvoiceBuilder<'a> {
8585
invoice_request: invoice_request.contents.clone(),
8686
fields: InvoiceFields {
8787
paths, payinfo, created_at, relative_expiry: None, payment_hash, amount_msats,
88-
fallbacks: None, features: Bolt12InvoiceFeatures::empty(), code: None,
88+
fallbacks: None, features: Bolt12InvoiceFeatures::empty(),
89+
signing_pubkey: invoice_request.contents.offer.signing_pubkey(),
8990
},
9091
},
9192
})
@@ -192,7 +193,7 @@ impl<'a> UnsignedInvoice<'a> {
192193
let mut bytes = Vec::new();
193194
unsigned_tlv_stream.write(&mut bytes).unwrap();
194195

195-
let pubkey = self.invoice.signing_pubkey();
196+
let pubkey = self.invoice.fields().signing_pubkey;
196197
let signature = merkle::sign_message(sign, SIGNATURE_TAG, &bytes, pubkey)?;
197198

198199
// Append the signature TLV record to the bytes.
@@ -204,7 +205,7 @@ impl<'a> UnsignedInvoice<'a> {
204205
Ok(Invoice {
205206
bytes,
206207
contents: self.invoice,
207-
signature: Some(signature),
208+
signature,
208209
})
209210
}
210211
}
@@ -386,15 +387,6 @@ impl InvoiceContents {
386387
}
387388
}
388389

389-
fn signing_pubkey(&self) -> PublicKey {
390-
match self {
391-
InvoiceContents::ForOffer { invoice_request, .. } => {
392-
invoice_request.offer.signing_pubkey()
393-
},
394-
InvoiceContents::ForRefund { .. } => unreachable!(),
395-
}
396-
}
397-
398390
fn fields(&self) -> &InvoiceFields {
399391
match self {
400392
InvoiceContents::ForOffer { fields, .. } => fields,
@@ -436,7 +428,7 @@ impl InvoiceFields {
436428
amount: Some(self.amount_msats),
437429
fallbacks: self.fallbacks.as_ref(),
438430
features,
439-
code: self.code.as_ref(),
431+
node_id: Some(&self.signing_pubkey),
440432
}
441433
}
442434
}

0 commit comments

Comments
 (0)