@@ -8,47 +8,66 @@ import {
8
8
9
9
const exampleReceiveOnchain = async ( ) => {
10
10
// ANCHOR: generate-receive-onchain-address
11
- const swapInfo = await receiveOnchain ( { } )
11
+ try {
12
+ const swapInfo = await receiveOnchain ( { } )
12
13
13
- // Send your funds to the below bitcoin address
14
- const address = swapInfo . bitcoinAddress
15
- console . log ( `Minimum amount allowed to deposit in sats: ${ swapInfo . minAllowedDeposit } ` )
16
- console . log ( `Maximum amount allowed to deposit in sats: ${ swapInfo . maxAllowedDeposit } ` )
14
+ // Send your funds to the below bitcoin address
15
+ const address = swapInfo . bitcoinAddress
16
+ console . log ( `Minimum amount allowed to deposit in sats: ${ swapInfo . minAllowedDeposit } ` )
17
+ console . log ( `Maximum amount allowed to deposit in sats: ${ swapInfo . maxAllowedDeposit } ` )
18
+ } catch ( err ) {
19
+ console . error ( err )
20
+ }
17
21
// ANCHOR_END: generate-receive-onchain-address
18
22
}
19
23
20
24
const exampleInProgressSwap = async ( ) => {
21
25
// ANCHOR: in-progress-swap
22
- const swapInfo = await inProgressSwap ( )
26
+ try {
27
+ const swapInfo = await inProgressSwap ( )
28
+ } catch ( err ) {
29
+ console . error ( err )
30
+ }
23
31
// ANCHOR_END: in-progress-swap
24
32
}
25
33
26
34
const exampleListRefundables = async ( ) => {
27
35
// ANCHOR: list-refundables
28
- const refundables = await listRefundables ( )
36
+ try {
37
+ const refundables = await listRefundables ( )
38
+ } catch ( err ) {
39
+ console . error ( err )
40
+ }
29
41
// ANCHOR_END: list-refundables
30
42
}
31
43
32
44
const exampleRefund = async ( ) => {
33
45
// ANCHOR: execute-refund
34
- const refundables = await listRefundables ( )
35
- const toAddress = '...'
36
- const satPerVbyte = 5
46
+ try {
47
+ const refundables = await listRefundables ( )
48
+ const toAddress = '...'
49
+ const satPerVbyte = 5
37
50
38
- const refundResponse = await refund ( {
39
- swapAddress : refundables [ 0 ] . bitcoinAddress ,
40
- toAddress,
41
- satPerVbyte
42
- } )
51
+ const refundResponse = await refund ( {
52
+ swapAddress : refundables [ 0 ] . bitcoinAddress ,
53
+ toAddress,
54
+ satPerVbyte
55
+ } )
56
+ } catch ( err ) {
57
+ console . error ( err )
58
+ }
43
59
// ANCHOR_END: execute-refund
44
60
}
45
61
46
62
const exampleOpenChannelFee = async ( ) => {
47
63
// ANCHOR: get-channel-opening-fees
48
- const amountMsat = 10000
49
-
50
- const openChannelFeeResponse = await openChannelFee ( {
51
- amountMsat
52
- } )
64
+ try {
65
+ const amountMsat = 10000
66
+ const openChannelFeeResponse = await openChannelFee ( {
67
+ amountMsat
68
+ } )
69
+ } catch ( err ) {
70
+ console . error ( err )
71
+ }
53
72
// ANCHOR_END: get-channel-opening-fees
54
73
}
0 commit comments