@teleportdao/bitcoin 1.8.9 → 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/.tmp/block-parser.ts +58 -0
- package/dist/bitcoin-interface-ordinal.d.ts +2 -2
- package/dist/bitcoin-interface-ordinal.d.ts.map +1 -1
- package/dist/bitcoin-interface-ordinal.js +1 -1
- package/dist/bitcoin-interface-ordinal.js.map +1 -1
- package/dist/bitcoin-interface-teleswap.d.ts +2 -53
- package/dist/bitcoin-interface-teleswap.d.ts.map +1 -1
- package/dist/bitcoin-interface-teleswap.js +6 -17
- package/dist/bitcoin-interface-teleswap.js.map +1 -1
- package/dist/bitcoin-interface-wallet.d.ts +29 -0
- package/dist/bitcoin-interface-wallet.d.ts.map +1 -0
- package/dist/bitcoin-interface-wallet.js +126 -0
- package/dist/bitcoin-interface-wallet.js.map +1 -0
- package/dist/bitcoin-interface.d.ts +5 -23
- package/dist/bitcoin-interface.d.ts.map +1 -1
- package/dist/bitcoin-interface.js +13 -92
- package/dist/bitcoin-interface.js.map +1 -1
- package/dist/bitcoin-wallet-base.d.ts +55 -31
- package/dist/bitcoin-wallet-base.d.ts.map +1 -1
- package/dist/bitcoin-wallet-base.js +105 -84
- package/dist/bitcoin-wallet-base.js.map +1 -1
- package/dist/ordinal-wallet.d.ts +29 -71
- package/dist/ordinal-wallet.d.ts.map +1 -1
- package/dist/ordinal-wallet.js +48 -108
- package/dist/ordinal-wallet.js.map +1 -1
- package/dist/teleswap-wallet.d.ts +10 -16
- package/dist/teleswap-wallet.d.ts.map +1 -1
- package/dist/teleswap-wallet.js +10 -30
- package/dist/teleswap-wallet.js.map +1 -1
- package/dist/transaction-builder/bitcoin-transaction-builder.d.ts +4 -11
- package/dist/transaction-builder/bitcoin-transaction-builder.d.ts.map +1 -1
- package/dist/transaction-builder/bitcoin-transaction-builder.js +2 -23
- package/dist/transaction-builder/bitcoin-transaction-builder.js.map +1 -1
- package/dist/transaction-builder/ordinal-transaction-builder.d.ts +3 -2
- package/dist/transaction-builder/ordinal-transaction-builder.d.ts.map +1 -1
- package/dist/transaction-builder/ordinal-transaction-builder.js +1 -6
- package/dist/transaction-builder/ordinal-transaction-builder.js.map +1 -1
- package/dist/transaction-builder/transaction-builder.d.ts +3 -7
- package/dist/transaction-builder/transaction-builder.d.ts.map +1 -1
- package/dist/transaction-builder/transaction-builder.js +22 -49
- package/dist/transaction-builder/transaction-builder.js.map +1 -1
- package/dist/type.d.ts +33 -18
- package/dist/type.d.ts.map +1 -1
- package/package.json +4 -4
- package/src/bitcoin-interface-ordinal.ts +7 -3
- package/src/bitcoin-interface-teleswap.ts +7 -22
- package/src/bitcoin-interface-wallet.ts +114 -0
- package/src/bitcoin-interface.ts +15 -98
- package/src/bitcoin-wallet-base.ts +166 -132
- package/src/ordinal-wallet.ts +73 -162
- package/src/teleswap-wallet.ts +50 -72
- package/src/transaction-builder/bitcoin-transaction-builder.ts +6 -24
- package/src/transaction-builder/ordinal-transaction-builder.ts +2 -10
- package/src/transaction-builder/transaction-builder.ts +34 -50
- package/src/type.ts +45 -19
package/dist/ordinal-wallet.d.ts
CHANGED
|
@@ -3,19 +3,18 @@ import { bitcoin as bitcoinProviders } from "@teleportdao/providers";
|
|
|
3
3
|
import { OrdinalTransactionBuilder } from "./transaction-builder/ordinal-transaction-builder";
|
|
4
4
|
import BitcoinSign from "./sign/sign-transaction";
|
|
5
5
|
import { BitcoinInterfaceOrdinal } from "./bitcoin-interface-ordinal";
|
|
6
|
-
import { BitcoinConnectionInfo } from "./type";
|
|
7
6
|
import { ChangeTarget, ExtendedUtxo, SignerInfo, Target } from "./transaction-builder";
|
|
8
|
-
import { BitcoinBaseWallet } from "./bitcoin-wallet-base";
|
|
7
|
+
import { BitcoinBaseWallet, FeeRateType } from "./bitcoin-wallet-base";
|
|
8
|
+
import { RPCConnectionInfo, UtxoConnectionInfo } from "./type";
|
|
9
9
|
declare class OrdinalWallet extends BitcoinBaseWallet {
|
|
10
10
|
unisat: bitcoinProviders.UniSat;
|
|
11
11
|
transactionBuilder: OrdinalTransactionBuilder;
|
|
12
12
|
btcInterface: BitcoinInterfaceOrdinal;
|
|
13
13
|
signer: BitcoinSign;
|
|
14
|
-
constructor(networkName: string, uniSatToken: string, connectionInfo
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
}): Promise<string>;
|
|
14
|
+
constructor(networkName: string, uniSatToken: string, connectionInfo: {
|
|
15
|
+
rpc: RPCConnectionInfo;
|
|
16
|
+
utxo?: UtxoConnectionInfo;
|
|
17
|
+
});
|
|
19
18
|
static deployBRC20Data(tickName: string, max: number | string, limit: number | string): {
|
|
20
19
|
buffer: Buffer;
|
|
21
20
|
type: string;
|
|
@@ -28,53 +27,11 @@ declare class OrdinalWallet extends BitcoinBaseWallet {
|
|
|
28
27
|
buffer: Buffer;
|
|
29
28
|
type: string;
|
|
30
29
|
};
|
|
31
|
-
sendUsingUtxosUnsigned({ receivers, speed, utxo, changeAddress, staticFeeRate, }: {
|
|
32
|
-
receivers: {
|
|
33
|
-
address: string;
|
|
34
|
-
value: number;
|
|
35
|
-
}[];
|
|
36
|
-
changeAddress: string;
|
|
37
|
-
speed?: "normal" | "fast" | "slow";
|
|
38
|
-
staticFeeRate?: number;
|
|
39
|
-
utxo: ExtendedUtxo[];
|
|
40
|
-
}): Promise<{
|
|
41
|
-
possibleTxId: string;
|
|
42
|
-
unsignedTransaction: string;
|
|
43
|
-
outputs: Target[];
|
|
44
|
-
inputs: {
|
|
45
|
-
hash: string;
|
|
46
|
-
value: number;
|
|
47
|
-
index: number;
|
|
48
|
-
signerInfo: SignerInfo;
|
|
49
|
-
}[];
|
|
50
|
-
fee: number;
|
|
51
|
-
change: ChangeTarget | undefined;
|
|
52
|
-
}>;
|
|
53
|
-
sendUsingUtxos({ receivers, speed, utxo, }: {
|
|
54
|
-
receivers: {
|
|
55
|
-
address: string;
|
|
56
|
-
value: number;
|
|
57
|
-
}[];
|
|
58
|
-
speed?: "normal" | "fast" | "slow";
|
|
59
|
-
utxo?: ExtendedUtxo[];
|
|
60
|
-
}): Promise<{
|
|
61
|
-
txId: string;
|
|
62
|
-
inputs: {
|
|
63
|
-
hash: string;
|
|
64
|
-
value: number;
|
|
65
|
-
index: number;
|
|
66
|
-
signerInfo: SignerInfo;
|
|
67
|
-
}[];
|
|
68
|
-
outputs: Target[];
|
|
69
|
-
change: ChangeTarget | undefined;
|
|
70
|
-
fee: number;
|
|
71
|
-
}>;
|
|
72
30
|
inscribeOrdinalDepositUnsigned(file: {
|
|
73
31
|
buffer: Buffer;
|
|
74
32
|
type: string;
|
|
75
|
-
}, signer: SignerInfo, ordinalSigner?: SignerInfo, extendedUtxo?: ExtendedUtxo[]
|
|
33
|
+
}, signer: SignerInfo, ordinalSigner?: SignerInfo, fee?: FeeRateType, extendedUtxo?: ExtendedUtxo[]): Promise<{
|
|
76
34
|
inscribeDepositUnsignedInfo: {
|
|
77
|
-
possibleTxId: string;
|
|
78
35
|
unsignedTransaction: string;
|
|
79
36
|
outputs: Target[];
|
|
80
37
|
inputs: {
|
|
@@ -85,6 +42,7 @@ declare class OrdinalWallet extends BitcoinBaseWallet {
|
|
|
85
42
|
}[];
|
|
86
43
|
fee: number;
|
|
87
44
|
change: ChangeTarget | undefined;
|
|
45
|
+
possibleTxId: string | undefined;
|
|
88
46
|
};
|
|
89
47
|
transferOrdinal: {
|
|
90
48
|
ordinalAddress: string;
|
|
@@ -99,9 +57,8 @@ declare class OrdinalWallet extends BitcoinBaseWallet {
|
|
|
99
57
|
inscribeOrdinalUnsigned(file: {
|
|
100
58
|
buffer: Buffer;
|
|
101
59
|
type: string;
|
|
102
|
-
}, signer: SignerInfo, ordinalSigner?: SignerInfo, extendedUtxo?: ExtendedUtxo[]
|
|
60
|
+
}, signer: SignerInfo, ordinalSigner?: SignerInfo, fee?: FeeRateType, extendedUtxo?: ExtendedUtxo[]): Promise<{
|
|
103
61
|
inscribeDepositUnsignedInfo: {
|
|
104
|
-
possibleTxId: string;
|
|
105
62
|
unsignedTransaction: string;
|
|
106
63
|
outputs: Target[];
|
|
107
64
|
inputs: {
|
|
@@ -112,9 +69,9 @@ declare class OrdinalWallet extends BitcoinBaseWallet {
|
|
|
112
69
|
}[];
|
|
113
70
|
fee: number;
|
|
114
71
|
change: ChangeTarget | undefined;
|
|
72
|
+
possibleTxId: string | undefined;
|
|
115
73
|
};
|
|
116
74
|
inscribeUnsignedInfo: {
|
|
117
|
-
possibleTxId: string;
|
|
118
75
|
unsignedTransaction: string;
|
|
119
76
|
inputs: {
|
|
120
77
|
hash: string;
|
|
@@ -126,6 +83,7 @@ declare class OrdinalWallet extends BitcoinBaseWallet {
|
|
|
126
83
|
address: string;
|
|
127
84
|
}[];
|
|
128
85
|
fee: number;
|
|
86
|
+
possibleTxId: string;
|
|
129
87
|
};
|
|
130
88
|
inscribeAddress: string;
|
|
131
89
|
receiverAddress: string;
|
|
@@ -133,7 +91,7 @@ declare class OrdinalWallet extends BitcoinBaseWallet {
|
|
|
133
91
|
inscribeOrdinal(file: {
|
|
134
92
|
buffer: Buffer;
|
|
135
93
|
type: string;
|
|
136
|
-
}, extendedUtxo?: ExtendedUtxo[],
|
|
94
|
+
}, fee?: FeeRateType, extendedUtxo?: ExtendedUtxo[], ordinalReceiverAddress?: string): Promise<{
|
|
137
95
|
inscribeTx: {
|
|
138
96
|
hash: string;
|
|
139
97
|
index: number;
|
|
@@ -158,7 +116,7 @@ declare class OrdinalWallet extends BitcoinBaseWallet {
|
|
|
158
116
|
tick: string;
|
|
159
117
|
max: number;
|
|
160
118
|
limit: number;
|
|
161
|
-
}, extendedUtxo?: ExtendedUtxo[]
|
|
119
|
+
}, fee?: FeeRateType, extendedUtxo?: ExtendedUtxo[]): Promise<{
|
|
162
120
|
inscribeTx: {
|
|
163
121
|
hash: string;
|
|
164
122
|
index: number;
|
|
@@ -182,7 +140,7 @@ declare class OrdinalWallet extends BitcoinBaseWallet {
|
|
|
182
140
|
mintBrc20(brc: {
|
|
183
141
|
tick: string;
|
|
184
142
|
amount: number | string;
|
|
185
|
-
}, extendedUtxo?: ExtendedUtxo[]
|
|
143
|
+
}, fee?: FeeRateType, extendedUtxo?: ExtendedUtxo[]): Promise<{
|
|
186
144
|
inscribeTx: {
|
|
187
145
|
hash: string;
|
|
188
146
|
index: number;
|
|
@@ -206,9 +164,8 @@ declare class OrdinalWallet extends BitcoinBaseWallet {
|
|
|
206
164
|
inscribeBrc20Unsigned(brc: {
|
|
207
165
|
tick: string;
|
|
208
166
|
amount: number | string;
|
|
209
|
-
}, signer: SignerInfo, ordinalSigner?: SignerInfo, extendedUtxo?: ExtendedUtxo[]
|
|
167
|
+
}, signer: SignerInfo, ordinalSigner?: SignerInfo, fee?: FeeRateType, extendedUtxo?: ExtendedUtxo[]): Promise<{
|
|
210
168
|
inscribeDepositUnsignedInfo: {
|
|
211
|
-
possibleTxId: string;
|
|
212
169
|
unsignedTransaction: string;
|
|
213
170
|
outputs: Target[];
|
|
214
171
|
inputs: {
|
|
@@ -219,9 +176,9 @@ declare class OrdinalWallet extends BitcoinBaseWallet {
|
|
|
219
176
|
}[];
|
|
220
177
|
fee: number;
|
|
221
178
|
change: ChangeTarget | undefined;
|
|
179
|
+
possibleTxId: string | undefined;
|
|
222
180
|
};
|
|
223
181
|
inscribeUnsignedInfo: {
|
|
224
|
-
possibleTxId: string;
|
|
225
182
|
unsignedTransaction: string;
|
|
226
183
|
inputs: {
|
|
227
184
|
hash: string;
|
|
@@ -233,6 +190,7 @@ declare class OrdinalWallet extends BitcoinBaseWallet {
|
|
|
233
190
|
address: string;
|
|
234
191
|
}[];
|
|
235
192
|
fee: number;
|
|
193
|
+
possibleTxId: string;
|
|
236
194
|
};
|
|
237
195
|
inscribeAddress: string;
|
|
238
196
|
receiverAddress: string;
|
|
@@ -240,7 +198,7 @@ declare class OrdinalWallet extends BitcoinBaseWallet {
|
|
|
240
198
|
inscribeBrc20(brc: {
|
|
241
199
|
tick: string;
|
|
242
200
|
amount: number | string;
|
|
243
|
-
}, extendedUtxo?: ExtendedUtxo[]
|
|
201
|
+
}, fee?: FeeRateType, extendedUtxo?: ExtendedUtxo[]): Promise<{
|
|
244
202
|
inscribeTx: {
|
|
245
203
|
hash: string;
|
|
246
204
|
index: number;
|
|
@@ -265,7 +223,7 @@ declare class OrdinalWallet extends BitcoinBaseWallet {
|
|
|
265
223
|
hash: string;
|
|
266
224
|
value: number;
|
|
267
225
|
index: number;
|
|
268
|
-
}, signer: SignerInfo, ordinalSigner?: SignerInfo, extendedUtxo?: ExtendedUtxo[],
|
|
226
|
+
}, signer: SignerInfo, ordinalSigner?: SignerInfo, fee?: FeeRateType, extendedUtxo?: ExtendedUtxo[], otherTargets?: Target[]): Promise<{
|
|
269
227
|
possibleTxId: string;
|
|
270
228
|
unsignedTransaction: string;
|
|
271
229
|
outputs: Target[];
|
|
@@ -282,7 +240,7 @@ declare class OrdinalWallet extends BitcoinBaseWallet {
|
|
|
282
240
|
hash: string;
|
|
283
241
|
value: number;
|
|
284
242
|
index: number;
|
|
285
|
-
}, extendedUtxo: ExtendedUtxo[],
|
|
243
|
+
}, fee: FeeRateType | undefined, extendedUtxo: ExtendedUtxo[], otherTargets?: Target[]): Promise<{
|
|
286
244
|
hash: string;
|
|
287
245
|
index: number;
|
|
288
246
|
value: number;
|
|
@@ -298,9 +256,8 @@ declare class OrdinalWallet extends BitcoinBaseWallet {
|
|
|
298
256
|
inscribeAndTransferBrc20Unsigned(receiver: string, brc: {
|
|
299
257
|
tick: string;
|
|
300
258
|
amount: number | string;
|
|
301
|
-
}, signer: SignerInfo, ordinalSigner?: SignerInfo, otherTargets?: Target[], extendedUtxo?: ExtendedUtxo[]
|
|
259
|
+
}, signer: SignerInfo, ordinalSigner?: SignerInfo, otherTargets?: Target[], fee?: FeeRateType, extendedUtxo?: ExtendedUtxo[]): Promise<{
|
|
302
260
|
inscribeDepositUnsignedInfo: {
|
|
303
|
-
possibleTxId: string;
|
|
304
261
|
unsignedTransaction: string;
|
|
305
262
|
outputs: Target[];
|
|
306
263
|
inputs: {
|
|
@@ -311,9 +268,9 @@ declare class OrdinalWallet extends BitcoinBaseWallet {
|
|
|
311
268
|
}[];
|
|
312
269
|
fee: number;
|
|
313
270
|
change: ChangeTarget | undefined;
|
|
271
|
+
possibleTxId: string | undefined;
|
|
314
272
|
};
|
|
315
273
|
inscribeUnsignedInfo: {
|
|
316
|
-
possibleTxId: string;
|
|
317
274
|
unsignedTransaction: string;
|
|
318
275
|
inputs: {
|
|
319
276
|
hash: string;
|
|
@@ -325,6 +282,7 @@ declare class OrdinalWallet extends BitcoinBaseWallet {
|
|
|
325
282
|
address: string;
|
|
326
283
|
}[];
|
|
327
284
|
fee: number;
|
|
285
|
+
possibleTxId: string;
|
|
328
286
|
};
|
|
329
287
|
transferTxUnsignedInfo: {
|
|
330
288
|
possibleTxId: string;
|
|
@@ -344,7 +302,7 @@ declare class OrdinalWallet extends BitcoinBaseWallet {
|
|
|
344
302
|
inscribeAndTransferBrc20(receiver: string, brc: {
|
|
345
303
|
tick: string;
|
|
346
304
|
amount: number | string;
|
|
347
|
-
}, otherTargets?: Target[], extendedUtxo?: ExtendedUtxo[]
|
|
305
|
+
}, otherTargets?: Target[], fee?: FeeRateType, extendedUtxo?: ExtendedUtxo[]): Promise<{
|
|
348
306
|
transferTx: {
|
|
349
307
|
hash: string;
|
|
350
308
|
index: number;
|
|
@@ -401,12 +359,11 @@ declare class OrdinalWallet extends BitcoinBaseWallet {
|
|
|
401
359
|
}, brc20TokenId: number, signer: SignerInfo, lockerAddress: string, exchange?: {
|
|
402
360
|
outputToken: string;
|
|
403
361
|
outputAmount: string;
|
|
404
|
-
}, ordinalSigner?: SignerInfo, extendedUtxo?: ExtendedUtxo[],
|
|
362
|
+
}, ordinalSigner?: SignerInfo, fee?: FeeRateType, extendedUtxo?: ExtendedUtxo[], { chainId, appId }?: {
|
|
405
363
|
chainId?: number | undefined;
|
|
406
364
|
appId?: number | undefined;
|
|
407
365
|
}): Promise<{
|
|
408
366
|
inscribeDepositUnsignedInfo: {
|
|
409
|
-
possibleTxId: string;
|
|
410
367
|
unsignedTransaction: string;
|
|
411
368
|
outputs: Target[];
|
|
412
369
|
inputs: {
|
|
@@ -417,9 +374,9 @@ declare class OrdinalWallet extends BitcoinBaseWallet {
|
|
|
417
374
|
}[];
|
|
418
375
|
fee: number;
|
|
419
376
|
change: ChangeTarget | undefined;
|
|
377
|
+
possibleTxId: string | undefined;
|
|
420
378
|
};
|
|
421
379
|
inscribeUnsignedInfo: {
|
|
422
|
-
possibleTxId: string;
|
|
423
380
|
unsignedTransaction: string;
|
|
424
381
|
inputs: {
|
|
425
382
|
hash: string;
|
|
@@ -431,6 +388,7 @@ declare class OrdinalWallet extends BitcoinBaseWallet {
|
|
|
431
388
|
address: string;
|
|
432
389
|
}[];
|
|
433
390
|
fee: number;
|
|
391
|
+
possibleTxId: string;
|
|
434
392
|
};
|
|
435
393
|
transferTxUnsignedInfo: {
|
|
436
394
|
possibleTxId: string;
|
|
@@ -457,7 +415,7 @@ declare class OrdinalWallet extends BitcoinBaseWallet {
|
|
|
457
415
|
}, brc20TokenId: number, signer: SignerInfo, lockerAddress: string, exchange?: {
|
|
458
416
|
outputToken: string;
|
|
459
417
|
outputAmount: string;
|
|
460
|
-
}, ordinalSigner?: SignerInfo, extendedUtxo?: ExtendedUtxo[],
|
|
418
|
+
}, ordinalSigner?: SignerInfo, fee?: FeeRateType, extendedUtxo?: ExtendedUtxo[], { chainId, appId }?: {
|
|
461
419
|
chainId?: number | undefined;
|
|
462
420
|
appId?: number | undefined;
|
|
463
421
|
}): Promise<{
|
|
@@ -479,7 +437,7 @@ declare class OrdinalWallet extends BitcoinBaseWallet {
|
|
|
479
437
|
}, brc20TokenId: number, lockerAddress: string, exchange?: {
|
|
480
438
|
outputToken: string;
|
|
481
439
|
outputAmount: string;
|
|
482
|
-
}, extendedUtxo?: ExtendedUtxo[],
|
|
440
|
+
}, fee?: FeeRateType, extendedUtxo?: ExtendedUtxo[], { chainId, appId }?: {
|
|
483
441
|
chainId?: number | undefined;
|
|
484
442
|
appId?: number | undefined;
|
|
485
443
|
}): Promise<{
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ordinal-wallet.d.ts","sourceRoot":"","sources":["../src/ordinal-wallet.ts"],"names":[],"mappings":";AACA,OAAO,EAAE,OAAO,IAAI,gBAAgB,EAAE,MAAM,wBAAwB,CAAA;AACpE,OAAO,EAAE,yBAAyB,EAAE,MAAM,mDAAmD,CAAA;AAC7F,OAAO,WAAW,MAAM,yBAAyB,CAAA;AAEjD,OAAO,EAAE,uBAAuB,EAAE,MAAM,6BAA6B,CAAA;AAGrE,OAAO,EAAE,
|
|
1
|
+
{"version":3,"file":"ordinal-wallet.d.ts","sourceRoot":"","sources":["../src/ordinal-wallet.ts"],"names":[],"mappings":";AACA,OAAO,EAAE,OAAO,IAAI,gBAAgB,EAAE,MAAM,wBAAwB,CAAA;AACpE,OAAO,EAAE,yBAAyB,EAAE,MAAM,mDAAmD,CAAA;AAC7F,OAAO,WAAW,MAAM,yBAAyB,CAAA;AAEjD,OAAO,EAAE,uBAAuB,EAAE,MAAM,6BAA6B,CAAA;AAGrE,OAAO,EAAE,YAAY,EAAE,YAAY,EAAE,UAAU,EAAE,MAAM,EAAE,MAAM,uBAAuB,CAAA;AACtF,OAAO,EAAE,iBAAiB,EAAE,WAAW,EAAE,MAAM,uBAAuB,CAAA;AACtE,OAAO,EAA0B,iBAAiB,EAAE,kBAAkB,EAAE,MAAM,QAAQ,CAAA;AAEtF,cAAM,aAAc,SAAQ,iBAAiB;IAC3C,MAAM,EAAE,gBAAgB,CAAC,MAAM,CAAA;IAC/B,kBAAkB,EAAE,yBAAyB,CAAA;IAC7C,YAAY,EAAE,uBAAuB,CAAA;IACrC,MAAM,EAAE,WAAW,CAAA;gBAEjB,WAAW,EAAE,MAAM,EACnB,WAAW,EAAE,MAAM,EACnB,cAAc,EAAE;QAEd,GAAG,EAAE,iBAAiB,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= require("./helper/brc20-helper");
|
|
|
20
20
|
const tools_1 = require("./utils/tools");
|
|
21
21
|
const bitcoin_wallet_base_1 = require("./bitcoin-wallet-base");
|
|
22
22
|
class OrdinalWallet extends bitcoin_wallet_base_1.BitcoinBaseWallet {
|
|
23
|
-
constructor(networkName, uniSatToken, connectionInfo
|
|
24
|
-
|
|
25
|
-
provider: "MempoolSpace",
|
|
26
|
-
},
|
|
27
|
-
}) {
|
|
28
|
-
var _a;
|
|
29
|
-
super(networkName, connectionInfo);
|
|
30
|
-
if (!((_a = connectionInfo.rpc) === null || _a === void 0 ? void 0 : _a.enabled)) {
|
|
23
|
+
constructor(networkName, uniSatToken, connectionInfo) {
|
|
24
|
+
if (!connectionInfo.rpc) {
|
|
31
25
|
throw new Error("rpc is required");
|
|
32
26
|
}
|
|
33
|
-
|
|
27
|
+
super(networkName, connectionInfo);
|
|
28
|
+
this.transactionBuilder = new ordinal_transaction_builder_1.OrdinalTransactionBuilder(networkName, this.network, connectionInfo);
|
|
34
29
|
this.signer = new sign_transaction_1.default(this.network);
|
|
35
30
|
this.btcInterface = new bitcoin_interface_ordinal_1.BitcoinInterfaceOrdinal(connectionInfo, networkName, uniSatToken);
|
|
36
31
|
this.unisat = this.btcInterface.unisat;
|
|
37
32
|
}
|
|
38
|
-
sendSignedPsbtWithRetry(signedPsbt, { maxTries = 5, retrySleep = 5000 } = {}) {
|
|
39
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
40
|
-
return (0, tools_1.runWithRetries)(() => this.sendSignedPsbt(signedPsbt), {
|
|
41
|
-
retrySleep,
|
|
42
|
-
maxTries,
|
|
43
|
-
});
|
|
44
|
-
});
|
|
45
|
-
}
|
|
46
33
|
static deployBRC20Data(tickName, max, limit) {
|
|
47
34
|
let data = {
|
|
48
35
|
p: "brc-20",
|
|
@@ -84,82 +71,32 @@ class OrdinalWallet extends bitcoin_wallet_base_1.BitcoinBaseWallet {
|
|
|
84
71
|
type: "text/plain",
|
|
85
72
|
};
|
|
86
73
|
}
|
|
87
|
-
|
|
88
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
89
|
-
let extendedUtxo = utxo;
|
|
90
|
-
receivers.forEach(({ value }) => {
|
|
91
|
-
if (value - +value.toFixed(0) !== 0)
|
|
92
|
-
throw new Error("incorrect amount. amount should be in satoshi");
|
|
93
|
-
});
|
|
94
|
-
let feeRate = staticFeeRate || (yield this.transactionBuilder._getFeeRate(speed));
|
|
95
|
-
let unsignedTx = yield this.transactionBuilder.processUnsignedTransaction({
|
|
96
|
-
extendedUtxo,
|
|
97
|
-
targets: receivers,
|
|
98
|
-
changeAddress,
|
|
99
|
-
feeRate,
|
|
100
|
-
fullAmount: false,
|
|
101
|
-
});
|
|
102
|
-
return Object.assign(Object.assign({}, unsignedTx), { possibleTxId: this.transactionBuilder.getUnsignedPsbtTxId(unsignedTx.unsignedTransaction) });
|
|
103
|
-
});
|
|
104
|
-
}
|
|
105
|
-
sendUsingUtxos({ receivers, speed = "normal", utxo, }) {
|
|
106
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
107
|
-
if (!this.currentAccount || !this.currentAccountType || !this.publicKey || !this.privateKey) {
|
|
108
|
-
throw new Error("account not initialized");
|
|
109
|
-
}
|
|
110
|
-
let extendedUtxo = utxo
|
|
111
|
-
? utxo.filter((u) => u.signerInfo.address === this.currentAccount)
|
|
112
|
-
: yield this.getExtendedUtxo({
|
|
113
|
-
address: this.currentAccount,
|
|
114
|
-
addressType: this.currentAccountType,
|
|
115
|
-
publicKey: this.publicKey.toString("hex"),
|
|
116
|
-
});
|
|
117
|
-
let unsignedTx = yield this.sendUsingUtxosUnsigned({
|
|
118
|
-
receivers,
|
|
119
|
-
speed,
|
|
120
|
-
utxo: extendedUtxo,
|
|
121
|
-
changeAddress: this.bitcoinAddress,
|
|
122
|
-
});
|
|
123
|
-
let signedPsbt = yield this.signer.signPsbt(unsignedTx, this.privateKey);
|
|
124
|
-
let signedTx = this.signer.finalizePsbts([signedPsbt]);
|
|
125
|
-
let txId = yield this.transactionBuilder.sendTx(signedTx);
|
|
126
|
-
const { inputs, outputs, change, fee } = unsignedTx;
|
|
127
|
-
return { txId, inputs, outputs, change, fee };
|
|
128
|
-
});
|
|
129
|
-
}
|
|
130
|
-
inscribeOrdinalDepositUnsigned(file, signer, ordinalSigner, extendedUtxo, staticFeeRate) {
|
|
74
|
+
inscribeOrdinalDepositUnsigned(file, signer, ordinalSigner, fee = "normal", extendedUtxo) {
|
|
131
75
|
return __awaiter(this, void 0, void 0, function* () {
|
|
132
76
|
const ordinalSignerPublicKey = (ordinalSigner === null || ordinalSigner === void 0 ? void 0 : ordinalSigner.publicKey) || signer.publicKey;
|
|
133
77
|
const publicKey = Buffer.from(ordinalSignerPublicKey, "hex");
|
|
134
78
|
let transferOrdinal = this.transactionBuilder.createOrdinalAddress(file, publicKey);
|
|
135
79
|
const leafScript = transferOrdinal.redeem.output;
|
|
136
80
|
const { ordinalAddress } = transferOrdinal;
|
|
137
|
-
let feeRate =
|
|
138
|
-
let
|
|
81
|
+
let feeRate = yield this.getFeeRate(fee);
|
|
82
|
+
let extraFee = +(((400 + leafScript.length) / 4) * feeRate * 1.5).toFixed(0);
|
|
139
83
|
let ordinalAmount = 600;
|
|
140
84
|
let utxo1 = extendedUtxo || (yield this.btcInterface.getBTCUtxo(signer.address, signer));
|
|
141
|
-
let inscribeDepositUnsignedInfo = yield this.
|
|
142
|
-
receivers: [
|
|
143
|
-
{
|
|
144
|
-
address: ordinalAddress,
|
|
145
|
-
value: ordinalAmount + fee,
|
|
146
|
-
},
|
|
147
|
-
],
|
|
148
|
-
utxo: utxo1,
|
|
149
|
-
changeAddress: signer.address,
|
|
150
|
-
});
|
|
85
|
+
let inscribeDepositUnsignedInfo = yield this.sendBTCUnsignedTx(ordinalAddress, ordinalAmount + extraFee, signer, feeRate, utxo1);
|
|
151
86
|
return {
|
|
152
87
|
inscribeDepositUnsignedInfo,
|
|
153
88
|
transferOrdinal,
|
|
154
89
|
};
|
|
155
90
|
});
|
|
156
91
|
}
|
|
157
|
-
inscribeOrdinalUnsigned(file, signer, ordinalSigner,
|
|
92
|
+
inscribeOrdinalUnsigned(file, signer, ordinalSigner, fee = "normal", extendedUtxo) {
|
|
158
93
|
return __awaiter(this, void 0, void 0, function* () {
|
|
159
94
|
const receiverAddress = (ordinalSigner === null || ordinalSigner === void 0 ? void 0 : ordinalSigner.address) || signer.address;
|
|
160
|
-
const { inscribeDepositUnsignedInfo, transferOrdinal } = yield this.inscribeOrdinalDepositUnsigned(file, signer, ordinalSigner,
|
|
95
|
+
const { inscribeDepositUnsignedInfo, transferOrdinal } = yield this.inscribeOrdinalDepositUnsigned(file, signer, ordinalSigner, fee, extendedUtxo);
|
|
161
96
|
const { ordinalAddress } = transferOrdinal;
|
|
162
97
|
let ordinalAmount = 600;
|
|
98
|
+
if (!inscribeDepositUnsignedInfo.possibleTxId)
|
|
99
|
+
throw new Error("inscribeDepositUnsignedInfo.possibleTxId is required. inscriber address type is not p2tr");
|
|
163
100
|
let inscribeDeposit = {
|
|
164
101
|
hash: inscribeDepositUnsignedInfo.possibleTxId,
|
|
165
102
|
value: inscribeDepositUnsignedInfo.outputs[0].value,
|
|
@@ -167,20 +104,20 @@ class OrdinalWallet extends bitcoin_wallet_base_1.BitcoinBaseWallet {
|
|
|
167
104
|
};
|
|
168
105
|
let inscribeUnsignedInfo = this.transactionBuilder.createInscribeUnsignedTx(transferOrdinal, inscribeDeposit, receiverAddress, ordinalAmount);
|
|
169
106
|
return {
|
|
170
|
-
inscribeDepositUnsignedInfo
|
|
171
|
-
inscribeUnsignedInfo
|
|
107
|
+
inscribeDepositUnsignedInfo,
|
|
108
|
+
inscribeUnsignedInfo,
|
|
172
109
|
inscribeAddress: ordinalAddress,
|
|
173
110
|
receiverAddress,
|
|
174
111
|
};
|
|
175
112
|
});
|
|
176
113
|
}
|
|
177
|
-
inscribeOrdinal(file,
|
|
114
|
+
inscribeOrdinal(file, fee = "normal", extendedUtxo, ordinalReceiverAddress) {
|
|
178
115
|
return __awaiter(this, void 0, void 0, function* () {
|
|
179
116
|
if (!this.currentAccount || !this.currentAccountType || !this.publicKey || !this.privateKey) {
|
|
180
117
|
throw new Error("account not initialized");
|
|
181
118
|
}
|
|
182
119
|
const receiverAddress = ordinalReceiverAddress || this.bitcoinAddress;
|
|
183
|
-
const { inscribeDepositUnsignedInfo, transferOrdinal } = yield this.inscribeOrdinalDepositUnsigned(file, this.signerInfo, undefined,
|
|
120
|
+
const { inscribeDepositUnsignedInfo, transferOrdinal } = yield this.inscribeOrdinalDepositUnsigned(file, this.signerInfo, undefined, fee, extendedUtxo);
|
|
184
121
|
let ordinalUtxo = yield this.btcInterface.getBTCUtxo(transferOrdinal.ordinalAddress, this.signerInfo);
|
|
185
122
|
let inscribeDeposit;
|
|
186
123
|
if (ordinalUtxo.length > 1) {
|
|
@@ -228,35 +165,35 @@ class OrdinalWallet extends bitcoin_wallet_base_1.BitcoinBaseWallet {
|
|
|
228
165
|
};
|
|
229
166
|
});
|
|
230
167
|
}
|
|
231
|
-
deployBrc20(brc,
|
|
168
|
+
deployBrc20(brc, fee = "normal", extendedUtxo) {
|
|
232
169
|
return __awaiter(this, void 0, void 0, function* () {
|
|
233
170
|
let file = OrdinalWallet.deployBRC20Data(brc.tick, brc.max, brc.limit);
|
|
234
|
-
return this.inscribeOrdinal(file,
|
|
171
|
+
return this.inscribeOrdinal(file, fee, extendedUtxo);
|
|
235
172
|
});
|
|
236
173
|
}
|
|
237
|
-
mintBrc20(brc,
|
|
174
|
+
mintBrc20(brc, fee = "normal", extendedUtxo) {
|
|
238
175
|
return __awaiter(this, void 0, void 0, function* () {
|
|
239
176
|
let file = OrdinalWallet.mintBRC20Data(brc.tick, brc.amount);
|
|
240
|
-
return this.inscribeOrdinal(file,
|
|
177
|
+
return this.inscribeOrdinal(file, fee, extendedUtxo);
|
|
241
178
|
});
|
|
242
179
|
}
|
|
243
|
-
inscribeBrc20Unsigned(brc, signer, ordinalSigner,
|
|
180
|
+
inscribeBrc20Unsigned(brc, signer, ordinalSigner, fee = "normal", extendedUtxo) {
|
|
244
181
|
return __awaiter(this, void 0, void 0, function* () {
|
|
245
182
|
let file = OrdinalWallet.transferBRC20Data(brc.tick, brc.amount);
|
|
246
|
-
return this.inscribeOrdinalUnsigned(file, signer, ordinalSigner,
|
|
183
|
+
return this.inscribeOrdinalUnsigned(file, signer, ordinalSigner, fee, extendedUtxo);
|
|
247
184
|
});
|
|
248
185
|
}
|
|
249
|
-
inscribeBrc20(brc,
|
|
186
|
+
inscribeBrc20(brc, fee = "normal", extendedUtxo) {
|
|
250
187
|
return __awaiter(this, void 0, void 0, function* () {
|
|
251
188
|
let file = OrdinalWallet.transferBRC20Data(brc.tick, brc.amount);
|
|
252
|
-
return this.inscribeOrdinal(file,
|
|
189
|
+
return this.inscribeOrdinal(file, fee, extendedUtxo);
|
|
253
190
|
});
|
|
254
191
|
}
|
|
255
|
-
transferBrc20Unsigned(receiver, brcInscribeUtxo, signer, ordinalSigner,
|
|
192
|
+
transferBrc20Unsigned(receiver, brcInscribeUtxo, signer, ordinalSigner, fee = "normal", extendedUtxo, otherTargets) {
|
|
256
193
|
return __awaiter(this, void 0, void 0, function* () {
|
|
257
194
|
const ordinalSignerInfo = ordinalSigner || signer;
|
|
258
195
|
let utxo = extendedUtxo || (yield this.btcInterface.getBTCUtxo(signer.address, signer));
|
|
259
|
-
let feeRate =
|
|
196
|
+
let feeRate = yield this.getFeeRate(fee);
|
|
260
197
|
let unsignedTx = yield this.transactionBuilder.createNftPsbt({
|
|
261
198
|
extendedUtxo: utxo,
|
|
262
199
|
nftExtendedUtxo: {
|
|
@@ -273,12 +210,12 @@ class OrdinalWallet extends bitcoin_wallet_base_1.BitcoinBaseWallet {
|
|
|
273
210
|
return Object.assign(Object.assign({}, unsignedTx), { possibleTxId: this.transactionBuilder.getUnsignedPsbtTxId(unsignedTx.unsignedTransaction) });
|
|
274
211
|
});
|
|
275
212
|
}
|
|
276
|
-
transferBrc20(receiver, brcInscribeUtxo,
|
|
213
|
+
transferBrc20(receiver, brcInscribeUtxo, fee = "normal", extendedUtxo, otherTargets) {
|
|
277
214
|
return __awaiter(this, void 0, void 0, function* () {
|
|
278
215
|
if (!this.currentAccount || !this.currentAccountType || !this.publicKey || !this.privateKey) {
|
|
279
216
|
throw new Error("account not initialized");
|
|
280
217
|
}
|
|
281
|
-
let feeRate =
|
|
218
|
+
let feeRate = yield this.getFeeRate(fee);
|
|
282
219
|
let unsignedTx = yield this.transactionBuilder.createNftPsbt({
|
|
283
220
|
extendedUtxo,
|
|
284
221
|
nftExtendedUtxo: {
|
|
@@ -304,7 +241,7 @@ class OrdinalWallet extends bitcoin_wallet_base_1.BitcoinBaseWallet {
|
|
|
304
241
|
};
|
|
305
242
|
});
|
|
306
243
|
}
|
|
307
|
-
inscribeAndTransferBrc20Unsigned(receiver, brc, signer, ordinalSigner, otherTargets,
|
|
244
|
+
inscribeAndTransferBrc20Unsigned(receiver, brc, signer, ordinalSigner, otherTargets, fee = "normal", extendedUtxo) {
|
|
308
245
|
return __awaiter(this, void 0, void 0, function* () {
|
|
309
246
|
const ordinalSignerInfo = ordinalSigner || signer;
|
|
310
247
|
let brc20Balance = yield this.unisat.getBrc20AddressBalanceForTicker(signer.address, brc.tick);
|
|
@@ -315,12 +252,15 @@ class OrdinalWallet extends bitcoin_wallet_base_1.BitcoinBaseWallet {
|
|
|
315
252
|
if ((0, bignumber_js_1.default)(brc20Balance.availableBalanceSafe).isLessThan(brc.amount)) {
|
|
316
253
|
throw new Error("insufficient balance");
|
|
317
254
|
}
|
|
318
|
-
let feeRate =
|
|
255
|
+
let feeRate = yield this.getFeeRate(fee);
|
|
319
256
|
let utxo1 = extendedUtxo || (yield this.btcInterface.getBTCUtxo(signer.address, signer));
|
|
320
257
|
let utxo2 = [];
|
|
321
|
-
const { inscribeAddress, inscribeDepositUnsignedInfo, inscribeUnsignedInfo } = yield this.inscribeBrc20Unsigned(brc, signer, ordinalSignerInfo,
|
|
258
|
+
const { inscribeAddress, inscribeDepositUnsignedInfo, inscribeUnsignedInfo } = yield this.inscribeBrc20Unsigned(brc, signer, ordinalSignerInfo, feeRate, utxo1);
|
|
322
259
|
utxo2 = utxo1.filter((u) => inscribeDepositUnsignedInfo.inputs.findIndex((i) => i.hash === u.hash && i.index === u.index) === -1);
|
|
323
260
|
if (inscribeDepositUnsignedInfo.change) {
|
|
261
|
+
if (!inscribeDepositUnsignedInfo.possibleTxId) {
|
|
262
|
+
throw new Error("inscribeDepositUnsignedInfo.possibleTxId is required");
|
|
263
|
+
}
|
|
324
264
|
utxo2.push({
|
|
325
265
|
hash: inscribeDepositUnsignedInfo.possibleTxId,
|
|
326
266
|
index: inscribeDepositUnsignedInfo.outputs.length,
|
|
@@ -332,7 +272,7 @@ class OrdinalWallet extends bitcoin_wallet_base_1.BitcoinBaseWallet {
|
|
|
332
272
|
hash: inscribeUnsignedInfo.possibleTxId,
|
|
333
273
|
value: inscribeUnsignedInfo.outputs[0].value,
|
|
334
274
|
index: 0,
|
|
335
|
-
}, signer, ordinalSignerInfo,
|
|
275
|
+
}, signer, ordinalSignerInfo, feeRate, utxo2, otherTargets);
|
|
336
276
|
return {
|
|
337
277
|
inscribeDepositUnsignedInfo,
|
|
338
278
|
inscribeUnsignedInfo,
|
|
@@ -341,7 +281,7 @@ class OrdinalWallet extends bitcoin_wallet_base_1.BitcoinBaseWallet {
|
|
|
341
281
|
};
|
|
342
282
|
});
|
|
343
283
|
}
|
|
344
|
-
inscribeAndTransferBrc20(receiver, brc, otherTargets,
|
|
284
|
+
inscribeAndTransferBrc20(receiver, brc, otherTargets, fee = "normal", extendedUtxo) {
|
|
345
285
|
return __awaiter(this, void 0, void 0, function* () {
|
|
346
286
|
let brc20Balance = yield this.unisat.getBrc20AddressBalanceForTicker(this.bitcoinAddress, brc.tick);
|
|
347
287
|
if ((0, bignumber_js_1.default)(brc20Balance.transferableBalance).gte(brc.amount)) {
|
|
@@ -354,8 +294,8 @@ class OrdinalWallet extends bitcoin_wallet_base_1.BitcoinBaseWallet {
|
|
|
354
294
|
hash: ins.utxo.txid,
|
|
355
295
|
index: ins.utxo.vout,
|
|
356
296
|
value: ins.utxo.satoshi,
|
|
357
|
-
}, extendedUtxo ||
|
|
358
|
-
(yield this.btcInterface.getBTCUtxo(this.bitcoinAddress, this.signerInfo)),
|
|
297
|
+
}, yield this.getFeeRate(fee), extendedUtxo ||
|
|
298
|
+
(yield this.btcInterface.getBTCUtxo(this.bitcoinAddress, this.signerInfo)), otherTargets);
|
|
359
299
|
return {
|
|
360
300
|
transferTx,
|
|
361
301
|
};
|
|
@@ -365,10 +305,10 @@ class OrdinalWallet extends bitcoin_wallet_base_1.BitcoinBaseWallet {
|
|
|
365
305
|
if ((0, bignumber_js_1.default)(brc20Balance.availableBalanceSafe).isLessThan(brc.amount)) {
|
|
366
306
|
throw new Error(`insufficient balance ${brc20Balance.availableBalanceSafe} ${brc.amount}`);
|
|
367
307
|
}
|
|
368
|
-
let feeRate =
|
|
308
|
+
let feeRate = yield this.getFeeRate(fee);
|
|
369
309
|
let utxo1 = extendedUtxo || (yield this.btcInterface.getBTCUtxo(this.bitcoinAddress, this.signerInfo));
|
|
370
310
|
let utxo2 = [];
|
|
371
|
-
const { inscribeAddress, inscribeDepositTx, inscribeTx } = yield this.inscribeBrc20(brc,
|
|
311
|
+
const { inscribeAddress, inscribeDepositTx, inscribeTx } = yield this.inscribeBrc20(brc, feeRate, utxo1);
|
|
372
312
|
utxo2 = utxo1.filter((u) => inscribeDepositTx.inputs.findIndex((i) => i.hash === u.hash && i.index === u.index) === -1);
|
|
373
313
|
if (inscribeDepositTx.change) {
|
|
374
314
|
utxo2.push({
|
|
@@ -379,7 +319,7 @@ class OrdinalWallet extends bitcoin_wallet_base_1.BitcoinBaseWallet {
|
|
|
379
319
|
});
|
|
380
320
|
}
|
|
381
321
|
yield (0, tools_1.sleep)(10 * 1000);
|
|
382
|
-
let transferTx = yield this.transferBrc20(receiver, inscribeTx,
|
|
322
|
+
let transferTx = yield this.transferBrc20(receiver, inscribeTx, feeRate, utxo2, otherTargets);
|
|
383
323
|
return {
|
|
384
324
|
inscribeTx,
|
|
385
325
|
inscribeAddress,
|
|
@@ -388,7 +328,7 @@ class OrdinalWallet extends bitcoin_wallet_base_1.BitcoinBaseWallet {
|
|
|
388
328
|
};
|
|
389
329
|
});
|
|
390
330
|
}
|
|
391
|
-
wrapBrc20Unsigned(recipientAddress, brc, brc20TokenId, signer, lockerAddress, exchange, ordinalSigner,
|
|
331
|
+
wrapBrc20Unsigned(recipientAddress, brc, brc20TokenId, signer, lockerAddress, exchange, ordinalSigner, fee = "normal", extendedUtxo, { chainId = 137, appId = exchange ? 1 : 0 } = {}) {
|
|
392
332
|
return __awaiter(this, void 0, void 0, function* () {
|
|
393
333
|
const isExchange = !!exchange;
|
|
394
334
|
let dataHex = (0, brc20_helper_1.generateBrc2OpReturn)({
|
|
@@ -402,10 +342,10 @@ class OrdinalWallet extends bitcoin_wallet_base_1.BitcoinBaseWallet {
|
|
|
402
342
|
outputAmount: exchange === null || exchange === void 0 ? void 0 : exchange.outputAmount,
|
|
403
343
|
});
|
|
404
344
|
let opTarget = this.transactionBuilder.getOpReturnTarget(dataHex);
|
|
405
|
-
return this.inscribeAndTransferBrc20Unsigned(lockerAddress, brc, signer, ordinalSigner, [opTarget],
|
|
345
|
+
return this.inscribeAndTransferBrc20Unsigned(lockerAddress, brc, signer, ordinalSigner, [opTarget], fee, extendedUtxo);
|
|
406
346
|
});
|
|
407
347
|
}
|
|
408
|
-
wrapBrc20OnlyTransferUnsigned(recipientAddress, brcInscribeTx, brc, brc20TokenId, signer, lockerAddress, exchange, ordinalSigner,
|
|
348
|
+
wrapBrc20OnlyTransferUnsigned(recipientAddress, brcInscribeTx, brc, brc20TokenId, signer, lockerAddress, exchange, ordinalSigner, fee = "normal", extendedUtxo, { chainId = 137, appId = exchange ? 1 : 0 } = {}) {
|
|
409
349
|
return __awaiter(this, void 0, void 0, function* () {
|
|
410
350
|
let utxo = extendedUtxo || (yield this.btcInterface.getBTCUtxo(signer.address, signer));
|
|
411
351
|
const isExchange = !!exchange;
|
|
@@ -420,12 +360,12 @@ class OrdinalWallet extends bitcoin_wallet_base_1.BitcoinBaseWallet {
|
|
|
420
360
|
outputAmount: exchange === null || exchange === void 0 ? void 0 : exchange.outputAmount,
|
|
421
361
|
});
|
|
422
362
|
let opTarget = this.transactionBuilder.getOpReturnTarget(dataHex);
|
|
423
|
-
let feeRate =
|
|
424
|
-
let transferTxUnsignedInfo = yield this.transferBrc20Unsigned(lockerAddress, brcInscribeTx, signer, ordinalSigner,
|
|
363
|
+
let feeRate = yield this.getFeeRate(fee);
|
|
364
|
+
let transferTxUnsignedInfo = yield this.transferBrc20Unsigned(lockerAddress, brcInscribeTx, signer, ordinalSigner, feeRate, utxo, [opTarget]);
|
|
425
365
|
return transferTxUnsignedInfo;
|
|
426
366
|
});
|
|
427
367
|
}
|
|
428
|
-
wrapBrc20(recipientAddress, brc, brc20TokenId, lockerAddress, exchange,
|
|
368
|
+
wrapBrc20(recipientAddress, brc, brc20TokenId, lockerAddress, exchange, fee = "normal", extendedUtxo, { chainId = 137, appId = exchange ? 1 : 0 } = {}) {
|
|
429
369
|
return __awaiter(this, void 0, void 0, function* () {
|
|
430
370
|
const isExchange = !!exchange;
|
|
431
371
|
let dataHex = (0, brc20_helper_1.generateBrc2OpReturn)({
|
|
@@ -439,7 +379,7 @@ class OrdinalWallet extends bitcoin_wallet_base_1.BitcoinBaseWallet {
|
|
|
439
379
|
outputAmount: exchange === null || exchange === void 0 ? void 0 : exchange.outputAmount,
|
|
440
380
|
});
|
|
441
381
|
let opTarget = this.transactionBuilder.getOpReturnTarget(dataHex);
|
|
442
|
-
return this.inscribeAndTransferBrc20(lockerAddress, brc, [opTarget],
|
|
382
|
+
return this.inscribeAndTransferBrc20(lockerAddress, brc, [opTarget], fee, extendedUtxo);
|
|
443
383
|
});
|
|
444
384
|
}
|
|
445
385
|
}
|