@teleportdao/bitcoin 2.0.5 → 2.0.7

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.
Files changed (76) hide show
  1. package/dist/bitcoin-interface-ordinal.d.ts +108 -108
  2. package/dist/bitcoin-interface-ordinal.js +140 -140
  3. package/dist/bitcoin-interface-teleswap.d.ts +101 -101
  4. package/dist/bitcoin-interface-teleswap.js +176 -176
  5. package/dist/bitcoin-interface-utils.d.ts +20 -20
  6. package/dist/bitcoin-interface-utils.js +45 -45
  7. package/dist/bitcoin-interface-wallet.d.ts +28 -28
  8. package/dist/bitcoin-interface-wallet.js +125 -125
  9. package/dist/bitcoin-interface.d.ts +66 -66
  10. package/dist/bitcoin-interface.js +119 -119
  11. package/dist/bitcoin-utils.d.ts +96 -96
  12. package/dist/bitcoin-utils.js +514 -514
  13. package/dist/bitcoin-wallet-base.d.ts +111 -111
  14. package/dist/bitcoin-wallet-base.js +258 -258
  15. package/dist/helper/brc20-helper.d.ts +42 -42
  16. package/dist/helper/brc20-helper.js +127 -127
  17. package/dist/helper/index.d.ts +3 -3
  18. package/dist/helper/index.js +29 -29
  19. package/dist/helper/ordinal-helper.d.ts +12 -12
  20. package/dist/helper/ordinal-helper.js +129 -129
  21. package/dist/helper/teleswap-helper.d.ts +95 -95
  22. package/dist/helper/teleswap-helper.js +186 -186
  23. package/dist/index.d.ts +12 -12
  24. package/dist/index.js +41 -41
  25. package/dist/ordinal-wallet.d.ts +495 -495
  26. package/dist/ordinal-wallet.js +386 -386
  27. package/dist/sign/index.d.ts +1 -1
  28. package/dist/sign/index.js +8 -8
  29. package/dist/sign/sign-transaction.d.ts +12 -12
  30. package/dist/sign/sign-transaction.js +82 -82
  31. package/dist/teleswap-wallet.d.ts +45 -45
  32. package/dist/teleswap-wallet.js +68 -68
  33. package/dist/transaction-builder/bitcoin-transaction-builder.d.ts +9 -9
  34. package/dist/transaction-builder/bitcoin-transaction-builder.js +54 -54
  35. package/dist/transaction-builder/index.d.ts +3 -3
  36. package/dist/transaction-builder/index.js +19 -19
  37. package/dist/transaction-builder/ordinal-transaction-builder.d.ts +63 -63
  38. package/dist/transaction-builder/ordinal-transaction-builder.js +125 -125
  39. package/dist/transaction-builder/transaction-builder.d.ts +223 -223
  40. package/dist/transaction-builder/transaction-builder.js +447 -447
  41. package/dist/type.d.ts +61 -61
  42. package/dist/type.js +2 -2
  43. package/dist/utils/networks.d.ts +5 -5
  44. package/dist/utils/networks.js +53 -53
  45. package/dist/utils/tools.d.ts +18 -18
  46. package/dist/utils/tools.js +74 -74
  47. package/package.json +4 -4
  48. package/src/bitcoin-interface-ordinal.ts +185 -185
  49. package/src/bitcoin-interface-teleswap.ts +251 -251
  50. package/src/bitcoin-interface-utils.ts +60 -60
  51. package/src/bitcoin-interface-wallet.ts +114 -114
  52. package/src/bitcoin-interface.ts +156 -156
  53. package/src/bitcoin-utils.ts +591 -591
  54. package/src/bitcoin-wallet-base.ts +344 -344
  55. package/src/helper/brc20-helper.ts +179 -179
  56. package/src/helper/ordinal-helper.ts +118 -118
  57. package/src/index.ts +15 -15
  58. package/src/ordinal-wallet.ts +659 -659
  59. package/src/sign/index.ts +1 -1
  60. package/src/sign/sign-transaction.ts +108 -108
  61. package/src/teleswap-wallet.ts +133 -133
  62. package/src/transaction-builder/bitcoin-transaction-builder.ts +26 -26
  63. package/src/transaction-builder/index.ts +3 -3
  64. package/src/transaction-builder/ordinal-transaction-builder.ts +139 -139
  65. package/src/transaction-builder/transaction-builder.ts +690 -690
  66. package/src/type.ts +74 -74
  67. package/src/utils/networks.ts +33 -33
  68. package/src/utils/tools.ts +92 -92
  69. package/tsconfig.json +9 -9
  70. package/webpack.config.js +16 -16
  71. package/.tmp/block-parser.ts +0 -58
  72. package/.tmp/check.ts +0 -101
  73. package/.tmp/ordinal-helper.ts +0 -133
  74. package/.tmp/ordinal.ts +0 -25
  75. package/.tmp/psbt/sign-transaction.ts +0 -121
  76. package/.tmp/rbf.ts +0 -45
