@atomiqlabs/sdk 8.0.7 → 8.0.8

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -78,7 +78,7 @@ class ToBTCLNSwap extends IToBTCSwap_1.IToBTCSwap {
78
78
  return Token_1.BitcoinTokens.BTCLN;
79
79
  }
80
80
  getOutput() {
81
- if (this.pr == null || !this.pr.startsWith("ln"))
81
+ if (this.pr == null || !this.pr.toLowerCase().startsWith("ln"))
82
82
  return null;
83
83
  const parsedPR = (0, bolt11_1.decode)(this.pr);
84
84
  if (parsedPR.millisatoshis == null)
@@ -114,7 +114,7 @@ class ToBTCLNSwap extends IToBTCSwap_1.IToBTCSwap {
114
114
  * Checks whether a swap is likely to fail, based on the confidence as reported by the LP
115
115
  */
116
116
  willLikelyFail() {
117
- if (this.pr == null || !this.pr.startsWith("ln"))
117
+ if (this.pr == null || !this.pr.toLowerCase().startsWith("ln"))
118
118
  return false;
119
119
  const parsedRequest = (0, bolt11_1.decode)(this.pr);
120
120
  if (parsedRequest.tagsObject.routing_info != null) {
@@ -131,7 +131,7 @@ class ToBTCLNSwap extends IToBTCSwap_1.IToBTCSwap {
131
131
  * for such a wallet to be online when attempting to make a swap
132
132
  */
133
133
  isPayingToNonCustodialWallet() {
134
- if (this.pr == null || !this.pr.startsWith("ln"))
134
+ if (this.pr == null || !this.pr.toLowerCase().startsWith("ln"))
135
135
  return false;
136
136
  const parsedRequest = (0, bolt11_1.decode)(this.pr);
137
137
  if (parsedRequest.tagsObject.routing_info != null) {
@@ -150,7 +150,7 @@ class ToBTCLNSwap extends IToBTCSwap_1.IToBTCSwap {
150
150
  getPaymentHash() {
151
151
  if (this.pr == null)
152
152
  return null;
153
- if (this.pr.startsWith("ln")) {
153
+ if (this.pr.toLowerCase().startsWith("ln")) {
154
154
  const parsed = (0, bolt11_1.decode)(this.pr);
155
155
  if (parsed.tagsObject.payment_hash == null)
156
156
  throw new Error("Swap invoice has no payment hash field!");
@@ -161,7 +161,7 @@ class ToBTCLNSwap extends IToBTCSwap_1.IToBTCSwap {
161
161
  getLpIdentifier() {
162
162
  if (this.pr == null)
163
163
  return this.data.getEscrowHash();
164
- if (this.pr.startsWith("ln")) {
164
+ if (this.pr.toLowerCase().startsWith("ln")) {
165
165
  const parsed = (0, bolt11_1.decode)(this.pr);
166
166
  if (parsed.tagsObject.payment_hash == null)
167
167
  throw new Error("Swap invoice has no payment hash field!");
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@atomiqlabs/sdk",
3
- "version": "8.0.7",
3
+ "version": "8.0.8",
4
4
  "description": "atomiq labs SDK for cross-chain swaps between smart chains and bitcoin",
5
5
  "main": "./dist/index.js",
6
6
  "types:": "./dist/index.d.ts",
@@ -105,7 +105,7 @@ export class ToBTCLNSwap<T extends ChainType = ChainType> extends IToBTCSwap<T,
105
105
  }
106
106
 
107
107
  getOutput(): TokenAmount<T["ChainId"], BtcToken<true>> | null {
108
- if(this.pr==null || !this.pr.startsWith("ln")) return null;
108
+ if(this.pr==null || !this.pr.toLowerCase().startsWith("ln")) return null;
109
109
  const parsedPR = bolt11Decode(this.pr);
110
110
  if(parsedPR.millisatoshis==null) throw new Error("Swap invoice has no msat amount field!");
111
111
  const amount = (BigInt(parsedPR.millisatoshis) + 999n) / 1000n;
@@ -146,7 +146,7 @@ export class ToBTCLNSwap<T extends ChainType = ChainType> extends IToBTCSwap<T,
146
146
  * Checks whether a swap is likely to fail, based on the confidence as reported by the LP
147
147
  */
148
148
  willLikelyFail(): boolean {
149
- if(this.pr==null || !this.pr.startsWith("ln")) return false;
149
+ if(this.pr==null || !this.pr.toLowerCase().startsWith("ln")) return false;
150
150
 
151
151
  const parsedRequest = bolt11Decode(this.pr);
152
152
 
@@ -166,7 +166,7 @@ export class ToBTCLNSwap<T extends ChainType = ChainType> extends IToBTCSwap<T,
166
166
  * for such a wallet to be online when attempting to make a swap
167
167
  */
168
168
  isPayingToNonCustodialWallet(): boolean {
169
- if(this.pr==null || !this.pr.startsWith("ln")) return false;
169
+ if(this.pr==null || !this.pr.toLowerCase().startsWith("ln")) return false;
170
170
 
171
171
  const parsedRequest = bolt11Decode(this.pr);
172
172
 
@@ -186,7 +186,7 @@ export class ToBTCLNSwap<T extends ChainType = ChainType> extends IToBTCSwap<T,
186
186
 
187
187
  getPaymentHash(): Buffer | null {
188
188
  if(this.pr==null) return null;
189
- if(this.pr.startsWith("ln")) {
189
+ if(this.pr.toLowerCase().startsWith("ln")) {
190
190
  const parsed = bolt11Decode(this.pr);
191
191
  if(parsed.tagsObject.payment_hash==null) throw new Error("Swap invoice has no payment hash field!");
192
192
  return Buffer.from(parsed.tagsObject.payment_hash, "hex");
@@ -196,7 +196,7 @@ export class ToBTCLNSwap<T extends ChainType = ChainType> extends IToBTCSwap<T,
196
196
 
197
197
  protected getLpIdentifier(): string {
198
198
  if(this.pr==null) return this.data.getEscrowHash();
199
- if(this.pr.startsWith("ln")) {
199
+ if(this.pr.toLowerCase().startsWith("ln")) {
200
200
  const parsed = bolt11Decode(this.pr);
201
201
  if(parsed.tagsObject.payment_hash==null) throw new Error("Swap invoice has no payment hash field!");
202
202
  return parsed.tagsObject.payment_hash;