mirror of
https://github.com/aljazceru/breez-sdk-docs.git
synced 2025-12-17 13:54:20 +01:00
Add examples for adding extra TLVs to a spontaneous payment
This commit is contained in:
@@ -2,6 +2,6 @@ module main
|
||||
|
||||
go 1.19
|
||||
|
||||
require github.com/breez/breez-sdk-go v0.2.10
|
||||
require github.com/breez/breez-sdk-go v0.2.15
|
||||
|
||||
replace github.com/breez/breez-sdk-go => ./packages/breez-sdk-go
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
package example
|
||||
|
||||
import (
|
||||
"encoding/hex"
|
||||
"log"
|
||||
|
||||
"github.com/breez/breez-sdk-go/breez_sdk"
|
||||
@@ -17,3 +18,22 @@ func SendSpontaneousPayment() {
|
||||
}
|
||||
// ANCHOR_END: send-spontaneous-payment
|
||||
}
|
||||
func SendSpontaneousPaymentWithTlvs() {
|
||||
// ANCHOR: send-spontaneous-payment-with-tlvs
|
||||
value, _ := hex.DecodeString("Hello world!")
|
||||
extraTlvs := []breez_sdk.TlvEntry{
|
||||
breez_sdk.TlvEntry{
|
||||
FieldNumber: uint64(34349334),
|
||||
Value: value,
|
||||
},
|
||||
}
|
||||
sendSpontaneousPaymentRequest := breez_sdk.SendSpontaneousPaymentRequest{
|
||||
NodeId: "...",
|
||||
AmountMsat: uint64(3_000_000),
|
||||
ExtraTlvs: &extraTlvs,
|
||||
}
|
||||
if response, err := sdk.SendSpontaneousPayment(sendSpontaneousPaymentRequest); err == nil {
|
||||
log.Printf("%#v", response)
|
||||
}
|
||||
// ANCHOR_END: send-spontaneous-payment-with-tlvs
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user