mirror of
https://github.com/aljazceru/breez-sdk-docs.git
synced 2025-12-17 13:54:20 +01:00
74 lines
1.7 KiB
TypeScript
74 lines
1.7 KiB
TypeScript
import {
|
|
inProgressSwap,
|
|
listRefundables,
|
|
openChannelFee,
|
|
receiveOnchain,
|
|
refund
|
|
} from '@breeztech/react-native-breez-sdk'
|
|
|
|
const exampleReceiveOnchain = async () => {
|
|
// ANCHOR: generate-receive-onchain-address
|
|
try {
|
|
const swapInfo = await receiveOnchain({})
|
|
|
|
// Send your funds to the below bitcoin address
|
|
const address = swapInfo.bitcoinAddress
|
|
console.log(`Minimum amount allowed to deposit in sats: ${swapInfo.minAllowedDeposit}`)
|
|
console.log(`Maximum amount allowed to deposit in sats: ${swapInfo.maxAllowedDeposit}`)
|
|
} catch (err) {
|
|
console.error(err)
|
|
}
|
|
// ANCHOR_END: generate-receive-onchain-address
|
|
}
|
|
|
|
const exampleInProgressSwap = async () => {
|
|
// ANCHOR: in-progress-swap
|
|
try {
|
|
const swapInfo = await inProgressSwap()
|
|
} catch (err) {
|
|
console.error(err)
|
|
}
|
|
// ANCHOR_END: in-progress-swap
|
|
}
|
|
|
|
const exampleListRefundables = async () => {
|
|
// ANCHOR: list-refundables
|
|
try {
|
|
const refundables = await listRefundables()
|
|
} catch (err) {
|
|
console.error(err)
|
|
}
|
|
// ANCHOR_END: list-refundables
|
|
}
|
|
|
|
const exampleRefund = async () => {
|
|
// ANCHOR: execute-refund
|
|
try {
|
|
const refundables = await listRefundables()
|
|
const toAddress = '...'
|
|
const satPerVbyte = 5
|
|
|
|
const refundResponse = await refund({
|
|
swapAddress: refundables[0].bitcoinAddress,
|
|
toAddress,
|
|
satPerVbyte
|
|
})
|
|
} catch (err) {
|
|
console.error(err)
|
|
}
|
|
// ANCHOR_END: execute-refund
|
|
}
|
|
|
|
const exampleOpenChannelFee = async () => {
|
|
// ANCHOR: get-channel-opening-fees
|
|
try {
|
|
const amountMsat = 10000
|
|
const openChannelFeeResponse = await openChannelFee({
|
|
amountMsat
|
|
})
|
|
} catch (err) {
|
|
console.error(err)
|
|
}
|
|
// ANCHOR_END: get-channel-opening-fees
|
|
}
|