From efa8f2d2b2bfad7bf1fde657fc4eb6874fd0ecc4 Mon Sep 17 00:00:00 2001 From: Ross Savage Date: Sun, 2 Jul 2023 22:03:51 +0200 Subject: [PATCH 1/3] Indentation fixes --- src/guide/getting_started.md | 30 ++++++++-------- src/guide/lnurl_auth.md | 6 ++-- src/guide/lnurl_pay.md | 6 ++-- src/guide/lnurl_withdraw.md | 6 ++-- src/guide/payments.md | 10 +++--- src/guide/recieve_onchain.md | 70 ++++++++++++++++++++++++++++++------ src/guide/send_onchain.md | 23 ++++++------ 7 files changed, 102 insertions(+), 49 deletions(-) diff --git a/src/guide/getting_started.md b/src/guide/getting_started.md index b2fb59e..c052dcc 100644 --- a/src/guide/getting_started.md +++ b/src/guide/getting_started.md @@ -75,12 +75,12 @@ The first step is to register a new node ## Registering a new node ```swift do { - let seed = try mnemonicToSeed(phrase: ""); - let invite_code = ; + let seed = try mnemonicToSeed(phrase: ""); + let invite_code = ; - // register_node takes either greenlight credentials (certifate & key) or invite code. - // At this example we are using the invite code option. - let credentials = try registerNode(network: Network.bitcoin, seed: seed, inviteCode: inviteCode); + // register_node takes either greenlight credentials (certifate & key) or invite code. + // At this example we are using the invite code option. + let credentials = try registerNode(network: Network.bitcoin, seed: seed, inviteCode: inviteCode); } catch SdkError.Error(let message) { print(message) } @@ -88,8 +88,8 @@ do { ## Recovering an existing node ```swift - let seed = try mnemonicToSeed(phrase: ""); - let credentials = try recoverNode(network: Network.bitcoin, seed: seed); +let seed = try mnemonicToSeed(phrase: ""); +let credentials = try recoverNode(network: Network.bitcoin, seed: seed); ``` Once the credentials are retrieved they should be saved in a secured storage. @@ -100,9 +100,9 @@ The next step is to initialize the SDK and start the node: // SDK events listener class SDKListener: EventListener { - func onEvent(e: BreezEvent) { - print("received event ", e); - } + func onEvent(e: BreezEvent) { + print("received event ", e); + } } // Create the default config @@ -113,8 +113,8 @@ config.apiKey = "your API key"; config.workingDir = "path to an existing directory"; do { - let sdkServices = try initServices(config: config, seed: seed, creds: credentials, listener: SDKListener()); - try sdkServices.start(); + let sdkServices = try initServices(config: config, seed: seed, creds: credentials, listener: SDKListener()); + try sdkServices.start(); } catch SdkError.Error(let message) { print(message) } @@ -124,9 +124,9 @@ At any point we can fetch our balance from the Greenlight node: ```swift do { - let nodeInfo = try sdkServices.nodeInfo(); - let lnBalance = nodeInfo.channelsBalanceMsat; - let onchainBalance = nodeInfo.onchainBalanceMsat; + let nodeInfo = try sdkServices.nodeInfo(); + let lnBalance = nodeInfo.channelsBalanceMsat; + let onchainBalance = nodeInfo.onchainBalanceMsat; } catch SdkError.Error(let message) { print(message) } diff --git a/src/guide/lnurl_auth.md b/src/guide/lnurl_auth.md index 7c94489..a3f2b2e 100644 --- a/src/guide/lnurl_auth.md +++ b/src/guide/lnurl_auth.md @@ -34,8 +34,8 @@ if let Ok(LnUrlAuth{data: ad}) = parse(lnurl_auth_url).await { let lnurlAuthUrl = "lnurl1dp68gurn8ghj7mr0vdskc6r0wd6z7mrww4excttvdankjm3lw3skw0tvdankjm3xdvcn6vtp8q6n2dfsx5mrjwtrxdjnqvtzv56rzcnyv3jrxv3sxqmkyenrvv6kve3exv6nqdtyv43nqcmzvdsnvdrzx33rsenxx5unqc3cxgeqgntfgu"; do { - let inputType = try parseInput(s: lnurlAuthUrl) - if case .lnUrlAuth(data) = inputType { + let inputType = try parseInput(s: lnurlAuthUrl) + if case .lnUrlAuth(data) = inputType { let result = try sdk.lnurlAuth(data) switch result { case .ok: @@ -43,7 +43,7 @@ do { case .errorStatus(data): print("Failed to authenticate") } - } + } } catch SdkError.Error(let message) { print(message) } diff --git a/src/guide/lnurl_pay.md b/src/guide/lnurl_pay.md index 732dd1d..baa6546 100644 --- a/src/guide/lnurl_pay.md +++ b/src/guide/lnurl_pay.md @@ -31,11 +31,11 @@ if let Ok(LnUrlPay{data: pd}) = parse(lnurl_pay_url).await { // lnurl1dp68gurn8ghj7mr0vdskc6r0wd6z7mrww4excttsv9un7um9wdekjmmw84jxywf5x43rvv35xgmr2enrxanr2cfcvsmnwe3jxcukvde48qukgdec89snwde3vfjxvepjxpjnjvtpxd3kvdnxx5crxwpjvyunsephsz36jf let lnurlPayUrl = "lightning@address.com"; do { - let inputType = try parseInput(s: input) - if case .lnUrlPay(data) = inputType { + let inputType = try parseInput(s: input) + if case .lnUrlPay(data) = inputType { let amountSats = inputType.minSendable; try sdk.payLnurl(amountSats: amountSats, "comment", reqData: data) - } + } } catch SdkError.Error(let message) { print(message) } diff --git a/src/guide/lnurl_withdraw.md b/src/guide/lnurl_withdraw.md index 1677f0c..3a4855f 100644 --- a/src/guide/lnurl_withdraw.md +++ b/src/guide/lnurl_withdraw.md @@ -30,12 +30,12 @@ if let Ok(LnUrlWithdraw{data: wd}) = parse(lnurl_withdraw_url).await { let lnurlWithdrawUrl = "lnurl1dp68gurn8ghj7mr0vdskc6r0wd6z7mrww4exctthd96xserjv9mn7um9wdekjmmw843xxwpexdnxzen9vgunsvfexq6rvdecx93rgdmyxcuxverrvcursenpxvukzv3c8qunsdecx33nzwpnvg6ryc3hv93nzvecxgcxgwp3h33lxk"; do { - let inputType = try parseInput(s: input) - if case .lnUrlWithdraw(data) = inputType { + let inputType = try parseInput(s: input) + if case .lnUrlWithdraw(data) = inputType { let amountSat = data.minWithdrawable; let description = "Test withdraw" try sdk.withdrawLnurl(amountSats: amountSat, description: "comment", reqData: data) - } + } } catch SdkError.Error(let message) { print(message) } diff --git a/src/guide/payments.md b/src/guide/payments.md index 303848b..a1350a0 100644 --- a/src/guide/payments.md +++ b/src/guide/payments.md @@ -25,14 +25,14 @@ sdk.send_payment(node_id.into(), Some(3000)).await?;
Swift
- +
## Receiving Lightning Payments Breez SDK doesn't require you to open a channel and set up your inbound liquidity. Breez SDK automatically connects your node to the LSP peer and you can now receive payments: ```swift do { - let invoice = try sdk.receivePayment(amountSats: 3000, description: "Invoice for 3000 sats") + let invoice = try sdk.receivePayment(amountSats: 3000, description: "Invoice for 3000 sats") } catch SdkError.Error(let message) { print(message) } @@ -42,7 +42,7 @@ do { ```swift let bolt11 = "..."; do { - let payment = try sdk.sendPayment(bolt11: bolt11, amountSats: 3000) + let payment = try sdk.sendPayment(bolt11: bolt11, amountSats: 3000) } catch SdkError.Error(let message) { print(message) } @@ -52,12 +52,12 @@ do { ```swift let nodeId = "..."; do { - let payment = try sdk.sendSpontaneousPayment(nodeId: nodeId, amountSats: 3000) + let payment = try sdk.sendSpontaneousPayment(nodeId: nodeId, amountSats: 3000) } catch SdkError.Error(let message) { print(message) } ``` - +
diff --git a/src/guide/recieve_onchain.md b/src/guide/recieve_onchain.md index 1d6cd84..7a35c5a 100644 --- a/src/guide/recieve_onchain.md +++ b/src/guide/recieve_onchain.md @@ -8,7 +8,7 @@ There are cases when you have funds in some bitcoin address and you would like t ```rust,no_run let swap_info = sdk.receive_onchain().await?; -// Send your funds to the bellow bitcoin address +// Send your funds to the below bitcoin address let address = swap_info.bitcoin_address; ``` @@ -42,10 +42,10 @@ sdk.refund(refundable.bitcoin_address, destination_address, sat_per_vbyte).await ```swift do { - let swapInfo = try sdk.receiveOnchain(); + let swapInfo = try sdk.receiveOnchain(); - // Send your funds to the bellow bitcoin address - let address = swapInfo.bitcoinAddress; + // Send your funds to the below bitcoin address + let address = swapInfo.bitcoinAddress; } catch SdkError.Error(let message) { print(message) } @@ -55,7 +55,7 @@ Once you've sent the funds to the above address, the SDK will monitor this addre ```swift do { - let swapInfo = try sdk.inProgressSwap() + let swapInfo = try sdk.inProgressSwap() } catch SdkError.Error(let message) { print(message) } @@ -70,7 +70,7 @@ In order to execute a refund, you need to supply an on-chain address to where th ```swift do { - let refundables = try sdk.listRefundables() + let refundables = try sdk.listRefundables() } catch SdkError.Error(let message) { print(message) } @@ -82,13 +82,63 @@ Once you have a refundable swap in hand, use the follwing code to execute a refu let destinationAddress = "..." let satPerVbyte = do { - try sdk.refund( - swapAddress: refundable.bitcoinAddress, - toAddress: destinationAddress, - satPerVbyte: satPerVbyte) + try sdk.refund(swapAddress: refundable.bitcoinAddress, + toAddress: destinationAddress, + satPerVbyte: satPerVbyte) } catch SdkError.Error(let message) { print(message) } ``` +
React Native
+
+ +```typescript +try { + const swapInfo = await sdkServices.receiveOnchain(); + + // Send your funds to the below bitcoin address + const address = swapInfo.bitcoinAddress; +} catch (error) { + console.log(error) +} +``` + +Once you've sent the funds to the above address, the SDK will monitor this address for unspent confirmed outputs and use a trustless submarine swap to receive these into your Lightning node. You can always monitor the status of the current in-progress swap using the following code: + +```typescript +try { + const swapInfo = await sdkServices.inProgressSwap() +} catch (error) { + console.log(error) +} +``` + +The process of receiving funds via an on-chain address is trustless and uses a submarine swap. This means there are two ways to spend the sent funds: + +1. Either by a preimage that is exposed when the Lightning payment is completed - this is the positive case where the swap was successful. +2. Or by your node when the swap didn't complete within a certain timeout - this is the negative case where your node will execute a refund. + +In order to execute a refund, you need to supply an on-chain address to where the refunded amount will be sent. The following code will retrieve the refundable swaps: + +```typescript +try { + const refundables = await sdkServices.listRefundables() +} catch (error) { + console.log(error) +} +``` + +Once you have a refundable swap in hand, use the follwing code to execute a refund: + +```typescript +const destinationAddress = "..." +const satPerVbyte = +try { + const result = await sdkServices.refund(refundable.bitcoinAddress, destinationAddress, satPerVbyte) +} catch (error) { + console.log(error) +} +``` +
\ No newline at end of file diff --git a/src/guide/send_onchain.md b/src/guide/send_onchain.md index eb9207d..1d2423f 100644 --- a/src/guide/send_onchain.md +++ b/src/guide/send_onchain.md @@ -53,13 +53,13 @@ for rs in sdk.in_progress_reverse_swaps().await? { ```swift try { - let currentFees = try sdk.fetchReverseSwapFees() + let currentFees = try sdk.fetchReverseSwapFees() - println("Percentage fee for the reverse swap service: \(currentFees.feesPercentage))"); - println("Estimated miner fees in sats for locking up funds: \(currentFees.feesLockup)"); - println("Estimated miner fees in sats for claiming funds: \(currentFees.feesClaim)"); -} catch { - print(error) + println("Percentage fee for the reverse swap service: \(currentFees.feesPercentage)"); + println("Estimated miner fees in sats for locking up funds: \(currentFees.feesLockup)"); + println("Estimated miner fees in sats for claiming funds: \(currentFees.feesClaim)"); +} catch SdkError.Error(let message) { + print(message) } ``` @@ -81,9 +81,9 @@ let destinationAddress = "bc1.."; let amountSat = currentFees.min; let satPerVbyte = try { - try sdk.sendOnchain(amountSat: amountSat, onchainRecipientAddress: destinationAddress, pairHash: currentFees.feesHash, satPerVbyte: satPerVbyte) -} catch { - print(error) + try sdk.sendOnchain(amountSat: amountSat, onchainRecipientAddress: destinationAddress, pairHash: currentFees.feesHash, satPerVbyte: satPerVbyte) +} catch SdkError.Error(let message) { + print(message) } ``` @@ -95,7 +95,10 @@ You can check its status with: ```swift for rs in sdk.inProgressReverseSwaps() { - println("Reverse swap \(rs.id) in progress, status is \(rs.breezStatus)"); + println("Reverse swap \(rs.id) in progress, status is \(rs.breezStatus)"); +} +``` + } ``` From 3a7d2b6cbf1f28964f1c00a8121a739222948816 Mon Sep 17 00:00:00 2001 From: Ross Savage Date: Sun, 2 Jul 2023 22:05:33 +0200 Subject: [PATCH 2/3] Add React Native examples --- src/guide/getting_started.md | 62 ++++++++++++++++++++++++++++++++++++ src/guide/lnurl_auth.md | 24 ++++++++++++++ src/guide/lnurl_pay.md | 20 ++++++++++++ src/guide/lnurl_withdraw.md | 19 +++++++++++ src/guide/payments.md | 31 ++++++++++++++++++ src/guide/send_onchain.md | 53 ++++++++++++++++++++++++++++++ 6 files changed, 209 insertions(+) diff --git a/src/guide/getting_started.md b/src/guide/getting_started.md index c052dcc..44d86ff 100644 --- a/src/guide/getting_started.md +++ b/src/guide/getting_started.md @@ -132,6 +132,68 @@ do { } ``` + +
React Native
+
+ +The first step is to register a new node +## Registering a new node +```typescript +try { + const seed = await mnemonicToSeed(""); + const invite_code = ""; + + // register_node takes either greenlight credentials (certifate & key) or invite code. + // At this example we are using the invite code option. + const credentials = await registerNode(Network.BITCOIN, seed, inviteCode); +} catch (error) { + console.log(error) +} +``` + +## Recovering an existing node +```typescript + const seed = await mnemonicToSeed(""); + const credentials = await recoverNode(Network.BITCOIN, seed); +``` + +Once the credentials are retrieved they should be saved in a secured storage. +The next step is to initialize the SDK and start the node: + +## Initializing the SDK +```typescript + +// SDK events listener +addEventListener((type, data) => { + console.log(`received event ${type}`); +}) + +// Create the default config +let config = defaultConfig(EnvironmentType.PRODUCTION) + +// Customize the config object according to your needs +config.apiKey = "your API key"; +config.workingDir = "path to an existing directory"; + +try { + const sdkServices = await initServices(config, credentials.deviceKey, credentials.deviceCert, seed); + await sdkServices.start(); +} catch (error) { + console.log(error); +} +``` + +At any point we can fetch our balance from the Greenlight node: + +```typescript +try { + const nodeInfo = await sdkServices.nodeInfo(); + const lnBalance = nodeInfo.channelsBalanceMsat; + const onchainBalance = nodeInfo.onchainBalanceMsat; +} catch (error) { + console.log(error); +} +```
diff --git a/src/guide/lnurl_auth.md b/src/guide/lnurl_auth.md index a3f2b2e..af4bca2 100644 --- a/src/guide/lnurl_auth.md +++ b/src/guide/lnurl_auth.md @@ -49,6 +49,30 @@ do { } ``` + +
React Native
+
+ +```typescript +// Endpoint can also be of the form: +// keyauth://domain.com/auth?key=val +let lnurlAuthUrl = "lnurl1dp68gurn8ghj7mr0vdskc6r0wd6z7mrww4excttvdankjm3lw3skw0tvdankjm3xdvcn6vtp8q6n2dfsx5mrjwtrxdjnqvtzv56rzcnyv3jrxv3sxqmkyenrvv6kve3exv6nqdtyv43nqcmzvdsnvdrzx33rsenxx5unqc3cxgeqgntfgu"; + +try { + const input = await parseInput(lnurlAuthUrl) + if (input.type === InputType.LNURL_AUTH) { + const result = await sdkServices.lnurlAuth(input.data) + if (result.status === "ok") { + print("Successfully authenticated") + } else { + print("Failed to authenticate") + } + } +} catch (error) { + console.log(error) +} +``` +
diff --git a/src/guide/lnurl_pay.md b/src/guide/lnurl_pay.md index baa6546..3fef874 100644 --- a/src/guide/lnurl_pay.md +++ b/src/guide/lnurl_pay.md @@ -41,6 +41,26 @@ do { } ``` +
React Native
+
+ +```typescript +// Endpoint can also be of the form: +// lnurlp://domain.com/lnurl-pay?key=val +// lnurl1dp68gurn8ghj7mr0vdskc6r0wd6z7mrww4excttsv9un7um9wdekjmmw84jxywf5x43rvv35xgmr2enrxanr2cfcvsmnwe3jxcukvde48qukgdec89snwde3vfjxvepjxpjnjvtpxd3kvdnxx5crxwpjvyunsephsz36jf +let lnurlPayUrl = "lightning@address.com"; + +try { + const input = await parseInput(lnurlAuthUrl) + if (input.type === InputType.LNURL_PAY) { + const amountSats = input.minSendable; + const result = await sdkServices.payLnurl(input.data, amountSats, "comment") + } +} catch (error) { + console.log(error) +} +``` +
## Supported Specs diff --git a/src/guide/lnurl_withdraw.md b/src/guide/lnurl_withdraw.md index 3a4855f..5c8addb 100644 --- a/src/guide/lnurl_withdraw.md +++ b/src/guide/lnurl_withdraw.md @@ -40,6 +40,25 @@ do { print(message) } +``` + +
React Native
+
+ +```typescript +// Endpoint can also be of the form: +// lnurlw://domain.com/lnurl-withdraw?key=val +let lnurlWithdrawUrl = "lnurl1dp68gurn8ghj7mr0vdskc6r0wd6z7mrww4exctthd96xserjv9mn7um9wdekjmmw843xxwpexdnxzen9vgunsvfexq6rvdecx93rgdmyxcuxverrvcursenpxvukzv3c8qunsdecx33nzwpnvg6ryc3hv93nzvecxgcxgwp3h33lxk"; + +try { + const input = await parseInput(lnurlAuthUrl) + if (input.type === InputType.LNURL_WITHDRAW) { + const amountSats = input.minWithdrawable; + const result = await sdkServices.withdrawLnurl(input.data, amountSats, "comment") + } +} catch (error) { + console.log(error) +} ```
diff --git a/src/guide/payments.md b/src/guide/payments.md index a1350a0..6b40d9a 100644 --- a/src/guide/payments.md +++ b/src/guide/payments.md @@ -58,7 +58,38 @@ do { } ``` +
React Native
+## Receiving Lightning Payments +Breez SDK doesn't require you to open a channel and set up your inbound liquidity. +Breez SDK automatically connects your node to the LSP peer and you can now receive payments: +```typescript +try { + const invoice = await sdkServices.receivePayment(3000, "Invoice for 3000 sats") +} catch (error) { + console.log(error) +} +``` + +## Sending Lightning Payments +```typescript +const bolt11 = "..."; +try { + const payment = await sdkServices.sendPayment(bolt11, 3000) +} catch (error) { + console.log(error) +} +``` + +## Sending Spontaneous Lightning Payments +```typescript +const nodeId = "..."; +try { + const payment = await sdkServices.sendSpontaneousPayment(nodeId, 3000) +} catch (error) { + console.log(error) +} +```
\ No newline at end of file diff --git a/src/guide/send_onchain.md b/src/guide/send_onchain.md index 1d2423f..9dd8341 100644 --- a/src/guide/send_onchain.md +++ b/src/guide/send_onchain.md @@ -99,6 +99,59 @@ for rs in sdk.inProgressReverseSwaps() { } ``` +
React Native
+
+ +```typescript +try { + const currentFees = await sdkServices.fetchReverseSwapFees() + + console.log(`Percentage fee for the reverse swap service: ${currentFees.feesPercentage}`); + console.log(`Estimated miner fees in sats for locking up funds: ${currentFees.feesLockup}`); + console.log(`Estimated miner fees in sats for claiming funds: ${currentFees.feesClaim}`); +} catch (error) { + console.log(error) +} +``` + +The reverse swap will involve two on-chain transactions, for which the mining fees can only be estimated. They will happen +automatically once the process is started, but the last two values above are these estimates to help you get a picture +of the total costs. + +Fetching the fees also tells you what is the range of amounts you can send: + +```typescript +console.log(`Minimum amount, in sats: ${current_fees.min}`); +console.log(`Maximum amount, in sats: ${current_fees.max}`); +``` + +Once you checked the fees are acceptable, you can start the reverse swap: + +```typescript +const destinationAddress = "bc1.."; +const amountSat = currentFees.min; +const satPerVbyte = +try { + const reverseSwapInfo = sdkServices.sendOnchain(amountSat, destinationAddress, currentFees.feesHash, satPerVbyte) +} catch (error) { + console.log(error) +} +``` + +Starting the reverse swap will trigger a HODL invoice payment, which will only be settled if the entire swap completes. +This means you will see an outgoing pending payment in your list of payments, which locks those funds until the invoice +is either settled or cancelled. This will happen automatically at the end of the reverse swap. + +You can check its status with: + +```typescript +try { + const swaps = await sdk.inProgressReverseSwaps() + for (const swap in swaps) { + println(`Reverse swap ${swap.id} in progress, status is ${swap.breezStatus}`); + } +} catch (error) { + console.log(error) } ```
From 8cf55b73060fa4683feffc9bd57cec6d9b30a8a6 Mon Sep 17 00:00:00 2001 From: Ross Savage Date: Sun, 2 Jul 2023 22:09:28 +0200 Subject: [PATCH 3/3] Remove sdkServices as its managed by the native module --- src/guide/getting_started.md | 4 ++-- src/guide/lnurl_auth.md | 2 +- src/guide/lnurl_pay.md | 2 +- src/guide/lnurl_withdraw.md | 2 +- src/guide/payments.md | 6 +++--- src/guide/recieve_onchain.md | 8 ++++---- src/guide/send_onchain.md | 6 +++--- 7 files changed, 15 insertions(+), 15 deletions(-) diff --git a/src/guide/getting_started.md b/src/guide/getting_started.md index 44d86ff..a369914 100644 --- a/src/guide/getting_started.md +++ b/src/guide/getting_started.md @@ -177,7 +177,7 @@ config.workingDir = "path to an existing directory"; try { const sdkServices = await initServices(config, credentials.deviceKey, credentials.deviceCert, seed); - await sdkServices.start(); + await start(); } catch (error) { console.log(error); } @@ -187,7 +187,7 @@ At any point we can fetch our balance from the Greenlight node: ```typescript try { - const nodeInfo = await sdkServices.nodeInfo(); + const nodeInfo = await nodeInfo(); const lnBalance = nodeInfo.channelsBalanceMsat; const onchainBalance = nodeInfo.onchainBalanceMsat; } catch (error) { diff --git a/src/guide/lnurl_auth.md b/src/guide/lnurl_auth.md index af4bca2..7d3c27d 100644 --- a/src/guide/lnurl_auth.md +++ b/src/guide/lnurl_auth.md @@ -61,7 +61,7 @@ let lnurlAuthUrl = "lnurl1dp68gurn8ghj7mr0vdskc6r0wd6z7mrww4excttvdankjm3lw3skw0 try { const input = await parseInput(lnurlAuthUrl) if (input.type === InputType.LNURL_AUTH) { - const result = await sdkServices.lnurlAuth(input.data) + const result = await lnurlAuth(input.data) if (result.status === "ok") { print("Successfully authenticated") } else { diff --git a/src/guide/lnurl_pay.md b/src/guide/lnurl_pay.md index 3fef874..1dada0e 100644 --- a/src/guide/lnurl_pay.md +++ b/src/guide/lnurl_pay.md @@ -54,7 +54,7 @@ try { const input = await parseInput(lnurlAuthUrl) if (input.type === InputType.LNURL_PAY) { const amountSats = input.minSendable; - const result = await sdkServices.payLnurl(input.data, amountSats, "comment") + const result = await payLnurl(input.data, amountSats, "comment") } } catch (error) { console.log(error) diff --git a/src/guide/lnurl_withdraw.md b/src/guide/lnurl_withdraw.md index 5c8addb..da7332f 100644 --- a/src/guide/lnurl_withdraw.md +++ b/src/guide/lnurl_withdraw.md @@ -54,7 +54,7 @@ try { const input = await parseInput(lnurlAuthUrl) if (input.type === InputType.LNURL_WITHDRAW) { const amountSats = input.minWithdrawable; - const result = await sdkServices.withdrawLnurl(input.data, amountSats, "comment") + const result = await withdrawLnurl(input.data, amountSats, "comment") } } catch (error) { console.log(error) diff --git a/src/guide/payments.md b/src/guide/payments.md index 6b40d9a..73167af 100644 --- a/src/guide/payments.md +++ b/src/guide/payments.md @@ -66,7 +66,7 @@ Breez SDK automatically connects your node to the LSP peer and you can now recei ```typescript try { - const invoice = await sdkServices.receivePayment(3000, "Invoice for 3000 sats") + const invoice = await receivePayment(3000, "Invoice for 3000 sats") } catch (error) { console.log(error) } @@ -76,7 +76,7 @@ try { ```typescript const bolt11 = "..."; try { - const payment = await sdkServices.sendPayment(bolt11, 3000) + const payment = await sendPayment(bolt11, 3000) } catch (error) { console.log(error) } @@ -86,7 +86,7 @@ try { ```typescript const nodeId = "..."; try { - const payment = await sdkServices.sendSpontaneousPayment(nodeId, 3000) + const payment = await sendSpontaneousPayment(nodeId, 3000) } catch (error) { console.log(error) } diff --git a/src/guide/recieve_onchain.md b/src/guide/recieve_onchain.md index 7a35c5a..dd554fb 100644 --- a/src/guide/recieve_onchain.md +++ b/src/guide/recieve_onchain.md @@ -95,7 +95,7 @@ do { ```typescript try { - const swapInfo = await sdkServices.receiveOnchain(); + const swapInfo = await receiveOnchain(); // Send your funds to the below bitcoin address const address = swapInfo.bitcoinAddress; @@ -108,7 +108,7 @@ Once you've sent the funds to the above address, the SDK will monitor this addre ```typescript try { - const swapInfo = await sdkServices.inProgressSwap() + const swapInfo = await inProgressSwap() } catch (error) { console.log(error) } @@ -123,7 +123,7 @@ In order to execute a refund, you need to supply an on-chain address to where th ```typescript try { - const refundables = await sdkServices.listRefundables() + const refundables = await listRefundables() } catch (error) { console.log(error) } @@ -135,7 +135,7 @@ Once you have a refundable swap in hand, use the follwing code to execute a refu const destinationAddress = "..." const satPerVbyte = try { - const result = await sdkServices.refund(refundable.bitcoinAddress, destinationAddress, satPerVbyte) + const result = await refund(refundable.bitcoinAddress, destinationAddress, satPerVbyte) } catch (error) { console.log(error) } diff --git a/src/guide/send_onchain.md b/src/guide/send_onchain.md index 9dd8341..ce1a4f9 100644 --- a/src/guide/send_onchain.md +++ b/src/guide/send_onchain.md @@ -104,7 +104,7 @@ for rs in sdk.inProgressReverseSwaps() { ```typescript try { - const currentFees = await sdkServices.fetchReverseSwapFees() + const currentFees = await fetchReverseSwapFees() console.log(`Percentage fee for the reverse swap service: ${currentFees.feesPercentage}`); console.log(`Estimated miner fees in sats for locking up funds: ${currentFees.feesLockup}`); @@ -132,7 +132,7 @@ const destinationAddress = "bc1.."; const amountSat = currentFees.min; const satPerVbyte = try { - const reverseSwapInfo = sdkServices.sendOnchain(amountSat, destinationAddress, currentFees.feesHash, satPerVbyte) + const reverseSwapInfo = sendOnchain(amountSat, destinationAddress, currentFees.feesHash, satPerVbyte) } catch (error) { console.log(error) } @@ -146,7 +146,7 @@ You can check its status with: ```typescript try { - const swaps = await sdk.inProgressReverseSwaps() + const swaps = await inProgressReverseSwaps() for (const swap in swaps) { println(`Reverse swap ${swap.id} in progress, status is ${swap.breezStatus}`); }