mainnet-js 1.1.34 → 2.0.0
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.
- package/dist/index.html +1 -1
- package/dist/{mainnet-1.1.34.js → mainnet-2.0.0.js} +25 -337
- package/dist/module/db/SqlProvider.d.ts +2 -2
- package/dist/module/db/SqlProvider.d.ts.map +1 -1
- package/dist/module/db/SqlProvider.js +6 -24
- package/dist/module/db/SqlProvider.js.map +1 -1
- package/dist/module/index.d.ts +0 -3
- package/dist/module/index.d.ts.map +1 -1
- package/dist/module/index.js +3 -6
- package/dist/module/index.js.map +1 -1
- package/dist/module/transaction/Wif.d.ts +4 -8
- package/dist/module/transaction/Wif.d.ts.map +1 -1
- package/dist/module/transaction/Wif.js +6 -10
- package/dist/module/transaction/Wif.js.map +1 -1
- package/dist/module/util/deriveCashaddr.d.ts +1 -0
- package/dist/module/util/deriveCashaddr.d.ts.map +1 -1
- package/dist/module/util/deriveCashaddr.js +8 -1
- package/dist/module/util/deriveCashaddr.js.map +1 -1
- package/dist/module/wallet/Base.d.ts +1 -1
- package/dist/module/wallet/Base.js +1 -1
- package/dist/module/wallet/Util.d.ts +2 -2
- package/dist/module/wallet/Util.js +2 -2
- package/dist/module/wallet/Wif.d.ts +0 -28
- package/dist/module/wallet/Wif.d.ts.map +1 -1
- package/dist/module/wallet/Wif.js +2 -109
- package/dist/module/wallet/Wif.js.map +1 -1
- package/dist/module/wallet/createWallet.d.ts +0 -12
- package/dist/module/wallet/createWallet.d.ts.map +1 -1
- package/dist/module/wallet/createWallet.js +0 -43
- package/dist/module/wallet/createWallet.js.map +1 -1
- package/dist/module/wallet/interface.d.ts +0 -2
- package/dist/module/wallet/interface.d.ts.map +1 -1
- package/dist/module/webhook/Webhook.d.ts +1 -6
- package/dist/module/webhook/Webhook.d.ts.map +1 -1
- package/dist/module/webhook/Webhook.js +0 -4
- package/dist/module/webhook/Webhook.js.map +1 -1
- package/dist/module/webhook/index.d.ts +0 -1
- package/dist/module/webhook/index.d.ts.map +1 -1
- package/dist/module/webhook/index.js +0 -1
- package/dist/module/webhook/index.js.map +1 -1
- package/dist/module/webhook/interface.d.ts +0 -1
- package/dist/module/webhook/interface.d.ts.map +1 -1
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/package.json +5 -10
- package/src/db/SqlProvider.test.ts +2 -18
- package/src/db/SqlProvider.ts +5 -26
- package/src/index.ts +3 -7
- package/src/transaction/Wif.ts +2 -19
- package/src/util/deriveCashaddr.test.ts +8 -0
- package/src/util/deriveCashaddr.ts +9 -0
- package/src/wallet/Base.ts +1 -1
- package/src/wallet/Util.ts +2 -2
- package/src/wallet/Wif.test.ts +0 -23
- package/src/wallet/Wif.ts +2 -148
- package/src/wallet/createWallet.ts +0 -53
- package/src/wallet/interface.ts +0 -2
- package/src/webhook/Webhook.ts +4 -10
- package/src/webhook/index.ts +0 -1
- package/src/webhook/interface.ts +0 -1
- package/webpack.config.cjs +7 -7
- package/dist/module/slp/GsppProvider.d.ts +0 -55
- package/dist/module/slp/GsppProvider.d.ts.map +0 -1
- package/dist/module/slp/GsppProvider.js +0 -204
- package/dist/module/slp/GsppProvider.js.map +0 -1
- package/dist/module/slp/SlpDbProvider.d.ts +0 -52
- package/dist/module/slp/SlpDbProvider.d.ts.map +0 -1
- package/dist/module/slp/SlpDbProvider.js +0 -175
- package/dist/module/slp/SlpDbProvider.js.map +0 -1
- package/dist/module/slp/SlpDbTemplates.d.ts +0 -313
- package/dist/module/slp/SlpDbTemplates.d.ts.map +0 -1
- package/dist/module/slp/SlpDbTemplates.js +0 -375
- package/dist/module/slp/SlpDbTemplates.js.map +0 -1
- package/dist/module/slp/SlpLibAuth.d.ts +0 -210
- package/dist/module/slp/SlpLibAuth.d.ts.map +0 -1
- package/dist/module/slp/SlpLibAuth.js +0 -451
- package/dist/module/slp/SlpLibAuth.js.map +0 -1
- package/dist/module/slp/SlpProvider.d.ts +0 -24
- package/dist/module/slp/SlpProvider.d.ts.map +0 -1
- package/dist/module/slp/SlpProvider.js +0 -29
- package/dist/module/slp/SlpProvider.js.map +0 -1
- package/dist/module/slp/index.d.ts +0 -6
- package/dist/module/slp/index.d.ts.map +0 -1
- package/dist/module/slp/index.js +0 -5
- package/dist/module/slp/index.js.map +0 -1
- package/dist/module/slp/interface.d.ts +0 -114
- package/dist/module/slp/interface.d.ts.map +0 -1
- package/dist/module/slp/interface.js +0 -7
- package/dist/module/slp/interface.js.map +0 -1
- package/dist/module/util/bchaddr.d.ts +0 -2
- package/dist/module/util/bchaddr.d.ts.map +0 -1
- package/dist/module/util/bchaddr.js +0 -16
- package/dist/module/util/bchaddr.js.map +0 -1
- package/dist/module/wallet/Slp.d.ts +0 -431
- package/dist/module/wallet/Slp.d.ts.map +0 -1
- package/dist/module/wallet/Slp.js +0 -770
- package/dist/module/wallet/Slp.js.map +0 -1
- package/dist/module/webhook/WebhookSlp.d.ts +0 -15
- package/dist/module/webhook/WebhookSlp.d.ts.map +0 -1
- package/dist/module/webhook/WebhookSlp.js +0 -100
- package/dist/module/webhook/WebhookSlp.js.map +0 -1
- package/src/slp/GsppProvider.test.ts +0 -40
- package/src/slp/GsppProvider.ts +0 -329
- package/src/slp/SlpDbProvider.test.ts +0 -27
- package/src/slp/SlpDbProvider.ts +0 -291
- package/src/slp/SlpDbTemplates.ts +0 -400
- package/src/slp/SlpLibAuth.test.ts +0 -162
- package/src/slp/SlpLibAuth.ts +0 -532
- package/src/slp/SlpProvider.ts +0 -100
- package/src/slp/index.ts +0 -6
- package/src/slp/interface.ts +0 -128
- package/src/util/bchaddr.test.ts +0 -27
- package/src/util/bchaddr.ts +0 -27
- package/src/wallet/Slp.test.headless.js +0 -120
- package/src/wallet/Slp.test.ts +0 -1000
- package/src/wallet/Slp.ts +0 -1014
- package/src/webhook/WebhookSlp.test.ts +0 -288
- package/src/webhook/WebhookSlp.ts +0 -123
|
@@ -1,288 +0,0 @@
|
|
|
1
|
-
import WebhookWorker from "./WebhookWorker";
|
|
2
|
-
import { RegTestWallet } from "../wallet/Wif";
|
|
3
|
-
import { mine } from "../mine/mine";
|
|
4
|
-
import { Webhook, WebhookRecurrence, WebhookType } from "./Webhook";
|
|
5
|
-
import { GsppProvider, SlpDbProvider, SlpGenesisOptions } from "../slp";
|
|
6
|
-
|
|
7
|
-
let worker: WebhookWorker;
|
|
8
|
-
let alice;
|
|
9
|
-
let aliceWif;
|
|
10
|
-
let tokenId;
|
|
11
|
-
|
|
12
|
-
const serversSlpDb = { ...{}, ...SlpDbProvider.defaultServers };
|
|
13
|
-
const serversGspp = { ...{}, ...GsppProvider.defaultServers };
|
|
14
|
-
|
|
15
|
-
/**
|
|
16
|
-
* @jest-environment jsdom
|
|
17
|
-
*/
|
|
18
|
-
describe.skip("Webhook worker tests", () => {
|
|
19
|
-
beforeAll(async () => {
|
|
20
|
-
try {
|
|
21
|
-
if (process.env.PRIVATE_WIF) {
|
|
22
|
-
alice = process.env.ADDRESS!;
|
|
23
|
-
aliceWif = `wif:regtest:${process.env.PRIVATE_WIF!}`;
|
|
24
|
-
} else {
|
|
25
|
-
console.error("regtest env vars not set");
|
|
26
|
-
}
|
|
27
|
-
|
|
28
|
-
Webhook.debug.setupAxiosMocks();
|
|
29
|
-
worker = await WebhookWorker.instance();
|
|
30
|
-
|
|
31
|
-
const genesisOptions: SlpGenesisOptions = {
|
|
32
|
-
name: "Webhook Token",
|
|
33
|
-
ticker: "WHT",
|
|
34
|
-
decimals: 2,
|
|
35
|
-
initialAmount: 10000,
|
|
36
|
-
documentUrl: "https://mainnet.cash",
|
|
37
|
-
documentHash:
|
|
38
|
-
"0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef",
|
|
39
|
-
};
|
|
40
|
-
|
|
41
|
-
const aliceWallet = await RegTestWallet.slp.fromId(aliceWif);
|
|
42
|
-
const genesisResult = await aliceWallet.slp.genesis(genesisOptions);
|
|
43
|
-
tokenId = genesisResult.tokenId;
|
|
44
|
-
|
|
45
|
-
SlpDbProvider.defaultServers.testnet =
|
|
46
|
-
SlpDbProvider.defaultServers.regtest;
|
|
47
|
-
GsppProvider.defaultServers.testnet = GsppProvider.defaultServers.regtest;
|
|
48
|
-
} catch (e: any) {
|
|
49
|
-
throw e;
|
|
50
|
-
}
|
|
51
|
-
});
|
|
52
|
-
|
|
53
|
-
beforeEach(async () => {
|
|
54
|
-
worker.deleteAllWebhooks();
|
|
55
|
-
});
|
|
56
|
-
|
|
57
|
-
afterEach(async () => {
|
|
58
|
-
Webhook.debug.reset();
|
|
59
|
-
});
|
|
60
|
-
|
|
61
|
-
afterAll(async () => {
|
|
62
|
-
await worker.destroy();
|
|
63
|
-
await worker.db.close();
|
|
64
|
-
|
|
65
|
-
SlpDbProvider.defaultServers = serversSlpDb;
|
|
66
|
-
GsppProvider.defaultServers = serversGspp;
|
|
67
|
-
});
|
|
68
|
-
|
|
69
|
-
test("Test non-recurrent hook to be deleted after successful call", async () => {
|
|
70
|
-
try {
|
|
71
|
-
const aliceWallet = await RegTestWallet.slp.fromId(aliceWif);
|
|
72
|
-
const bobWallet = await RegTestWallet.slp.newRandom();
|
|
73
|
-
await worker.registerWebhook({
|
|
74
|
-
cashaddr: bobWallet.slp.slpaddr,
|
|
75
|
-
url: "http://example.com/success",
|
|
76
|
-
type: WebhookType.slpTransactionIn,
|
|
77
|
-
recurrence: WebhookRecurrence.once,
|
|
78
|
-
tokenId: tokenId,
|
|
79
|
-
});
|
|
80
|
-
|
|
81
|
-
await Promise.all([
|
|
82
|
-
aliceWallet.slp.send([
|
|
83
|
-
{
|
|
84
|
-
slpaddr: bobWallet.slp.slpaddr,
|
|
85
|
-
value: 1000,
|
|
86
|
-
tokenId: tokenId,
|
|
87
|
-
},
|
|
88
|
-
]),
|
|
89
|
-
bobWallet.slp.waitForTransaction(),
|
|
90
|
-
]);
|
|
91
|
-
|
|
92
|
-
// return funds
|
|
93
|
-
// let sendResponse2 = await bobWallet.sendMax(aliceWallet.cashaddr!);
|
|
94
|
-
|
|
95
|
-
await new Promise((resolve) =>
|
|
96
|
-
setTimeout(async () => {
|
|
97
|
-
expect(
|
|
98
|
-
Webhook.debug.responses["http://example.com/success"].length
|
|
99
|
-
).toBe(1);
|
|
100
|
-
expect(worker.activeHooks.size).toBe(0);
|
|
101
|
-
|
|
102
|
-
resolve(true);
|
|
103
|
-
}, 3000)
|
|
104
|
-
);
|
|
105
|
-
} catch (e: any) {
|
|
106
|
-
console.log(e, e.stack, e.message);
|
|
107
|
-
throw e;
|
|
108
|
-
}
|
|
109
|
-
});
|
|
110
|
-
|
|
111
|
-
test("Test non-recurrent hook to be not deleted after failed call", async () => {
|
|
112
|
-
try {
|
|
113
|
-
const aliceWallet = await RegTestWallet.slp.fromId(aliceWif);
|
|
114
|
-
const bobWallet = await RegTestWallet.slp.newRandom();
|
|
115
|
-
await worker.registerWebhook({
|
|
116
|
-
cashaddr: bobWallet.slp.slpaddr,
|
|
117
|
-
url: "http://example.com/fail",
|
|
118
|
-
type: WebhookType.slpTransactionIn,
|
|
119
|
-
recurrence: WebhookRecurrence.once,
|
|
120
|
-
tokenId: tokenId,
|
|
121
|
-
});
|
|
122
|
-
|
|
123
|
-
await Promise.all([
|
|
124
|
-
aliceWallet.slp.send([
|
|
125
|
-
{
|
|
126
|
-
slpaddr: bobWallet.slp.slpaddr,
|
|
127
|
-
value: 1000,
|
|
128
|
-
tokenId: tokenId,
|
|
129
|
-
},
|
|
130
|
-
]),
|
|
131
|
-
bobWallet.slp.waitForTransaction(),
|
|
132
|
-
]);
|
|
133
|
-
|
|
134
|
-
await new Promise((resolve) =>
|
|
135
|
-
setTimeout(async () => {
|
|
136
|
-
expect(
|
|
137
|
-
Webhook.debug.responses["http://example.com/fail"].length
|
|
138
|
-
).toBe(1);
|
|
139
|
-
expect(worker.activeHooks.size).toBe(1);
|
|
140
|
-
|
|
141
|
-
// return funds
|
|
142
|
-
// let sendResponse2 = await bobWallet.sendMax(aliceWallet.cashaddr!);
|
|
143
|
-
resolve(true);
|
|
144
|
-
}, 3000)
|
|
145
|
-
);
|
|
146
|
-
} catch (e: any) {
|
|
147
|
-
console.log(e, e.stack, e.message);
|
|
148
|
-
throw e;
|
|
149
|
-
}
|
|
150
|
-
});
|
|
151
|
-
|
|
152
|
-
test("Test recurrent hook for incoming transaction", async () => {
|
|
153
|
-
try {
|
|
154
|
-
const aliceWallet = await RegTestWallet.slp.fromId(aliceWif);
|
|
155
|
-
const bobWallet = await RegTestWallet.slp.newRandom();
|
|
156
|
-
await worker.registerWebhook({
|
|
157
|
-
cashaddr: bobWallet.slp.slpaddr,
|
|
158
|
-
url: "http://example.com/bob",
|
|
159
|
-
type: WebhookType.slpTransactionIn,
|
|
160
|
-
recurrence: WebhookRecurrence.recurrent,
|
|
161
|
-
tokenId: tokenId,
|
|
162
|
-
});
|
|
163
|
-
|
|
164
|
-
await Promise.all([
|
|
165
|
-
aliceWallet.slp.send([
|
|
166
|
-
{
|
|
167
|
-
slpaddr: bobWallet.slp.slpaddr,
|
|
168
|
-
value: 1000,
|
|
169
|
-
tokenId: tokenId,
|
|
170
|
-
},
|
|
171
|
-
]),
|
|
172
|
-
bobWallet.slp.waitForTransaction(),
|
|
173
|
-
]);
|
|
174
|
-
|
|
175
|
-
// return funds
|
|
176
|
-
// let sendResponse2 = await bobWallet.sendMax(aliceWallet.cashaddr!);
|
|
177
|
-
|
|
178
|
-
await new Promise((resolve) =>
|
|
179
|
-
setTimeout(async () => {
|
|
180
|
-
expect(Webhook.debug.responses["http://example.com/bob"].length).toBe(
|
|
181
|
-
1
|
|
182
|
-
);
|
|
183
|
-
expect(worker.activeHooks.size).toBe(1);
|
|
184
|
-
|
|
185
|
-
resolve(true);
|
|
186
|
-
}, 3000)
|
|
187
|
-
);
|
|
188
|
-
} catch (e: any) {
|
|
189
|
-
console.log(e, e.stack, e.message);
|
|
190
|
-
throw e;
|
|
191
|
-
}
|
|
192
|
-
});
|
|
193
|
-
|
|
194
|
-
test("Test recurrent hook for outgoing transactions", async () => {
|
|
195
|
-
try {
|
|
196
|
-
const aliceWallet = await RegTestWallet.slp.fromId(aliceWif);
|
|
197
|
-
const bobWallet = await RegTestWallet.slp.newRandom();
|
|
198
|
-
await worker.registerWebhook({
|
|
199
|
-
cashaddr: bobWallet.slp.slpaddr,
|
|
200
|
-
url: "http://example.com/bob",
|
|
201
|
-
type: WebhookType.slpTransactionOut,
|
|
202
|
-
recurrence: WebhookRecurrence.recurrent,
|
|
203
|
-
tokenId: tokenId,
|
|
204
|
-
});
|
|
205
|
-
|
|
206
|
-
await aliceWallet.send([
|
|
207
|
-
{
|
|
208
|
-
cashaddr: bobWallet.cashaddr!,
|
|
209
|
-
value: 1000,
|
|
210
|
-
unit: "satoshi",
|
|
211
|
-
},
|
|
212
|
-
]);
|
|
213
|
-
|
|
214
|
-
await Promise.all([
|
|
215
|
-
aliceWallet.slp.send([
|
|
216
|
-
{
|
|
217
|
-
slpaddr: bobWallet.slp.slpaddr,
|
|
218
|
-
value: 1000,
|
|
219
|
-
tokenId: tokenId,
|
|
220
|
-
},
|
|
221
|
-
]),
|
|
222
|
-
bobWallet.slp.waitForTransaction(),
|
|
223
|
-
]);
|
|
224
|
-
|
|
225
|
-
// return funds
|
|
226
|
-
await Promise.all([
|
|
227
|
-
bobWallet.slp.sendMax(aliceWallet.cashaddr!, tokenId),
|
|
228
|
-
aliceWallet.slp.waitForTransaction(),
|
|
229
|
-
]);
|
|
230
|
-
|
|
231
|
-
await new Promise((resolve) =>
|
|
232
|
-
setTimeout(async () => {
|
|
233
|
-
expect(Webhook.debug.responses["http://example.com/bob"].length).toBe(
|
|
234
|
-
1
|
|
235
|
-
);
|
|
236
|
-
expect(worker.activeHooks.size).toBe(1);
|
|
237
|
-
|
|
238
|
-
resolve(true);
|
|
239
|
-
}, 3000)
|
|
240
|
-
);
|
|
241
|
-
} catch (e: any) {
|
|
242
|
-
console.log(e, e.stack, e.message);
|
|
243
|
-
throw e;
|
|
244
|
-
}
|
|
245
|
-
});
|
|
246
|
-
|
|
247
|
-
test("Test non-recurrent watch balance hook", async () => {
|
|
248
|
-
try {
|
|
249
|
-
const aliceWallet = await RegTestWallet.slp.fromId(aliceWif);
|
|
250
|
-
const bobWallet = await RegTestWallet.slp.newRandom();
|
|
251
|
-
await worker.registerWebhook({
|
|
252
|
-
cashaddr: bobWallet.slp.slpaddr,
|
|
253
|
-
url: "http://example.com/watchBalance",
|
|
254
|
-
type: WebhookType.slpBalance,
|
|
255
|
-
recurrence: WebhookRecurrence.once,
|
|
256
|
-
tokenId: tokenId,
|
|
257
|
-
});
|
|
258
|
-
|
|
259
|
-
await Promise.all([
|
|
260
|
-
aliceWallet.slp.send([
|
|
261
|
-
{
|
|
262
|
-
slpaddr: bobWallet.slp.slpaddr,
|
|
263
|
-
value: 1000,
|
|
264
|
-
tokenId: tokenId,
|
|
265
|
-
},
|
|
266
|
-
]),
|
|
267
|
-
bobWallet.slp.waitForTransaction(),
|
|
268
|
-
]);
|
|
269
|
-
|
|
270
|
-
// return funds
|
|
271
|
-
// let sendResponse2 = await bobWallet.sendMax(aliceWallet.cashaddr!);
|
|
272
|
-
|
|
273
|
-
await new Promise((resolve) =>
|
|
274
|
-
setTimeout(async () => {
|
|
275
|
-
expect(
|
|
276
|
-
Webhook.debug.responses["http://example.com/watchBalance"].length
|
|
277
|
-
).toBe(1);
|
|
278
|
-
expect(worker.activeHooks.size).toBe(0);
|
|
279
|
-
|
|
280
|
-
resolve(true);
|
|
281
|
-
}, 3000)
|
|
282
|
-
);
|
|
283
|
-
} catch (e: any) {
|
|
284
|
-
console.log(e, e.stack, e.message);
|
|
285
|
-
throw e;
|
|
286
|
-
}
|
|
287
|
-
});
|
|
288
|
-
});
|
|
@@ -1,123 +0,0 @@
|
|
|
1
|
-
import { GsppTx, SlpDbTx, SlpTxI } from "../slp/index.js";
|
|
2
|
-
import {
|
|
3
|
-
SlpCancelWatchFn,
|
|
4
|
-
SlpWatchTransactionCallback,
|
|
5
|
-
} from "../slp/SlpProvider.js";
|
|
6
|
-
import { toSlpAddress } from "../util/bchaddr.js";
|
|
7
|
-
import { Wallet } from "../wallet/Wif.js";
|
|
8
|
-
import { Webhook, WebhookRecurrence, WebhookType } from "./Webhook.js";
|
|
9
|
-
import WebhookWorker from "./WebhookWorker.js";
|
|
10
|
-
|
|
11
|
-
export class WebhookSlp extends Webhook {
|
|
12
|
-
callback!: SlpWatchTransactionCallback;
|
|
13
|
-
cancelFn!: SlpCancelWatchFn;
|
|
14
|
-
wallet!: Wallet;
|
|
15
|
-
|
|
16
|
-
constructor(hook: Webhook | Object) {
|
|
17
|
-
super(hook);
|
|
18
|
-
Object.assign(this, hook);
|
|
19
|
-
this.cashaddr = toSlpAddress(this.cashaddr);
|
|
20
|
-
}
|
|
21
|
-
|
|
22
|
-
async start(): Promise<void> {
|
|
23
|
-
const webhookCallback: SlpWatchTransactionCallback = async (
|
|
24
|
-
rawTx: SlpTxI
|
|
25
|
-
) => {
|
|
26
|
-
let result = false;
|
|
27
|
-
if ("_id" in rawTx.details) {
|
|
28
|
-
result = await this.slpDbHandler(rawTx);
|
|
29
|
-
} else {
|
|
30
|
-
result = await this.gsppHandler(rawTx);
|
|
31
|
-
}
|
|
32
|
-
|
|
33
|
-
if (result && this.recurrence === WebhookRecurrence.once) {
|
|
34
|
-
// we have to notify the worker about end of life
|
|
35
|
-
await (await WebhookWorker.instance()).stopHook(this);
|
|
36
|
-
await this.destroy();
|
|
37
|
-
}
|
|
38
|
-
};
|
|
39
|
-
|
|
40
|
-
this.callback = webhookCallback;
|
|
41
|
-
this.wallet = await Wallet.fromSlpaddr(this.cashaddr);
|
|
42
|
-
this.cancelFn = this.wallet.slp.watchTransactions(
|
|
43
|
-
webhookCallback,
|
|
44
|
-
this.tokenId
|
|
45
|
-
);
|
|
46
|
-
}
|
|
47
|
-
|
|
48
|
-
async slpDbHandler(rawTx: SlpTxI) {
|
|
49
|
-
let result: boolean = false;
|
|
50
|
-
const txDirection = this.type;
|
|
51
|
-
const details: SlpDbTx = rawTx.details as SlpDbTx;
|
|
52
|
-
if (this.type === WebhookType.slpTransactionInOut) {
|
|
53
|
-
result = await this.post({
|
|
54
|
-
direction: txDirection,
|
|
55
|
-
data: rawTx,
|
|
56
|
-
});
|
|
57
|
-
} else if (
|
|
58
|
-
this.type === WebhookType.slpTransactionIn &&
|
|
59
|
-
details.out.findIndex((val) => val.e.a === this.cashaddr) > -1
|
|
60
|
-
) {
|
|
61
|
-
result = await this.post({
|
|
62
|
-
direction: txDirection,
|
|
63
|
-
data: rawTx,
|
|
64
|
-
});
|
|
65
|
-
} else if (
|
|
66
|
-
this.type === WebhookType.slpTransactionOut &&
|
|
67
|
-
details.in.findIndex((val) => val.e.a === this.cashaddr) > -1
|
|
68
|
-
) {
|
|
69
|
-
result = await this.post({
|
|
70
|
-
direction: txDirection,
|
|
71
|
-
data: rawTx,
|
|
72
|
-
});
|
|
73
|
-
} else if (this.type === WebhookType.slpBalance) {
|
|
74
|
-
const balance = this.wallet.slp.getBalance(this.tokenId!);
|
|
75
|
-
result = await this.post({
|
|
76
|
-
direction: txDirection,
|
|
77
|
-
data: balance,
|
|
78
|
-
});
|
|
79
|
-
}
|
|
80
|
-
|
|
81
|
-
return result;
|
|
82
|
-
}
|
|
83
|
-
|
|
84
|
-
async gsppHandler(rawTx: SlpTxI) {
|
|
85
|
-
let result: boolean = false;
|
|
86
|
-
const txDirection = this.type;
|
|
87
|
-
const details: GsppTx = rawTx.details as GsppTx;
|
|
88
|
-
if (this.type === WebhookType.slpTransactionInOut) {
|
|
89
|
-
result = await this.post({
|
|
90
|
-
direction: txDirection,
|
|
91
|
-
data: rawTx,
|
|
92
|
-
});
|
|
93
|
-
} else if (
|
|
94
|
-
this.type === WebhookType.slpTransactionIn &&
|
|
95
|
-
details.outputs.findIndex((val) => val === this.cashaddr) > -1
|
|
96
|
-
) {
|
|
97
|
-
result = await this.post({
|
|
98
|
-
direction: txDirection,
|
|
99
|
-
data: rawTx,
|
|
100
|
-
});
|
|
101
|
-
} else if (
|
|
102
|
-
this.type === WebhookType.slpTransactionOut &&
|
|
103
|
-
details.inputs.findIndex((val) => val === this.cashaddr) > -1
|
|
104
|
-
) {
|
|
105
|
-
result = await this.post({
|
|
106
|
-
direction: txDirection,
|
|
107
|
-
data: rawTx,
|
|
108
|
-
});
|
|
109
|
-
} else if (this.type === WebhookType.slpBalance) {
|
|
110
|
-
const balance = this.wallet.slp.getBalance(this.tokenId!);
|
|
111
|
-
result = await this.post({
|
|
112
|
-
direction: txDirection,
|
|
113
|
-
data: balance,
|
|
114
|
-
});
|
|
115
|
-
}
|
|
116
|
-
|
|
117
|
-
return result;
|
|
118
|
-
}
|
|
119
|
-
|
|
120
|
-
async stop(): Promise<void> {
|
|
121
|
-
await this.cancelFn();
|
|
122
|
-
}
|
|
123
|
-
}
|