mirror of
https://github.com/aljazceru/breez-sdk-docs.git
synced 2025-12-17 13:54:20 +01:00
Add React Native snippets
This commit is contained in:
52
snippets/react-native/receive_onchain.ts
Normal file
52
snippets/react-native/receive_onchain.ts
Normal file
@@ -0,0 +1,52 @@
|
||||
import {
|
||||
inProgressSwap,
|
||||
listRefundables,
|
||||
openChannelFee,
|
||||
receiveOnchain,
|
||||
refund
|
||||
} from "@breeztech/react-native-breez-sdk"
|
||||
|
||||
const exampleReceiveOnchain = async () => {
|
||||
// ANCHOR: generate-receive-onchain-address
|
||||
const swapInfo = await receiveOnchain({})
|
||||
|
||||
// Send your funds to the below bitcoin address
|
||||
const address = swapInfo.bitcoinAddress
|
||||
// ANCHOR_END: generate-receive-onchain-address
|
||||
}
|
||||
|
||||
const exampleInProgressSwap = async () => {
|
||||
// ANCHOR: in-progress-swap
|
||||
const swapInfo = await inProgressSwap()
|
||||
// ANCHOR_END: in-progress-swap
|
||||
}
|
||||
|
||||
const exampleListRefundables = async () => {
|
||||
// ANCHOR: list-refundables
|
||||
const refundables = await listRefundables()
|
||||
// ANCHOR_END: list-refundables
|
||||
}
|
||||
|
||||
const exampleRefund = async () => {
|
||||
// ANCHOR: execute-refund
|
||||
const refundables = await listRefundables()
|
||||
const toAddress = "..."
|
||||
const satPerVbyte = 5
|
||||
|
||||
const refundResponse = await refund({
|
||||
swapAddress: refundables[0].bitcoinAddress,
|
||||
toAddress,
|
||||
satPerVbyte
|
||||
})
|
||||
// ANCHOR_END: execute-refund
|
||||
}
|
||||
|
||||
const exampleOpenChannelFee = async () => {
|
||||
// ANCHOR: get-channel-opening-fees
|
||||
const amountMsat = 10000
|
||||
|
||||
const openChannelFeeResponse = await openChannelFee({
|
||||
amountMsat: amountMsat
|
||||
})
|
||||
// ANCHOR_END: get-channel-opening-fees
|
||||
}
|
||||
Reference in New Issue
Block a user