Remove sdkServices as its managed by the native module

This commit is contained in:
Ross Savage
2023-07-02 22:09:28 +02:00
parent 3a7d2b6cbf
commit 8cf55b7306
7 changed files with 15 additions and 15 deletions

View File

@@ -177,7 +177,7 @@ config.workingDir = "path to an existing directory";
try { try {
const sdkServices = await initServices(config, credentials.deviceKey, credentials.deviceCert, seed); const sdkServices = await initServices(config, credentials.deviceKey, credentials.deviceCert, seed);
await sdkServices.start(); await start();
} catch (error) { } catch (error) {
console.log(error); console.log(error);
} }
@@ -187,7 +187,7 @@ At any point we can fetch our balance from the Greenlight node:
```typescript ```typescript
try { try {
const nodeInfo = await sdkServices.nodeInfo(); const nodeInfo = await nodeInfo();
const lnBalance = nodeInfo.channelsBalanceMsat; const lnBalance = nodeInfo.channelsBalanceMsat;
const onchainBalance = nodeInfo.onchainBalanceMsat; const onchainBalance = nodeInfo.onchainBalanceMsat;
} catch (error) { } catch (error) {

View File

@@ -61,7 +61,7 @@ let lnurlAuthUrl = "lnurl1dp68gurn8ghj7mr0vdskc6r0wd6z7mrww4excttvdankjm3lw3skw0
try { try {
const input = await parseInput(lnurlAuthUrl) const input = await parseInput(lnurlAuthUrl)
if (input.type === InputType.LNURL_AUTH) { if (input.type === InputType.LNURL_AUTH) {
const result = await sdkServices.lnurlAuth(input.data) const result = await lnurlAuth(input.data)
if (result.status === "ok") { if (result.status === "ok") {
print("Successfully authenticated") print("Successfully authenticated")
} else { } else {

View File

@@ -54,7 +54,7 @@ try {
const input = await parseInput(lnurlAuthUrl) const input = await parseInput(lnurlAuthUrl)
if (input.type === InputType.LNURL_PAY) { if (input.type === InputType.LNURL_PAY) {
const amountSats = input.minSendable; const amountSats = input.minSendable;
const result = await sdkServices.payLnurl(input.data, amountSats, "comment") const result = await payLnurl(input.data, amountSats, "comment")
} }
} catch (error) { } catch (error) {
console.log(error) console.log(error)

View File

@@ -54,7 +54,7 @@ try {
const input = await parseInput(lnurlAuthUrl) const input = await parseInput(lnurlAuthUrl)
if (input.type === InputType.LNURL_WITHDRAW) { if (input.type === InputType.LNURL_WITHDRAW) {
const amountSats = input.minWithdrawable; const amountSats = input.minWithdrawable;
const result = await sdkServices.withdrawLnurl(input.data, amountSats, "comment") const result = await withdrawLnurl(input.data, amountSats, "comment")
} }
} catch (error) { } catch (error) {
console.log(error) console.log(error)

View File

@@ -66,7 +66,7 @@ Breez SDK automatically connects your node to the LSP peer and you can now recei
```typescript ```typescript
try { try {
const invoice = await sdkServices.receivePayment(3000, "Invoice for 3000 sats") const invoice = await receivePayment(3000, "Invoice for 3000 sats")
} catch (error) { } catch (error) {
console.log(error) console.log(error)
} }
@@ -76,7 +76,7 @@ try {
```typescript ```typescript
const bolt11 = "..."; const bolt11 = "...";
try { try {
const payment = await sdkServices.sendPayment(bolt11, 3000) const payment = await sendPayment(bolt11, 3000)
} catch (error) { } catch (error) {
console.log(error) console.log(error)
} }
@@ -86,7 +86,7 @@ try {
```typescript ```typescript
const nodeId = "..."; const nodeId = "...";
try { try {
const payment = await sdkServices.sendSpontaneousPayment(nodeId, 3000) const payment = await sendSpontaneousPayment(nodeId, 3000)
} catch (error) { } catch (error) {
console.log(error) console.log(error)
} }

View File

@@ -95,7 +95,7 @@ do {
```typescript ```typescript
try { try {
const swapInfo = await sdkServices.receiveOnchain(); const swapInfo = await receiveOnchain();
// Send your funds to the below bitcoin address // Send your funds to the below bitcoin address
const address = swapInfo.bitcoinAddress; 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 ```typescript
try { try {
const swapInfo = await sdkServices.inProgressSwap() const swapInfo = await inProgressSwap()
} catch (error) { } catch (error) {
console.log(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 ```typescript
try { try {
const refundables = await sdkServices.listRefundables() const refundables = await listRefundables()
} catch (error) { } catch (error) {
console.log(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 destinationAddress = "..."
const satPerVbyte = <refund tx fee rate> const satPerVbyte = <refund tx fee rate>
try { try {
const result = await sdkServices.refund(refundable.bitcoinAddress, destinationAddress, satPerVbyte) const result = await refund(refundable.bitcoinAddress, destinationAddress, satPerVbyte)
} catch (error) { } catch (error) {
console.log(error) console.log(error)
} }

View File

@@ -104,7 +104,7 @@ for rs in sdk.inProgressReverseSwaps() {
```typescript ```typescript
try { try {
const currentFees = await sdkServices.fetchReverseSwapFees() const currentFees = await fetchReverseSwapFees()
console.log(`Percentage fee for the reverse swap service: ${currentFees.feesPercentage}`); 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 locking up funds: ${currentFees.feesLockup}`);
@@ -132,7 +132,7 @@ const destinationAddress = "bc1..";
const amountSat = currentFees.min; const amountSat = currentFees.min;
const satPerVbyte = <fee rate> const satPerVbyte = <fee rate>
try { try {
const reverseSwapInfo = sdkServices.sendOnchain(amountSat, destinationAddress, currentFees.feesHash, satPerVbyte) const reverseSwapInfo = sendOnchain(amountSat, destinationAddress, currentFees.feesHash, satPerVbyte)
} catch (error) { } catch (error) {
console.log(error) console.log(error)
} }
@@ -146,7 +146,7 @@ You can check its status with:
```typescript ```typescript
try { try {
const swaps = await sdk.inProgressReverseSwaps() const swaps = await inProgressReverseSwaps()
for (const swap in swaps) { for (const swap in swaps) {
println(`Reverse swap ${swap.id} in progress, status is ${swap.breezStatus}`); println(`Reverse swap ${swap.id} in progress, status is ${swap.breezStatus}`);
} }