@@ -1,109 +1,109 @@
1
- import { bitcoin as bitcoinProviders } from "@teleportdao/providers";
2
- import { BitcoinInterface } from "./bitcoin-interface";
3
- import { Transaction, BitcoinTokenNodeConnectionInfo } from "./type";
4
- import type { SignerInfo } from "./transaction-builder";
5
- export declare class BitcoinInterfaceOrdinal extends BitcoinInterface {
6
- unisat: bitcoinProviders.UniSat;
7
- constructor(connectionInfo: BitcoinTokenNodeConnectionInfo, networkName: string, uniSatToken: string);
8
- getInscriptionWithRetry(inscriptionId: string, { numberOfRetry, sleepTime }?: {
9
- numberOfRetry?: number | undefined;
10
- sleepTime?: number | undefined;
11
- }): Promise<bitcoinProviders.UnisatInscription | null>;
12
- getTransactionBrc20TransferInfo(transaction: {
13
- txId: string;
14
- vout: {
15
- address: string | null;
16
- script: string;
17
- value: number;
18
- }[];
19
- vin: {
20
- txId: string;
21
- index: number;
22
- address?: string | null;
23
- script?: string | null;
24
- value?: number | null;
25
- }[];
26
- }): Promise<{
27
- txId: string;
28
- receiver: string;
29
- index: number;
30
- brc20: {
31
- op: string;
32
- tick: string;
33
- lim: string;
34
- amt: string;
35
- decimal: string;
36
- };
37
- inscription: bitcoinProviders.UnisatInscription;
38
- }[]>;
39
- convertToBrc20WrapRequest(transaction: Transaction, lockerAddress: string): Promise<{
40
- transaction: Transaction;
41
- request: {
42
- status: boolean;
43
- data?: import("./helper/brc20-helper").WrapOpReturnAndType | undefined;
44
- dataOutputIndex?: number | undefined;
45
- lockerFeeValue?: number | undefined;
46
- lockerFeeOutputIndex?: number | undefined;
47
- brc20OutputIndex?: number | undefined;
48
- brc20OutputValue?: number | undefined;
49
- message?: string | undefined;
50
- code?: string | undefined;
51
- };
52
- lockerAddress: string;
53
- lockerLockingScript: string;
54
- }>;
55
- getBrc20WrapRequests(addresses: string[], startblockNumber: number, endBlockNumber: number): Promise<{
56
- requests: {
57
- brc20: {
58
- op: string;
59
- tick: string;
60
- lim: string;
61
- amt: string;
62
- decimal: string;
63
- };
64
- transaction: Transaction;
65
- request: {
66
- status: boolean;
67
- data?: import("./helper/brc20-helper").WrapOpReturnAndType | undefined;
68
- dataOutputIndex?: number | undefined;
69
- lockerFeeValue?: number | undefined;
70
- lockerFeeOutputIndex?: number | undefined;
71
- brc20OutputIndex?: number | undefined;
72
- brc20OutputValue?: number | undefined;
73
- message?: string | undefined;
74
- code?: string | undefined;
75
- };
76
- lockerAddress: string;
77
- lockerLockingScript: string;
78
- }[];
79
- invalidRequests: {
80
- transaction: Transaction;
81
- request: {
82
- status: boolean;
83
- data?: import("./helper/brc20-helper").WrapOpReturnAndType | undefined;
84
- dataOutputIndex?: number | undefined;
85
- lockerFeeValue?: number | undefined;
86
- lockerFeeOutputIndex?: number | undefined;
87
- brc20OutputIndex?: number | undefined;
88
- brc20OutputValue?: number | undefined;
89
- message?: string | undefined;
90
- code?: string | undefined;
91
- };
92
- lockerAddress: string;
93
- lockerLockingScript: string;
94
- }[];
95
- }>;
96
- getBTCUtxo(address: string, signerInfo: SignerInfo): Promise<{
97
- hash: string;
98
- index: number;
99
- value: number;
100
- signerInfo: SignerInfo;
101
- }[]>;
102
- getInscriptionUtxo(address: string, signerInfo: SignerInfo): Promise<{
103
- hash: string;
104
- index: number;
105
- value: number;
106
- signerInfo: SignerInfo;
107
- }[]>;
108
- }
1
+ import { bitcoin as bitcoinProviders } from "@teleportdao/providers";
2
+ import { BitcoinInterface } from "./bitcoin-interface";
3
+ import { Transaction, BitcoinTokenNodeConnectionInfo } from "./type";
4
+ import type { SignerInfo } from "./transaction-builder";
5
+ export declare class BitcoinInterfaceOrdinal extends BitcoinInterface {
6
+ unisat: bitcoinProviders.UniSat;
7
+ constructor(connectionInfo: BitcoinTokenNodeConnectionInfo, networkName: string, uniSatToken: string);
8
+ getInscriptionWithRetry(inscriptionId: string, { numberOfRetry, sleepTime }?: {
9
+ numberOfRetry?: number | undefined;
10
+ sleepTime?: number | undefined;
11
+ }): Promise<bitcoinProviders.UnisatInscription | null>;
12
+ getTransactionBrc20TransferInfo(transaction: {
13
+ txId: string;
14
+ vout: {
15
+ address: string | null;
16
+ script: string;
17
+ value: number;
18
+ }[];
19
+ vin: {
20
+ txId: string;
21
+ index: number;
22
+ address?: string | null;
23
+ script?: string | null;
24
+ value?: number | null;
25
+ }[];
26
+ }): Promise<{
27
+ txId: string;
28
+ receiver: string;
29
+ index: number;
30
+ brc20: {
31
+ op: string;
32
+ tick: string;
33
+ lim: string;
34
+ amt: string;
35
+ decimal: string;
36
+ };
37
+ inscription: bitcoinProviders.UnisatInscription;
38
+ }[]>;
39
+ convertToBrc20WrapRequest(transaction: Transaction, lockerAddress: string): Promise<{
40
+ transaction: Transaction;
41
+ request: {
42
+ status: boolean;
43
+ data?: import("./helper/brc20-helper").WrapOpReturnAndType | undefined;
44
+ dataOutputIndex?: number | undefined;
45
+ lockerFeeValue?: number | undefined;
46
+ lockerFeeOutputIndex?: number | undefined;
47
+ brc20OutputIndex?: number | undefined;
48
+ brc20OutputValue?: number | undefined;
49
+ message?: string | undefined;
50
+ code?: string | undefined;
51
+ };
52
+ lockerAddress: string;
53
+ lockerLockingScript: string;
54
+ }>;
55
+ getBrc20WrapRequests(addresses: string[], startblockNumber: number, endBlockNumber: number): Promise<{
56
+ requests: {
57
+ brc20: {
58
+ op: string;
59
+ tick: string;
60
+ lim: string;
61
+ amt: string;
62
+ decimal: string;
63
+ };
64
+ transaction: Transaction;
65
+ request: {
66
+ status: boolean;
67
+ data?: import("./helper/brc20-helper").WrapOpReturnAndType | undefined;
68
+ dataOutputIndex?: number | undefined;
69
+ lockerFeeValue?: number | undefined;
70
+ lockerFeeOutputIndex?: number | undefined;
71
+ brc20OutputIndex?: number | undefined;
72
+ brc20OutputValue?: number | undefined;
73
+ message?: string | undefined;
74
+ code?: string | undefined;
75
+ };
76
+ lockerAddress: string;
77
+ lockerLockingScript: string;
78
+ }[];
79
+ invalidRequests: {
80
+ transaction: Transaction;
81
+ request: {
82
+ status: boolean;
83
+ data?: import("./helper/brc20-helper").WrapOpReturnAndType | undefined;
84
+ dataOutputIndex?: number | undefined;
85
+ lockerFeeValue?: number | undefined;
86
+ lockerFeeOutputIndex?: number | undefined;
87
+ brc20OutputIndex?: number | undefined;
88
+ brc20OutputValue?: number | undefined;
89
+ message?: string | undefined;
90
+ code?: string | undefined;
91
+ };
92
+ lockerAddress: string;
93
+ lockerLockingScript: string;
94
+ }[];
95
+ }>;
96
+ getBTCUtxo(address: string, signerInfo: SignerInfo): Promise<{
97
+ hash: string;
98
+ index: number;
99
+ value: number;
100
+ signerInfo: SignerInfo;
101
+ }[]>;
102
+ getInscriptionUtxo(address: string, signerInfo: SignerInfo): Promise<{
103
+ hash: string;
104
+ index: number;
105
+ value: number;
106
+ signerInfo: SignerInfo;
107
+ }[]>;
108
+ }
109
109
  //# sourceMappingURL=bitcoin-interface-ordinal.d.ts.map
