@atomiqlabs/btc-mempool 1.0.1 → 1.0.3
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.
|
@@ -166,7 +166,7 @@ class MempoolApi {
|
|
|
166
166
|
getLNNodeInfo(pubkey) {
|
|
167
167
|
//500, 200
|
|
168
168
|
return this.request("v1/lightning/nodes/" + pubkey, "obj").catch((e) => {
|
|
169
|
-
if (e.
|
|
169
|
+
if (e.responseMessage === "This node does not exist, or our node is not seeing it yet")
|
|
170
170
|
return null;
|
|
171
171
|
throw e;
|
|
172
172
|
});
|
|
@@ -179,7 +179,7 @@ class MempoolApi {
|
|
|
179
179
|
getTransaction(txId) {
|
|
180
180
|
//404 ("Transaction not found"), 200
|
|
181
181
|
return this.request("tx/" + txId, "obj").catch((e) => {
|
|
182
|
-
if (e.
|
|
182
|
+
if (e.responseMessage === "Transaction not found")
|
|
183
183
|
return null;
|
|
184
184
|
throw e;
|
|
185
185
|
});
|
|
@@ -192,7 +192,7 @@ class MempoolApi {
|
|
|
192
192
|
async getRawTransaction(txId) {
|
|
193
193
|
//404 ("Transaction not found"), 200
|
|
194
194
|
const rawTransaction = await this.request("tx/" + txId + "/hex", "str").catch((e) => {
|
|
195
|
-
if (e.
|
|
195
|
+
if (e.responseMessage === "Transaction not found")
|
|
196
196
|
return null;
|
|
197
197
|
throw e;
|
|
198
198
|
});
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@atomiqlabs/btc-mempool",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.3",
|
|
4
4
|
"description": "Connector and synchronizer using mempool.space API for bitcoin",
|
|
5
5
|
"main": "./dist/index.js",
|
|
6
6
|
"types:": "./dist/index.d.ts",
|
|
@@ -24,7 +24,7 @@
|
|
|
24
24
|
"author": "adambor",
|
|
25
25
|
"license": "ISC",
|
|
26
26
|
"dependencies": {
|
|
27
|
-
"@atomiqlabs/base": "
|
|
27
|
+
"@atomiqlabs/base": "^13.1.2",
|
|
28
28
|
"@scure/btc-signer": "1.6.0"
|
|
29
29
|
},
|
|
30
30
|
"devDependencies": {
|
|
@@ -7,12 +7,14 @@
|
|
|
7
7
|
export class MempoolApiError extends Error {
|
|
8
8
|
|
|
9
9
|
httpCode: number;
|
|
10
|
+
responseMessage: string;
|
|
10
11
|
|
|
11
12
|
constructor(msg: string, httpCode: number) {
|
|
12
13
|
super(`MempoolApiError(${httpCode}): `+msg);
|
|
13
14
|
// Set the prototype explicitly.
|
|
14
15
|
Object.setPrototypeOf(this, MempoolApiError.prototype);
|
|
15
16
|
this.httpCode = httpCode;
|
|
17
|
+
this.responseMessage = msg;
|
|
16
18
|
}
|
|
17
19
|
|
|
18
20
|
}
|
|
@@ -399,8 +399,8 @@ export class MempoolApi {
|
|
|
399
399
|
*/
|
|
400
400
|
getLNNodeInfo(pubkey: string): Promise<LNNodeInfo | null> {
|
|
401
401
|
//500, 200
|
|
402
|
-
return this.request<LNNodeInfo>("v1/lightning/nodes/"+pubkey, "obj").catch((e:
|
|
403
|
-
if(e.
|
|
402
|
+
return this.request<LNNodeInfo>("v1/lightning/nodes/"+pubkey, "obj").catch((e: MempoolApiError) => {
|
|
403
|
+
if(e.responseMessage==="This node does not exist, or our node is not seeing it yet") return null;
|
|
404
404
|
throw e;
|
|
405
405
|
});
|
|
406
406
|
}
|
|
@@ -412,8 +412,8 @@ export class MempoolApi {
|
|
|
412
412
|
*/
|
|
413
413
|
getTransaction(txId: string): Promise<BitcoinTransaction | null> {
|
|
414
414
|
//404 ("Transaction not found"), 200
|
|
415
|
-
return this.request<BitcoinTransaction>("tx/"+txId, "obj").catch((e:
|
|
416
|
-
if(e.
|
|
415
|
+
return this.request<BitcoinTransaction>("tx/"+txId, "obj").catch((e: MempoolApiError) => {
|
|
416
|
+
if(e.responseMessage==="Transaction not found") return null;
|
|
417
417
|
throw e;
|
|
418
418
|
});
|
|
419
419
|
}
|
|
@@ -425,8 +425,8 @@ export class MempoolApi {
|
|
|
425
425
|
*/
|
|
426
426
|
async getRawTransaction(txId: string): Promise<Buffer | null> {
|
|
427
427
|
//404 ("Transaction not found"), 200
|
|
428
|
-
const rawTransaction: string | null = await this.request<string>("tx/"+txId+"/hex", "str").catch((e:
|
|
429
|
-
if(e.
|
|
428
|
+
const rawTransaction: string | null = await this.request<string>("tx/"+txId+"/hex", "str").catch((e: MempoolApiError) => {
|
|
429
|
+
if(e.responseMessage==="Transaction not found") return null;
|
|
430
430
|
throw e;
|
|
431
431
|
});
|
|
432
432
|
return rawTransaction==null ? null : Buffer.from(rawTransaction, "hex")
|