Add examples for adding extra TLVs to a spontaneous payment

This commit is contained in:
Ross Savage
2024-01-29 17:11:25 +01:00
parent 60552e8b35
commit 37a46fa4d6
23 changed files with 290 additions and 55 deletions

View File

@@ -34,7 +34,7 @@ kotlin {
}
val commonMain by getting {
dependencies {
implementation("technology.breez:breez-sdk-kmp:0.2.10")
implementation("technology.breez:breez-sdk-kmp:0.2.15")
}
}
}

View File

@@ -14,4 +14,20 @@ class SendSpontaneousPayment {
}
// ANCHOR_END: send-spontaneous-payment
}
fun send_spontaneous_payment_with_tlvs(sdk: BlockingBreezServices) {
// ANCHOR: send-spontaneous-payment-with-tlvs
val nodeId = "..."
val amountMsat = 3_000_000.toULong()
val extraTlvs = listOf<TlvEntry>(
TlvEntry(34_349_334.toULong(), "Hello world!".encodeToByteArray().asUByteArray().toList())
)
try {
val response = sdk.sendSpontaneousPayment(
SendSpontaneousPaymentRequest(nodeId, amountMsat, extraTlvs))
} catch (e: Exception) {
// handle error
}
// ANCHOR_END: send-spontaneous-payment-with-tlvs
}
}