Skip to content

Commit 2daa125

Browse files
offer: be able to create an offer with description
Signed-off-by: Vincenzo Palazzo <vincenzopalazzodev@gmail.com>
1 parent 86f8e44 commit 2daa125

1 file changed

Lines changed: 14 additions & 0 deletions

File tree

  • modules/core/src/commonMain/kotlin/fr/acinq/lightning

modules/core/src/commonMain/kotlin/fr/acinq/lightning/NodeParams.kt

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -271,4 +271,18 @@ data class NodeParams(
271271
// If we add a new feature that we would like to use by default, we will need to explicitly create a new offer.
272272
return OfferTypes.Offer.createBlindedOffer(amount = null, description = null, this, trampolineNodeId, Features.empty, blindingSecret)
273273
}
274+
275+
/**
276+
* FIXME(vincenzopalazzo): Add docs
277+
*/
278+
fun offer(amount: MilliSatoshi?, description: String?, trampolineNodeId: PublicKey): Pair<OfferTypes.Offer, PrivateKey> {
279+
// We generate a deterministic blindingSecret based on:
280+
// - a custom tag indicating that this is used in the Bolt 12 context
281+
// - our trampoline node, which is used as an introduction node for the offer's blinded path
282+
// - our private key, which ensures that nobody else can generate the same blindingSecret
283+
// FIXME: there is some problem if I change the string prefix? yes I tried and the LSP was rejecting my code
284+
val blindingSecret = PrivateKey(Crypto.sha256("bolt 12 default offer".toByteArray(Charsets.UTF_8).byteVector() + trampolineNodeId.value + nodePrivateKey.value).byteVector32())
285+
// FIXME: it should be included some additional feature
286+
return OfferTypes.Offer.createBlindedOffer(amount = amount, description = description, this, trampolineNodeId, Features.empty, blindingSecret)
287+
}
274288
}

0 commit comments

Comments
 (0)