Skip to content

Commit

Permalink
offer: be able to create an offer with description
Browse files Browse the repository at this point in the history
Signed-off-by: Vincenzo Palazzo <[email protected]>
  • Loading branch information
vincenzopalazzo committed Dec 16, 2024
1 parent 7cfdb96 commit f20e5c3
Showing 1 changed file with 14 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -271,4 +271,18 @@ data class NodeParams(
// If we add a new feature that we would like to use by default, we will need to explicitly create a new offer.
return OfferTypes.Offer.createBlindedOffer(amount = null, description = null, this, trampolineNodeId, Features.empty, sessionKey)
}

/**
* FIXME(vincenzopalazzo): Add docs
*/
fun offer(amount: MilliSatoshi?, description: String?, trampolineNodeId: PublicKey): Pair<OfferTypes.Offer, PrivateKey> {
// We generate a deterministic blindingSecret based on:
// - a custom tag indicating that this is used in the Bolt 12 context
// - our trampoline node, which is used as an introduction node for the offer's blinded path
// - our private key, which ensures that nobody else can generate the same blindingSecret
// FIXME: there is some problem if I change the string prefix? yes I tried and the LSP was rejecting my code
val blindingSecret = PrivateKey(Crypto.sha256("bolt 12 default offer".toByteArray(Charsets.UTF_8).byteVector() + trampolineNodeId.value + nodePrivateKey.value).byteVector32())
// FIXME: it should be included some additional feature
return OfferTypes.Offer.createBlindedOffer(amount = amount, description = description, this, trampolineNodeId, Features.empty, blindingSecret)
}
}

0 comments on commit f20e5c3

Please sign in to comment.