mirror of
https://github.com/aljazceru/breez-sdk-docs.git
synced 2025-12-18 06:14:21 +01:00
Remove sdkServices as its managed by the native module
This commit is contained in:
@@ -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) {
|
||||
|
||||
@@ -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 {
|
||||
|
||||
@@ -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)
|
||||
|
||||
@@ -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)
|
||||
|
||||
@@ -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)
|
||||
}
|
||||
|
||||
@@ -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 = <refund tx fee rate>
|
||||
try {
|
||||
const result = await sdkServices.refund(refundable.bitcoinAddress, destinationAddress, satPerVbyte)
|
||||
const result = await refund(refundable.bitcoinAddress, destinationAddress, satPerVbyte)
|
||||
} catch (error) {
|
||||
console.log(error)
|
||||
}
|
||||
|
||||
@@ -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 = <fee rate>
|
||||
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}`);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user