@@ -1,141 +1,141 @@
1
- "use strict";
2
- var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
3
- function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
4
- return new (P || (P = Promise))(function (resolve, reject) {
5
- function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
6
- function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
7
- function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
8
- step((generator = generator.apply(thisArg, _arguments || [])).next());
9
- });
10
- };
11
- var __importDefault = (this && this.__importDefault) || function (mod) {
12
- return (mod && mod.__esModule) ? mod : { "default": mod };
13
- };
14
- Object.defineProperty(exports, "__esModule", { value: true });
15
- exports.BitcoinInterfaceOrdinal = void 0;
16
- const bignumber_js_1 = __importDefault(require("bignumber.js"));
17
- const providers_1 = require("@teleportdao/providers");
18
- const bitcoin_interface_1 = require("./bitcoin-interface");
19
- const tools_1 = require("./utils/tools");
20
- const brc20_helper_1 = require("./helper/brc20-helper");
21
- class BitcoinInterfaceOrdinal extends bitcoin_interface_1.BitcoinInterface {
22
- constructor(connectionInfo, networkName, uniSatToken) {
23
- super(networkName, connectionInfo);
24
- this.unisat = new providers_1.bitcoin.UniSat({
25
- token: uniSatToken,
26
- }, networkName.includes("testnet"));
27
- }
28
- getInscriptionWithRetry(inscriptionId, { numberOfRetry = 5, sleepTime = 20000 } = {}) {
29
- return __awaiter(this, void 0, void 0, function* () {
30
- let count = 0;
31
- while (count <= numberOfRetry) {
32
- try {
33
- let inscription = yield this.unisat.getInscriptionInfo(inscriptionId);
34
- if (inscription === null || inscription === void 0 ? void 0 : inscription.brc20) {
35
- return inscription;
36
- }
37
- }
38
- catch (e) {
39
- console.log(e.message);
40
- }
41
- yield (0, tools_1.sleep)(sleepTime + count * 5000);
42
- count += 1;
43
- }
44
- return null;
45
- });
46
- }
47
- getTransactionBrc20TransferInfo(transaction) {
48
- var _a;
49
- return __awaiter(this, void 0, void 0, function* () {
50
- let txBrc20s = [];
51
- for (let x = 0; x < transaction.vout.length - 1; x += 1) {
52
- if (!transaction.vout[x].address) {
53
- return [];
54
- }
55
- let inscription = yield this.unisat.getInscriptionInfo(`${transaction.vin[x].txId}i${transaction.vin[x].index}`);
56
- const brc20 = ((_a = inscription === null || inscription === void 0 ? void 0 : inscription.brc20) === null || _a === void 0 ? void 0 : _a.op) === "transfer" ? inscription.brc20 : undefined;
57
- if (brc20 && inscription) {
58
- txBrc20s.push({
59
- txId: transaction.txId,
60
- receiver: transaction.vout[x].address,
61
- index: x,
62
- inscription,
63
- brc20,
64
- });
65
- }
66
- else {
67
- return [];
68
- }
69
- }
70
- return txBrc20s;
71
- });
72
- }
73
- convertToBrc20WrapRequest(transaction, lockerAddress) {
74
- return __awaiter(this, void 0, void 0, function* () {
75
- let { vout } = transaction;
76
- let request = (0, brc20_helper_1.checkAndParseBrc20Request)(vout, lockerAddress);
77
- let lockerLockingScript = transaction.addressScript ||
78
- this.convertAddressToScript(lockerAddress).script.toString("hex");
79
- return {
80
- transaction,
81
- request,
82
- lockerAddress,
83
- lockerLockingScript,
84
- };
85
- });
86
- }
87
- getBrc20WrapRequests(addresses, startblockNumber, endBlockNumber) {
88
- var _a, _b, _c, _d, _e, _f, _g;
89
- return __awaiter(this, void 0, void 0, function* () {
90
- let transactions = yield this.getMultipleBlocksTransactions(addresses, startblockNumber, endBlockNumber || (yield this.getLatestBlockNumber()));
91
- let requests = [];
92
- let invalidRequests = [];
93
- for (let inputTx of transactions) {
94
- let data = yield this.convertToBrc20WrapRequest(inputTx, inputTx.address);
95
- if (data.request.status) {
96
- let inscription = yield this.getInscriptionWithRetry(`${inputTx.vin[0].txId}i${inputTx.vin[0].index}`);
97
- const brc20 = ((_a = inscription === null || inscription === void 0 ? void 0 : inscription.brc20) === null || _a === void 0 ? void 0 : _a.op) === "transfer" ? inscription.brc20 : undefined;
98
- if (!brc20) {
99
- invalidRequests.push(Object.assign(Object.assign({}, data), { message: `invalid brc20 -> ${(_b = inscription === null || inscription === void 0 ? void 0 : inscription.brc20) === null || _b === void 0 ? void 0 : _b.op}:${(_c = inscription === null || inscription === void 0 ? void 0 : inscription.brc20) === null || _c === void 0 ? void 0 : _c.amt}` }));
100
- }
101
- else if (!(0, bignumber_js_1.default)(brc20.amt)
102
- .multipliedBy(1e18)
103
- .isEqualTo(((_d = data.request.data) === null || _d === void 0 ? void 0 : _d.inputAmount) || 0)) {
104
- invalidRequests.push(Object.assign(Object.assign({}, data), { message: `invalid brc20 amount -> ${(_e = inscription === null || inscription === void 0 ? void 0 : inscription.brc20) === null || _e === void 0 ? void 0 : _e.op}:${(_f = inscription === null || inscription === void 0 ? void 0 : inscription.brc20) === null || _f === void 0 ? void 0 : _f.amt}:${(_g = data.request.data) === null || _g === void 0 ? void 0 : _g.inputAmount}` }));
105
- }
106
- else {
107
- requests.push(Object.assign(Object.assign({}, data), { brc20 }));
108
- }
109
- }
110
- else if (data.request.code !== "NO_OP_RETURN") {
111
- invalidRequests.push(data);
112
- }
113
- }
114
- return { requests, invalidRequests };
115
- });
116
- }
117
- getBTCUtxo(address, signerInfo) {
118
- var _a;
119
- return __awaiter(this, void 0, void 0, function* () {
120
- return providers_1.bitcoin.UniSat.convertToNormalUtxo(((_a = (yield this.unisat.getBTCUtxo(address))) === null || _a === void 0 ? void 0 : _a.utxo) || []).map(({ txId, index, value }) => ({
121
- hash: txId,
122
- index,
123
- value,
124
- signerInfo,
125
- }));
126
- });
127
- }
128
- getInscriptionUtxo(address, signerInfo) {
129
- var _a;
130
- return __awaiter(this, void 0, void 0, function* () {
131
- return providers_1.bitcoin.UniSat.convertToNormalUtxo(((_a = (yield this.unisat.getInscriptionUtxo(address))) === null || _a === void 0 ? void 0 : _a.utxo) || []).map(({ txId, index, value }) => ({
132
- hash: txId,
133
- index,
134
- value,
135
- signerInfo,
136
- }));
137
- });
138
- }
139
- }
140
- exports.BitcoinInterfaceOrdinal = BitcoinInterfaceOrdinal;
1
+ "use strict";
2
+ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
3
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
4
+ return new (P || (P = Promise))(function (resolve, reject) {
5
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
6
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
7
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
8
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
9
+ });
10
+ };
11
+ var __importDefault = (this && this.__importDefault) || function (mod) {
12
+ return (mod && mod.__esModule) ? mod : { "default": mod };
13
+ };
14
+ Object.defineProperty(exports, "__esModule", { value: true });
15
+ exports.BitcoinInterfaceOrdinal = void 0;
16
+ const bignumber_js_1 = __importDefault(require("bignumber.js"));
17
+ const providers_1 = require("@teleportdao/providers");
18
+ const bitcoin_interface_1 = require("./bitcoin-interface");
19
+ const tools_1 = require("./utils/tools");
20
+ const brc20_helper_1 = require("./helper/brc20-helper");
21
+ class BitcoinInterfaceOrdinal extends bitcoin_interface_1.BitcoinInterface {
22
+ constructor(connectionInfo, networkName, uniSatToken) {
23
+ super(networkName, connectionInfo);
24
+ this.unisat = new providers_1.bitcoin.UniSat({
25
+ token: uniSatToken,
26
+ }, networkName.includes("testnet"));
27
+ }
28
+ getInscriptionWithRetry(inscriptionId, { numberOfRetry = 5, sleepTime = 20000 } = {}) {
29
+ return __awaiter(this, void 0, void 0, function* () {
30
+ let count = 0;
31
+ while (count <= numberOfRetry) {
32
+ try {
33
+ let inscription = yield this.unisat.getInscriptionInfo(inscriptionId);
34
+ if (inscription === null || inscription === void 0 ? void 0 : inscription.brc20) {
35
+ return inscription;
36
+ }
37
+ }
38
+ catch (e) {
39
+ console.log(e.message);
40
+ }
41
+ yield (0, tools_1.sleep)(sleepTime + count * 5000);
42
+ count += 1;
43
+ }
44
+ return null;
45
+ });
46
+ }
47
+ getTransactionBrc20TransferInfo(transaction) {
48
+ var _a;
49
+ return __awaiter(this, void 0, void 0, function* () {
50
+ let txBrc20s = [];
51
+ for (let x = 0; x < transaction.vout.length - 1; x += 1) {
52
+ if (!transaction.vout[x].address) {
53
+ return [];
54
+ }
55
+ let inscription = yield this.unisat.getInscriptionInfo(`${transaction.vin[x].txId}i${transaction.vin[x].index}`);
56
+ const brc20 = ((_a = inscription === null || inscription === void 0 ? void 0 : inscription.brc20) === null || _a === void 0 ? void 0 : _a.op) === "transfer" ? inscription.brc20 : undefined;
57
+ if (brc20 && inscription) {
58
+ txBrc20s.push({
59
+ txId: transaction.txId,
60
+ receiver: transaction.vout[x].address,
61
+ index: x,
62
+ inscription,
63
+ brc20,
64
+ });
65
+ }
66
+ else {
67
+ return [];
68
+ }
69
+ }
70
+ return txBrc20s;
71
+ });
72
+ }
73
+ convertToBrc20WrapRequest(transaction, lockerAddress) {
74
+ return __awaiter(this, void 0, void 0, function* () {
75
+ let { vout } = transaction;
76
+ let request = (0, brc20_helper_1.checkAndParseBrc20Request)(vout, lockerAddress);
77
+ let lockerLockingScript = transaction.addressScript ||
78
+ this.convertAddressToScript(lockerAddress).script.toString("hex");
79
+ return {
80
+ transaction,
81
+ request,
82
+ lockerAddress,
83
+ lockerLockingScript,
84
+ };
85
+ });
86
+ }
87
+ getBrc20WrapRequests(addresses, startblockNumber, endBlockNumber) {
88
+ var _a, _b, _c, _d, _e, _f, _g;
89
+ return __awaiter(this, void 0, void 0, function* () {
90
+ let transactions = yield this.getMultipleBlocksTransactions(addresses, startblockNumber, endBlockNumber || (yield this.getLatestBlockNumber()));
91
+ let requests = [];
92
+ let invalidRequests = [];
93
+ for (let inputTx of transactions) {
94
+ let data = yield this.convertToBrc20WrapRequest(inputTx, inputTx.address);
95
+ if (data.request.status) {
96
+ let inscription = yield this.getInscriptionWithRetry(`${inputTx.vin[0].txId}i${inputTx.vin[0].index}`);
97
+ const brc20 = ((_a = inscription === null || inscription === void 0 ? void 0 : inscription.brc20) === null || _a === void 0 ? void 0 : _a.op) === "transfer" ? inscription.brc20 : undefined;
98
+ if (!brc20) {
99
+ invalidRequests.push(Object.assign(Object.assign({}, data), { message: `invalid brc20 -> ${(_b = inscription === null || inscription === void 0 ? void 0 : inscription.brc20) === null || _b === void 0 ? void 0 : _b.op}:${(_c = inscription === null || inscription === void 0 ? void 0 : inscription.brc20) === null || _c === void 0 ? void 0 : _c.amt}` }));
100
+ }
101
+ else if (!(0, bignumber_js_1.default)(brc20.amt)
102
+ .multipliedBy(1e18)
103
+ .isEqualTo(((_d = data.request.data) === null || _d === void 0 ? void 0 : _d.inputAmount) || 0)) {
104
+ invalidRequests.push(Object.assign(Object.assign({}, data), { message: `invalid brc20 amount -> ${(_e = inscription === null || inscription === void 0 ? void 0 : inscription.brc20) === null || _e === void 0 ? void 0 : _e.op}:${(_f = inscription === null || inscription === void 0 ? void 0 : inscription.brc20) === null || _f === void 0 ? void 0 : _f.amt}:${(_g = data.request.data) === null || _g === void 0 ? void 0 : _g.inputAmount}` }));
105
+ }
106
+ else {
107
+ requests.push(Object.assign(Object.assign({}, data), { brc20 }));
108
+ }
109
+ }
110
+ else if (data.request.code !== "NO_OP_RETURN") {
111
+ invalidRequests.push(data);
112
+ }
113
+ }
114
+ return { requests, invalidRequests };
115
+ });
116
+ }
117
+ getBTCUtxo(address, signerInfo) {
118
+ var _a;
119
+ return __awaiter(this, void 0, void 0, function* () {
120
+ return providers_1.bitcoin.UniSat.convertToNormalUtxo(((_a = (yield this.unisat.getBTCUtxo(address))) === null || _a === void 0 ? void 0 : _a.utxo) || []).map(({ txId, index, value }) => ({
121
+ hash: txId,
122
+ index,
123
+ value,
124
+ signerInfo,
125
+ }));
126
+ });
127
+ }
128
+ getInscriptionUtxo(address, signerInfo) {
129
+ var _a;
130
+ return __awaiter(this, void 0, void 0, function* () {
131
+ return providers_1.bitcoin.UniSat.convertToNormalUtxo(((_a = (yield this.unisat.getInscriptionUtxo(address))) === null || _a === void 0 ? void 0 : _a.utxo) || []).map(({ txId, index, value }) => ({
132
+ hash: txId,
133
+ index,
134
+ value,
135
+ signerInfo,
136
+ }));
137
+ });
138
+ }
139
+ }
140
+ exports.BitcoinInterfaceOrdinal = BitcoinInterfaceOrdinal;
141
141
  //# sourceMappingURL=bitcoin-interface-ordinal.js.map