@teleportdao/bitcoin 2.0.5 → 2.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.
Files changed (90) 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 +83 -101
  4. package/dist/bitcoin-interface-teleswap.d.ts.map +1 -1
  5. package/dist/bitcoin-interface-teleswap.js +119 -176
  6. package/dist/bitcoin-interface-teleswap.js.map +1 -1
  7. package/dist/bitcoin-interface-utils.d.ts +20 -20
  8. package/dist/bitcoin-interface-utils.js +45 -45
  9. package/dist/bitcoin-interface-wallet.d.ts +29 -28
  10. package/dist/bitcoin-interface-wallet.d.ts.map +1 -1
  11. package/dist/bitcoin-interface-wallet.js +126 -125
  12. package/dist/bitcoin-interface-wallet.js.map +1 -1
  13. package/dist/bitcoin-interface.d.ts +63 -66
  14. package/dist/bitcoin-interface.d.ts.map +1 -1
  15. package/dist/bitcoin-interface.js +112 -119
  16. package/dist/bitcoin-interface.js.map +1 -1
  17. package/dist/bitcoin-utils.d.ts +96 -96
  18. package/dist/bitcoin-utils.js +514 -514
  19. package/dist/bitcoin-wallet-base.d.ts +111 -111
  20. package/dist/bitcoin-wallet-base.d.ts.map +1 -1
  21. package/dist/bitcoin-wallet-base.js +258 -258
  22. package/dist/helper/brc20-helper.d.ts +42 -42
  23. package/dist/helper/brc20-helper.js +127 -127
  24. package/dist/helper/index.d.ts +3 -3
  25. package/dist/helper/index.js +29 -29
  26. package/dist/helper/ordinal-helper.d.ts +12 -12
  27. package/dist/helper/ordinal-helper.js +129 -129
  28. package/dist/helper/teleswap-helper.d.ts +95 -95
  29. package/dist/helper/teleswap-helper.js +186 -186
  30. package/dist/index.d.ts +12 -12
  31. package/dist/index.js +41 -41
  32. package/dist/ordinal-wallet.d.ts +492 -495
  33. package/dist/ordinal-wallet.d.ts.map +1 -1
  34. package/dist/ordinal-wallet.js +386 -386
  35. package/dist/ordinal-wallet.js.map +1 -1
  36. package/dist/sign/index.d.ts +1 -1
  37. package/dist/sign/index.js +8 -8
  38. package/dist/sign/sign-transaction.d.ts +12 -12
  39. package/dist/sign/sign-transaction.js +82 -82
  40. package/dist/teleswap-wallet.d.ts +45 -45
  41. package/dist/teleswap-wallet.js +68 -68
  42. package/dist/transaction-builder/bitcoin-transaction-builder.d.ts +9 -9
  43. package/dist/transaction-builder/bitcoin-transaction-builder.d.ts.map +1 -1
  44. package/dist/transaction-builder/bitcoin-transaction-builder.js +54 -54
  45. package/dist/transaction-builder/bitcoin-transaction-builder.js.map +1 -1
  46. package/dist/transaction-builder/index.d.ts +3 -3
  47. package/dist/transaction-builder/index.js +19 -19
  48. package/dist/transaction-builder/ordinal-transaction-builder.d.ts +63 -63
  49. package/dist/transaction-builder/ordinal-transaction-builder.js +125 -125
  50. package/dist/transaction-builder/transaction-builder.d.ts +223 -223
  51. package/dist/transaction-builder/transaction-builder.d.ts.map +1 -1
  52. package/dist/transaction-builder/transaction-builder.js +442 -447
  53. package/dist/transaction-builder/transaction-builder.js.map +1 -1
  54. package/dist/type.d.ts +55 -61
  55. package/dist/type.d.ts.map +1 -1
  56. package/dist/type.js +2 -2
  57. package/dist/utils/networks.d.ts +5 -5
  58. package/dist/utils/networks.js +53 -53
  59. package/dist/utils/tools.d.ts +18 -18
  60. package/dist/utils/tools.js +74 -74
  61. package/package.json +4 -4
  62. package/src/bitcoin-interface-ordinal.ts +185 -185
  63. package/src/bitcoin-interface-teleswap.ts +246 -251
  64. package/src/bitcoin-interface-utils.ts +60 -60
  65. package/src/bitcoin-interface-wallet.ts +112 -114
  66. package/src/bitcoin-interface.ts +146 -156
  67. package/src/bitcoin-utils.ts +591 -591
  68. package/src/bitcoin-wallet-base.ts +344 -344
  69. package/src/helper/brc20-helper.ts +179 -179
  70. package/src/helper/ordinal-helper.ts +118 -118
  71. package/src/index.ts +15 -15
  72. package/src/ordinal-wallet.ts +654 -659
  73. package/src/sign/index.ts +1 -1
  74. package/src/sign/sign-transaction.ts +108 -108
  75. package/src/teleswap-wallet.ts +133 -133
  76. package/src/transaction-builder/bitcoin-transaction-builder.ts +26 -26
  77. package/src/transaction-builder/index.ts +3 -3
  78. package/src/transaction-builder/ordinal-transaction-builder.ts +139 -139
  79. package/src/transaction-builder/transaction-builder.ts +686 -690
  80. package/src/type.ts +64 -74
  81. package/src/utils/networks.ts +33 -33
  82. package/src/utils/tools.ts +92 -92
  83. package/tsconfig.json +9 -9
  84. package/webpack.config.js +16 -16
  85. package/.tmp/block-parser.ts +0 -58
  86. package/.tmp/check.ts +0 -101
  87. package/.tmp/ordinal-helper.ts +0 -133
  88. package/.tmp/ordinal.ts +0 -25
  89. package/.tmp/psbt/sign-transaction.ts +0 -121
  90. 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