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

@@ -1,4 +1,7 @@
import { sendSpontaneousPayment } from '@breeztech/react-native-breez-sdk'
import {
sendSpontaneousPayment,
type TlvEntry
} from '@breeztech/react-native-breez-sdk'
const exampleSendSpontaneousPayment = async () => {
// ANCHOR: send-spontaneous-payment
@@ -10,3 +13,26 @@ const exampleSendSpontaneousPayment = async () => {
})
// ANCHOR_END: send-spontaneous-payment
}
const stringToBytes = (str: string): number[] => {
const bytes: number[] = []
for (let i = 0; i < str.length; ++i) {
bytes.push(str.charCodeAt(i))
}
return bytes
}
const exampleSendSpontaneousPaymentWithTlvs = async () => {
// ANCHOR: send-spontaneous-payment-with-tlvs
const nodeId = '...'
const extraTlvs: TlvEntry[] = [
{ fieldNumber: 34349334, value: stringToBytes('Hello world!') }
]
const sendPaymentResponse = await sendSpontaneousPayment({
nodeId,
amountMsat: 3000000,
extraTlvs
})
// ANCHOR_END: send-spontaneous-payment-with-tlvs
}

View File

@@ -714,10 +714,10 @@
"@babel/helper-validator-identifier" "^7.22.20"
to-fast-properties "^2.0.0"
"@breeztech/react-native-breez-sdk@0.2.10":
version "0.2.10"
resolved "https://registry.yarnpkg.com/@breeztech/react-native-breez-sdk/-/react-native-breez-sdk-0.2.10.tgz#072b00f57028b5276c600a462cbcaac93d3dee22"
integrity sha512-81wtbkKGxhDaIweIQkD+LLDUL7WTtbI3qEb9vx4Itiu1hGzM8Q2RlYNF5R1jh2m4wdYKUKMWSBd3O4VRnywf1Q==
"@breeztech/react-native-breez-sdk@0.2.15":
version "0.2.15"
resolved "https://registry.yarnpkg.com/@breeztech/react-native-breez-sdk/-/react-native-breez-sdk-0.2.15.tgz#0a415747e94b08f0dbbca8aae23f2d4231881db3"
integrity sha512-VxT4wdZCyDrhZBe6heHJKUJc1nbVJ4Y0qbOm1B+LJa6JOq0YDooUFnbtHMq1PHQ3xviwuM1pCzAco0orWqnvDA==
"@esbuild/android-arm64@0.18.20":
version "0.18.20"