Merge pull request #52 from breez/savage-rn-connect

Update RN connect interface
This commit is contained in:
Ross Savage
2023-10-05 13:47:08 +02:00
committed by GitHub
7 changed files with 28 additions and 28 deletions

View File

@@ -132,27 +132,27 @@ try {
```typescript
// SDK events listener
addEventListener((type, data) => {
console.log(`received event ${type}`);
const onBreezEvent = (event: BreezEvent) => {
console.log(`received event ${event.type}`)
})
// Create the default config
const seed = await mnemonicToSeed("<mnemonics words>");
const inviteCode = "<your greenlight invite code>";
const seed = await mnemonicToSeed("<mnemonics words>")
const inviteCode = "<your greenlight invite code>"
const nodeConfig : NodeConfig = {
type: NodeConfigType.GREENLIGHT,
config: {
inviteCode: "your invite code"
}
}
let config = await defaultConfig(EnvironmentType.PRODUCTION, "api key", nodeConfig);
let config = await defaultConfig(EnvironmentType.PRODUCTION, "api key", nodeConfig)
// Customize the config object according to your needs
config.workingDir = "path to an existing directory";
config.workingDir = "path to an existing directory"
try {
// Connect to the Breez SDK make it ready for use
const sdkServices = await connect(config, seed);
const sdkServices = await connect(config, seed, onBreezEvent)
} catch (error) {
console.log(error)
}

View File

@@ -79,16 +79,16 @@ try {
```typescript
// Endpoint can also be of the form:
// keyauth://domain.com/auth?key=val
let lnurlAuthUrl = "lnurl1dp68gurn8ghj7mr0vdskc6r0wd6z7mrww4excttvdankjm3lw3skw0tvdankjm3xdvcn6vtp8q6n2dfsx5mrjwtrxdjnqvtzv56rzcnyv3jrxv3sxqmkyenrvv6kve3exv6nqdtyv43nqcmzvdsnvdrzx33rsenxx5unqc3cxgeqgntfgu";
let lnurlAuthUrl = "lnurl1dp68gurn8ghj7mr0vdskc6r0wd6z7mrww4excttvdankjm3lw3skw0tvdankjm3xdvcn6vtp8q6n2dfsx5mrjwtrxdjnqvtzv56rzcnyv3jrxv3sxqmkyenrvv6kve3exv6nqdtyv43nqcmzvdsnvdrzx33rsenxx5unqc3cxgeqgntfgu"
try {
const input = await parseInput(lnurlAuthUrl)
if (input.type === InputType.LNURL_AUTH) {
if (input.type === InputTypeVariant.LN_URL_AUTH) {
const result = await lnurlAuth(input.data)
if (result.status === "ok") {
print("Successfully authenticated")
if (result.type === LnUrlCallbackStatusVariant.OK) {
console.log("Successfully authanticated")
} else {
print("Failed to authenticate")
console.log("Failed to authenticate")
}
}
} catch (error) {

View File

@@ -71,12 +71,12 @@ try {
// Endpoint can also be of the form:
// lnurlp://domain.com/lnurl-pay?key=val
// lnurl1dp68gurn8ghj7mr0vdskc6r0wd6z7mrww4excttsv9un7um9wdekjmmw84jxywf5x43rvv35xgmr2enrxanr2cfcvsmnwe3jxcukvde48qukgdec89snwde3vfjxvepjxpjnjvtpxd3kvdnxx5crxwpjvyunsephsz36jf
let lnurlPayUrl = "lightning@address.com";
let lnurlPayUrl = "lightning@address.com"
try {
const input = await parseInput(lnurlPayUrl)
if (input.type === InputType.LNURL_PAY) {
const amountSats = input.data.minSendable;
if (input.type === InputTypeVariant.LN_URL_PAY) {
const amountSats = input.data.minSendable
const result = await payLnurl(input.data, amountSats, "comment")
}
} catch (error) {

View File

@@ -70,12 +70,12 @@ try {
```typescript
// Endpoint can also be of the form:
// lnurlw://domain.com/lnurl-withdraw?key=val
let lnurlWithdrawUrl = "lnurl1dp68gurn8ghj7mr0vdskc6r0wd6z7mrww4exctthd96xserjv9mn7um9wdekjmmw843xxwpexdnxzen9vgunsvfexq6rvdecx93rgdmyxcuxverrvcursenpxvukzv3c8qunsdecx33nzwpnvg6ryc3hv93nzvecxgcxgwp3h33lxk";
let lnurlWithdrawUrl = "lnurl1dp68gurn8ghj7mr0vdskc6r0wd6z7mrww4exctthd96xserjv9mn7um9wdekjmmw843xxwpexdnxzen9vgunsvfexq6rvdecx93rgdmyxcuxverrvcursenpxvukzv3c8qunsdecx33nzwpnvg6ryc3hv93nzvecxgcxgwp3h33lxk"
try {
const input = await parseInput(lnurlWithdrawUrl)
if (input.type === InputType.LNURL_WITHDRAW) {
const amountSats = input.data.minWithdrawable;
if (input.type === InputTypeVariant.LN_URL_WITHDRAW) {
const amountSats = input.data.minWithdrawable
const result = await withdrawLnurl(input.data, amountSats, "comment")
}
} catch (error) {

View File

@@ -175,7 +175,7 @@ try {
<section>
```typescript
const bolt11 = "...";
const bolt11 = "..."
try {
const payment = await sendPayment(bolt11, 3000)
} catch (error) {
@@ -285,7 +285,7 @@ try {
<section>
```typescript
const nodeId = "...";
const nodeId = "..."
try {
const payment = await sendSpontaneousPayment(nodeId, 3000)
} catch (error) {

View File

@@ -56,7 +56,7 @@ try {
const swapInfo = await receiveOnchain({})
// Send your funds to the below bitcoin address
const address = swapInfo.bitcoinAddress;
const address = swapInfo.bitcoinAddress
} catch (error) {
console.log(error)
}

View File

@@ -54,7 +54,7 @@ try {
try {
const currentFees = await fetchReverseSwapFees({sendAmountSat: 50000})
console.log(`Total estimated fees for reverse swap: ${currentFees.totalEstimatedFees}`);
console.log(`Total estimated fees for reverse swap: ${currentFees.totalEstimatedFees}`)
} catch (error) {
console.log(error)
}
@@ -162,8 +162,8 @@ Log.v("Breez", "Maximum amount, in sats: ${fees.max}")
<section>
```typescript
console.log(`Minimum amount, in sats: ${currentFees.min}`);
console.log(`Maximum amount, in sats: ${currentFees.max}`);
console.log(`Minimum amount, in sats: ${currentFees.min}`)
console.log(`Maximum amount, in sats: ${currentFees.max}`)
```
</section>
@@ -257,8 +257,8 @@ try {
<section>
```typescript
const destinationAddress = "bc1..";
const amountSat = currentFees.min;
const destinationAddress = "bc1.."
const amountSat = currentFees.min
const satPerVbyte = <fee rate>
try {
const reverseSwapInfo = await sendOnchain(amountSat, destinationAddress, currentFees.feesHash, satPerVbyte)
@@ -387,8 +387,8 @@ for (rs in sdk.inProgressReverseSwaps()) {
```typescript
try {
const swaps = await inProgressReverseSwaps()
for (const swap in swaps) {
println(`Reverse swap ${swap.id} in progress, status is ${swap.status}`);
for (const swap of swaps) {
console.log(`Reverse swap ${swap.id} in progress, status is ${swap.status}`)
}
} catch (error) {
console.log(error)