crosslightning-sdk-base
Advanced tools
Comparing version 3.1.3 to 3.1.4
@@ -79,2 +79,3 @@ /// <reference types="node" /> | ||
nonce: number; | ||
invoice: string; | ||
}>; | ||
@@ -81,0 +82,0 @@ payLightning(bolt11PayReq: string, expirySeconds: number, maxFee: BN, url: string, requiredToken?: TokenAddress, requiredClaimerKey?: string, requiredBaseFee?: BN, requiredFeePPM?: BN): Promise<{ |
@@ -368,3 +368,5 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) { | ||
} | ||
return this.payLightning(invoice, expirySeconds, maxFee, url, requiredToken, requiredClaimerKey, requiredBaseFee, requiredFeePPM); | ||
const resp = yield this.payLightning(invoice, expirySeconds, maxFee, url, requiredToken, requiredClaimerKey, requiredBaseFee, requiredFeePPM); | ||
resp.invoice = invoice; | ||
return resp; | ||
}); | ||
@@ -371,0 +373,0 @@ } |
@@ -31,2 +31,18 @@ import { SoltoBTCLNSwap } from "./SoltoBTCLNSwap"; | ||
create(bolt11PayRequest: string, expirySeconds: number, url: string, maxBaseFee?: BN, maxPPMFee?: BN, requiredToken?: TokenAddress, requiredKey?: string, requiredBaseFee?: BN, requiredFeePPM?: BN): Promise<SoltoBTCLNSwap<T>>; | ||
/** | ||
* Returns a newly created swap, paying for LNURL-pay | ||
* | ||
* @param lnurlPay LNURL-pay link to use for payment | ||
* @param amount Amount in sats to pay | ||
* @param comment Optional comment for the payment request | ||
* @param expirySeconds Swap expiration in seconds, setting this too low might lead to unsuccessful payments, too high and you might lose access to your funds for longer than necessary | ||
* @param url Intermediary/Counterparty swap service url | ||
* @param maxBaseFee Max base fee for the payment routing | ||
* @param maxPPMFee Max proportional fee PPM (per million 0.1% == 1000) for routing | ||
* @param requiredToken Token that we want to send | ||
* @param requiredKey Required key of the Intermediary | ||
* @param requiredBaseFee Desired base fee reported by the swap intermediary | ||
* @param requiredFeePPM Desired proportional fee report by the swap intermediary | ||
*/ | ||
createViaLNURL(lnurlPay: string, amount: BN, comment: string, expirySeconds: number, url: string, maxBaseFee?: BN, maxPPMFee?: BN, requiredToken?: TokenAddress, requiredKey?: string, requiredBaseFee?: BN, requiredFeePPM?: BN): Promise<SoltoBTCLNSwap<T>>; | ||
} |
@@ -61,2 +61,29 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) { | ||
} | ||
/** | ||
* Returns a newly created swap, paying for LNURL-pay | ||
* | ||
* @param lnurlPay LNURL-pay link to use for payment | ||
* @param amount Amount in sats to pay | ||
* @param comment Optional comment for the payment request | ||
* @param expirySeconds Swap expiration in seconds, setting this too low might lead to unsuccessful payments, too high and you might lose access to your funds for longer than necessary | ||
* @param url Intermediary/Counterparty swap service url | ||
* @param maxBaseFee Max base fee for the payment routing | ||
* @param maxPPMFee Max proportional fee PPM (per million 0.1% == 1000) for routing | ||
* @param requiredToken Token that we want to send | ||
* @param requiredKey Required key of the Intermediary | ||
* @param requiredBaseFee Desired base fee reported by the swap intermediary | ||
* @param requiredFeePPM Desired proportional fee report by the swap intermediary | ||
*/ | ||
createViaLNURL(lnurlPay, amount, comment, expirySeconds, url, maxBaseFee, maxPPMFee, requiredToken, requiredKey, requiredBaseFee, requiredFeePPM) { | ||
return __awaiter(this, void 0, void 0, function* () { | ||
if (!this.isInitialized) | ||
throw new Error("Not initialized, call init() first!"); | ||
const fee = this.calculateFeeForAmount(amount, maxBaseFee, maxPPMFee); | ||
const result = yield this.contract.payLightningLNURL(lnurlPay, amount, comment, expirySeconds, fee, url, requiredToken, requiredKey, requiredBaseFee, requiredFeePPM); | ||
const swap = new SoltoBTCLNSwap(this, result.invoice, result.data, result.swapFee.add(result.maxFee), result.prefix, result.timeout, result.signature, result.nonce, url, result.confidence, result.routingFeeSats); | ||
yield swap.save(); | ||
this.swapData[result.data.getHash()] = swap; | ||
return swap; | ||
}); | ||
} | ||
} |
{ | ||
"name": "crosslightning-sdk-base", | ||
"version": "3.1.3", | ||
"version": "3.1.4", | ||
"description": "CrossLightning SDK chain-agnostic base", | ||
@@ -5,0 +5,0 @@ "main": "./dist/index.js", |
@@ -459,3 +459,5 @@ import * as BN from "bn.js"; | ||
signature: string, | ||
nonce: number | ||
nonce: number, | ||
invoice: string | ||
}> { | ||
@@ -526,3 +528,3 @@ const foundLNURL = findlnurl(lnurl); | ||
return this.payLightning( | ||
const resp: any = await this.payLightning( | ||
invoice, | ||
@@ -537,2 +539,6 @@ expirySeconds, | ||
); | ||
resp.invoice = invoice; | ||
return resp; | ||
} | ||
@@ -539,0 +545,0 @@ |
@@ -90,2 +90,59 @@ import * as bolt11 from "bolt11"; | ||
/** | ||
* Returns a newly created swap, paying for LNURL-pay | ||
* | ||
* @param lnurlPay LNURL-pay link to use for payment | ||
* @param amount Amount in sats to pay | ||
* @param comment Optional comment for the payment request | ||
* @param expirySeconds Swap expiration in seconds, setting this too low might lead to unsuccessful payments, too high and you might lose access to your funds for longer than necessary | ||
* @param url Intermediary/Counterparty swap service url | ||
* @param maxBaseFee Max base fee for the payment routing | ||
* @param maxPPMFee Max proportional fee PPM (per million 0.1% == 1000) for routing | ||
* @param requiredToken Token that we want to send | ||
* @param requiredKey Required key of the Intermediary | ||
* @param requiredBaseFee Desired base fee reported by the swap intermediary | ||
* @param requiredFeePPM Desired proportional fee report by the swap intermediary | ||
*/ | ||
async createViaLNURL( | ||
lnurlPay: string, | ||
amount: BN, | ||
comment: string, | ||
expirySeconds: number, | ||
url: string, | ||
maxBaseFee?: BN, | ||
maxPPMFee?: BN, | ||
requiredToken?: TokenAddress, | ||
requiredKey?: string, | ||
requiredBaseFee?: BN, | ||
requiredFeePPM?: BN | ||
): Promise<SoltoBTCLNSwap<T>> { | ||
if(!this.isInitialized) throw new Error("Not initialized, call init() first!"); | ||
const fee = this.calculateFeeForAmount(amount, maxBaseFee, maxPPMFee); | ||
const result = await this.contract.payLightningLNURL(lnurlPay, amount, comment, expirySeconds, fee, url, requiredToken, requiredKey, requiredBaseFee, requiredFeePPM); | ||
const swap = new SoltoBTCLNSwap( | ||
this, | ||
result.invoice, | ||
result.data, | ||
result.swapFee.add(result.maxFee), | ||
result.prefix, | ||
result.timeout, | ||
result.signature, | ||
result.nonce, | ||
url, | ||
result.confidence, | ||
result.routingFeeSats | ||
); | ||
await swap.save(); | ||
this.swapData[result.data.getHash()] = swap; | ||
return swap; | ||
} | ||
} |
458609
10349