@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.
- package/dist/bitcoin-interface-ordinal.d.ts +108 -108
- package/dist/bitcoin-interface-ordinal.js +140 -140
- package/dist/bitcoin-interface-teleswap.d.ts +83 -101
- package/dist/bitcoin-interface-teleswap.d.ts.map +1 -1
- package/dist/bitcoin-interface-teleswap.js +119 -176
- package/dist/bitcoin-interface-teleswap.js.map +1 -1
- package/dist/bitcoin-interface-utils.d.ts +20 -20
- package/dist/bitcoin-interface-utils.js +45 -45
- package/dist/bitcoin-interface-wallet.d.ts +29 -28
- package/dist/bitcoin-interface-wallet.d.ts.map +1 -1
- package/dist/bitcoin-interface-wallet.js +126 -125
- package/dist/bitcoin-interface-wallet.js.map +1 -1
- package/dist/bitcoin-interface.d.ts +63 -66
- package/dist/bitcoin-interface.d.ts.map +1 -1
- package/dist/bitcoin-interface.js +112 -119
- package/dist/bitcoin-interface.js.map +1 -1
- package/dist/bitcoin-utils.d.ts +96 -96
- package/dist/bitcoin-utils.js +514 -514
- package/dist/bitcoin-wallet-base.d.ts +111 -111
- package/dist/bitcoin-wallet-base.d.ts.map +1 -1
- package/dist/bitcoin-wallet-base.js +258 -258
- package/dist/helper/brc20-helper.d.ts +42 -42
- package/dist/helper/brc20-helper.js +127 -127
- package/dist/helper/index.d.ts +3 -3
- package/dist/helper/index.js +29 -29
- package/dist/helper/ordinal-helper.d.ts +12 -12
- package/dist/helper/ordinal-helper.js +129 -129
- package/dist/helper/teleswap-helper.d.ts +95 -95
- package/dist/helper/teleswap-helper.js +186 -186
- package/dist/index.d.ts +12 -12
- package/dist/index.js +41 -41
- package/dist/ordinal-wallet.d.ts +492 -495
- package/dist/ordinal-wallet.d.ts.map +1 -1
- package/dist/ordinal-wallet.js +386 -386
- package/dist/ordinal-wallet.js.map +1 -1
- package/dist/sign/index.d.ts +1 -1
- package/dist/sign/index.js +8 -8
- package/dist/sign/sign-transaction.d.ts +12 -12
- package/dist/sign/sign-transaction.js +82 -82
- package/dist/teleswap-wallet.d.ts +45 -45
- package/dist/teleswap-wallet.js +68 -68
- package/dist/transaction-builder/bitcoin-transaction-builder.d.ts +9 -9
- package/dist/transaction-builder/bitcoin-transaction-builder.d.ts.map +1 -1
- package/dist/transaction-builder/bitcoin-transaction-builder.js +54 -54
- package/dist/transaction-builder/bitcoin-transaction-builder.js.map +1 -1
- package/dist/transaction-builder/index.d.ts +3 -3
- package/dist/transaction-builder/index.js +19 -19
- package/dist/transaction-builder/ordinal-transaction-builder.d.ts +63 -63
- package/dist/transaction-builder/ordinal-transaction-builder.js +125 -125
- package/dist/transaction-builder/transaction-builder.d.ts +223 -223
- package/dist/transaction-builder/transaction-builder.d.ts.map +1 -1
- package/dist/transaction-builder/transaction-builder.js +442 -447
- package/dist/transaction-builder/transaction-builder.js.map +1 -1
- package/dist/type.d.ts +55 -61
- package/dist/type.d.ts.map +1 -1
- package/dist/type.js +2 -2
- package/dist/utils/networks.d.ts +5 -5
- package/dist/utils/networks.js +53 -53
- package/dist/utils/tools.d.ts +18 -18
- package/dist/utils/tools.js +74 -74
- package/package.json +4 -4
- package/src/bitcoin-interface-ordinal.ts +185 -185
- package/src/bitcoin-interface-teleswap.ts +246 -251
- package/src/bitcoin-interface-utils.ts +60 -60
- package/src/bitcoin-interface-wallet.ts +112 -114
- package/src/bitcoin-interface.ts +146 -156
- package/src/bitcoin-utils.ts +591 -591
- package/src/bitcoin-wallet-base.ts +344 -344
- package/src/helper/brc20-helper.ts +179 -179
- package/src/helper/ordinal-helper.ts +118 -118
- package/src/index.ts +15 -15
- package/src/ordinal-wallet.ts +654 -659
- package/src/sign/index.ts +1 -1
- package/src/sign/sign-transaction.ts +108 -108
- package/src/teleswap-wallet.ts +133 -133
- package/src/transaction-builder/bitcoin-transaction-builder.ts +26 -26
- package/src/transaction-builder/index.ts +3 -3
- package/src/transaction-builder/ordinal-transaction-builder.ts +139 -139
- package/src/transaction-builder/transaction-builder.ts +686 -690
- package/src/type.ts +64 -74
- package/src/utils/networks.ts +33 -33
- package/src/utils/tools.ts +92 -92
- package/tsconfig.json +9 -9
- package/webpack.config.js +16 -16
- package/.tmp/block-parser.ts +0 -58
- package/.tmp/check.ts +0 -101
- package/.tmp/ordinal-helper.ts +0 -133
- package/.tmp/ordinal.ts +0 -25
- package/.tmp/psbt/sign-transaction.ts +0 -121
- package/.tmp/rbf.ts +0 -45
|
@@ -1,102 +1,84 @@
|
|
|
1
|
-
import { bitcoin } from "@teleportdao/providers";
|
|
2
|
-
import { UnwrapInfo, WrapOpReturnWithType } from "./helper/teleswap-helper";
|
|
3
|
-
import BitcoinInterface from "./bitcoin-interface";
|
|
4
|
-
import { BitcoinNodeConnectionInfo, Transaction } from "./type";
|
|
5
|
-
export type ValidWrapRequest = {
|
|
6
|
-
transaction: bitcoin.Types.ConfirmedTransaction & {
|
|
7
|
-
address?: string;
|
|
8
|
-
addressScript?: string;
|
|
9
|
-
merkleProof?: Transaction["merkleProof"];
|
|
10
|
-
};
|
|
11
|
-
request: {
|
|
12
|
-
status: boolean;
|
|
13
|
-
data: WrapOpReturnWithType;
|
|
14
|
-
value: number;
|
|
15
|
-
valueOutputIndex: number;
|
|
16
|
-
};
|
|
17
|
-
lockerAddress: string;
|
|
18
|
-
lockerLockingScript: string;
|
|
19
|
-
};
|
|
20
|
-
export type InValidWrapRequest = {
|
|
21
|
-
transaction: bitcoin.Types.ConfirmedTransaction & {
|
|
22
|
-
address?: string;
|
|
23
|
-
addressScript?: string;
|
|
24
|
-
merkleProof?: Transaction["merkleProof"];
|
|
25
|
-
};
|
|
26
|
-
request: {
|
|
27
|
-
status: boolean;
|
|
28
|
-
message: string;
|
|
29
|
-
code: string;
|
|
30
|
-
};
|
|
31
|
-
lockerAddress: string;
|
|
32
|
-
lockerLockingScript: string;
|
|
33
|
-
};
|
|
34
|
-
export type UnwrapRequest = {
|
|
35
|
-
burnInfo: UnwrapInfo | undefined;
|
|
36
|
-
lockerAddress: string;
|
|
37
|
-
lockerLockingScript: string;
|
|
38
|
-
};
|
|
39
|
-
export declare class BitcoinInterfaceTeleswap extends BitcoinInterface {
|
|
40
|
-
constructor(connectionInfo: BitcoinNodeConnectionInfo, networkName: string);
|
|
41
|
-
getHexBlockHeaders(startBlockNumber: number, endBlockNumber: number): Promise<{
|
|
42
|
-
hexBlockHeaders: string;
|
|
43
|
-
fromBlockNumber: number;
|
|
44
|
-
toBlockNumber: number;
|
|
45
|
-
difficulty: string | null;
|
|
46
|
-
}[]>;
|
|
47
|
-
getWrapRequests(addresses: string[], startblockNumber: number, endBlockNumber: number): Promise<{
|
|
48
|
-
requests: ValidWrapRequest[];
|
|
49
|
-
invalidRequests: InValidWrapRequest[];
|
|
50
|
-
}>;
|
|
51
|
-
getWrapRequestByTx(inputTransaction: {
|
|
52
|
-
txId: string;
|
|
53
|
-
} | (bitcoin.Types.ConfirmedTransaction & {
|
|
54
|
-
address?: string;
|
|
55
|
-
addressScript?: string;
|
|
56
|
-
merkleProof?: Transaction["merkleProof"];
|
|
57
|
-
}), lockerAddress: string): Promise<{
|
|
58
|
-
transaction: bitcoin.Types.ConfirmedTransaction & {
|
|
59
|
-
address?: string | undefined;
|
|
60
|
-
addressScript?: string | undefined;
|
|
61
|
-
merkleProof?: Transaction["merkleProof"];
|
|
62
|
-
};
|
|
63
|
-
request: {
|
|
64
|
-
status: boolean;
|
|
65
|
-
message: string;
|
|
66
|
-
code: string;
|
|
67
|
-
data?: undefined;
|
|
68
|
-
value?: undefined;
|
|
69
|
-
valueOutputIndex?: undefined;
|
|
70
|
-
requestOutputIndex?: undefined;
|
|
71
|
-
} | {
|
|
72
|
-
status: true;
|
|
73
|
-
data: WrapOpReturnWithType;
|
|
74
|
-
value: number;
|
|
75
|
-
valueOutputIndex: number;
|
|
76
|
-
requestOutputIndex: number;
|
|
77
|
-
message?: undefined;
|
|
78
|
-
code?: undefined;
|
|
79
|
-
};
|
|
80
|
-
lockerAddress: string;
|
|
81
|
-
lockerLockingScript: string;
|
|
82
|
-
}>;
|
|
83
|
-
|
|
84
|
-
transaction: Transaction;
|
|
85
|
-
burnInfo: UnwrapInfo | undefined;
|
|
86
|
-
lockerAddress: string;
|
|
87
|
-
lockerLockingScript: string;
|
|
88
|
-
}[]>;
|
|
89
|
-
getLockersUnwrapMEmpoolTransactions(addresses: string[], startBlockNumber: number, endBlockNumber: number): Promise<{
|
|
90
|
-
transaction: Transaction;
|
|
91
|
-
burnInfo: UnwrapInfo | undefined;
|
|
92
|
-
lockerAddress: string;
|
|
93
|
-
lockerLockingScript: string;
|
|
94
|
-
}[]>;
|
|
95
|
-
getTransactionUnwrapInfoByTx(transaction: {
|
|
96
|
-
txId: any;
|
|
97
|
-
vout?: any;
|
|
98
|
-
vin?: any;
|
|
99
|
-
addressScript?: any;
|
|
100
|
-
}, lockerAddress: string): Promise<UnwrapRequest | undefined>;
|
|
101
|
-
}
|
|
1
|
+
import { bitcoin } from "@teleportdao/providers";
|
|
2
|
+
import { UnwrapInfo, WrapOpReturnWithType } from "./helper/teleswap-helper";
|
|
3
|
+
import BitcoinInterface from "./bitcoin-interface";
|
|
4
|
+
import { BitcoinNodeConnectionInfo, Transaction } from "./type";
|
|
5
|
+
export type ValidWrapRequest = {
|
|
6
|
+
transaction: bitcoin.Types.ConfirmedTransaction & {
|
|
7
|
+
address?: string;
|
|
8
|
+
addressScript?: string;
|
|
9
|
+
merkleProof?: Transaction["merkleProof"];
|
|
10
|
+
};
|
|
11
|
+
request: {
|
|
12
|
+
status: boolean;
|
|
13
|
+
data: WrapOpReturnWithType;
|
|
14
|
+
value: number;
|
|
15
|
+
valueOutputIndex: number;
|
|
16
|
+
};
|
|
17
|
+
lockerAddress: string;
|
|
18
|
+
lockerLockingScript: string;
|
|
19
|
+
};
|
|
20
|
+
export type InValidWrapRequest = {
|
|
21
|
+
transaction: bitcoin.Types.ConfirmedTransaction & {
|
|
22
|
+
address?: string;
|
|
23
|
+
addressScript?: string;
|
|
24
|
+
merkleProof?: Transaction["merkleProof"];
|
|
25
|
+
};
|
|
26
|
+
request: {
|
|
27
|
+
status: boolean;
|
|
28
|
+
message: string;
|
|
29
|
+
code: string;
|
|
30
|
+
};
|
|
31
|
+
lockerAddress: string;
|
|
32
|
+
lockerLockingScript: string;
|
|
33
|
+
};
|
|
34
|
+
export type UnwrapRequest = {
|
|
35
|
+
burnInfo: UnwrapInfo | undefined;
|
|
36
|
+
lockerAddress: string;
|
|
37
|
+
lockerLockingScript: string;
|
|
38
|
+
};
|
|
39
|
+
export declare class BitcoinInterfaceTeleswap extends BitcoinInterface {
|
|
40
|
+
constructor(connectionInfo: BitcoinNodeConnectionInfo, networkName: string);
|
|
41
|
+
getHexBlockHeaders(startBlockNumber: number, endBlockNumber: number): Promise<{
|
|
42
|
+
hexBlockHeaders: string;
|
|
43
|
+
fromBlockNumber: number;
|
|
44
|
+
toBlockNumber: number;
|
|
45
|
+
difficulty: string | null;
|
|
46
|
+
}[]>;
|
|
47
|
+
getWrapRequests(addresses: string[], startblockNumber: number, endBlockNumber: number): Promise<{
|
|
48
|
+
requests: ValidWrapRequest[];
|
|
49
|
+
invalidRequests: InValidWrapRequest[];
|
|
50
|
+
}>;
|
|
51
|
+
getWrapRequestByTx(inputTransaction: {
|
|
52
|
+
txId: string;
|
|
53
|
+
} | (bitcoin.Types.ConfirmedTransaction & {
|
|
54
|
+
address?: string;
|
|
55
|
+
addressScript?: string;
|
|
56
|
+
merkleProof?: Transaction["merkleProof"];
|
|
57
|
+
}), lockerAddress: string): Promise<{
|
|
58
|
+
transaction: bitcoin.Types.ConfirmedTransaction & {
|
|
59
|
+
address?: string | undefined;
|
|
60
|
+
addressScript?: string | undefined;
|
|
61
|
+
merkleProof?: Transaction["merkleProof"];
|
|
62
|
+
};
|
|
63
|
+
request: {
|
|
64
|
+
status: boolean;
|
|
65
|
+
message: string;
|
|
66
|
+
code: string;
|
|
67
|
+
data?: undefined;
|
|
68
|
+
value?: undefined;
|
|
69
|
+
valueOutputIndex?: undefined;
|
|
70
|
+
requestOutputIndex?: undefined;
|
|
71
|
+
} | {
|
|
72
|
+
status: true;
|
|
73
|
+
data: WrapOpReturnWithType;
|
|
74
|
+
value: number;
|
|
75
|
+
valueOutputIndex: number;
|
|
76
|
+
requestOutputIndex: number;
|
|
77
|
+
message?: undefined;
|
|
78
|
+
code?: undefined;
|
|
79
|
+
};
|
|
80
|
+
lockerAddress: string;
|
|
81
|
+
lockerLockingScript: string;
|
|
82
|
+
}>;
|
|
83
|
+
}
|
|
102
84
|
//# sourceMappingURL=bitcoin-interface-teleswap.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"bitcoin-interface-teleswap.d.ts","sourceRoot":"","sources":["../src/bitcoin-interface-teleswap.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,wBAAwB,CAAA;AAGhD,OAAO,EAGL,UAAU,EACV,oBAAoB,EACrB,MAAM,0BAA0B,CAAA;AACjC,OAAO,gBAAgB,MAAM,qBAAqB,CAAA;AAClD,OAAO,EAAE,yBAAyB,EAAE,WAAW,EAAE,MAAM,QAAQ,CAAA;AAE/D,MAAM,MAAM,gBAAgB,GAAG;IAC7B,WAAW,EAAE,OAAO,CAAC,KAAK,CAAC,oBAAoB,GAAG;QAChD,OAAO,CAAC,EAAE,MAAM,CAAA;QAChB,aAAa,CAAC,EAAE,MAAM,CAAA;QACtB,WAAW,CAAC,EAAE,WAAW,CAAC,aAAa,CAAC,CAAA;KACzC,CAAA;IACD,OAAO,EAAE;QACP,MAAM,EAAE,OAAO,CAAA;QACf,IAAI,EAAE,oBAAoB,CAAA;QAC1B,KAAK,EAAE,MAAM,CAAA;QACb,gBAAgB,EAAE,MAAM,CAAA;KACzB,CAAA;IACD,aAAa,EAAE,MAAM,CAAA;IACrB,mBAAmB,EAAE,MAAM,CAAA;CAC5B,CAAA;AAED,MAAM,MAAM,kBAAkB,GAAG;IAC/B,WAAW,EA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A;AAED,qBAAa,wBAAyB,SAAQ,gBAAgB;gBAChD,cAAc,EAAE,yBAAyB,EAAE,WAAW,EAAE,MAAM;IAOpE,kBAAkB,CAAC,gBAAgB,EAAE,MAAM,EAAE,cAAc,EAAE,MAAM;;;;;;IAoCnE,eAAe,CAAC,SAAS,EAAE,MAAM,EAAE,EAAE,gBAAgB,EAAE,MAAM,EAAE,cAAc,EAAE,MAAM;;;;IAyCrF,kBAAkB,CACtB,gBAAgB,EACZ;QAAE,IAAI,EAAE,MAAM,CAAA;KAAE,GAChB,CAAC,OAAO,CAAC,KAAK,CAAC,oBAAoB,GAAG;QACpC,OAAO,CAAC,EAAE,MAAM,CAAA;QAChB,aAAa,CAAC,EAAE,MAAM,CAAA;QACtB,WAAW,CAAC,EAAE,WAAW,CAAC,aAAa,CAAC,CAAA;KACzC,CAAC,EACN,aAAa,EAAE,MAAM;;;;0BAKL,WAAW,CAAC,aAAa,CAAC;;;;;;;;;;;;;;;;;;;;;;CAkG7C"}
|
|
@@ -1,177 +1,120 @@
|
|
|
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.BitcoinInterfaceTeleswap = void 0;
|
|
16
|
-
const configs_1 = require("@teleportdao/configs");
|
|
17
|
-
const bitcoin_utils_1 = require("./bitcoin-utils");
|
|
18
|
-
const teleswap_helper_1 = require("./helper/teleswap-helper");
|
|
19
|
-
const bitcoin_interface_1 = __importDefault(require("./bitcoin-interface"));
|
|
20
|
-
class BitcoinInterfaceTeleswap extends bitcoin_interface_1.default {
|
|
21
|
-
constructor(connectionInfo, networkName) {
|
|
22
|
-
if (!connectionInfo.rpc) {
|
|
23
|
-
throw new Error("rpc provider is required");
|
|
24
|
-
}
|
|
25
|
-
super(networkName, connectionInfo);
|
|
26
|
-
}
|
|
27
|
-
getHexBlockHeaders(startBlockNumber, endBlockNumber) {
|
|
28
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
29
|
-
const blockHeaders = [];
|
|
30
|
-
let difficulty = null;
|
|
31
|
-
let hexBlockHeaders = "";
|
|
32
|
-
let fromBlockNumber = startBlockNumber;
|
|
33
|
-
for (let blockNumber = startBlockNumber; blockNumber <= endBlockNumber; blockNumber += 1) {
|
|
34
|
-
let blockHeader = yield this.getBlockHeaderHex(blockNumber);
|
|
35
|
-
console.log("block", blockNumber);
|
|
36
|
-
let parsedBlockHeader = (0, bitcoin_utils_1.parseBlockHeader)(blockHeader);
|
|
37
|
-
if (difficulty && parsedBlockHeader.difficulty !== difficulty) {
|
|
38
|
-
blockHeaders.push({
|
|
39
|
-
hexBlockHeaders,
|
|
40
|
-
fromBlockNumber,
|
|
41
|
-
toBlockNumber: blockNumber - 1,
|
|
42
|
-
difficulty,
|
|
43
|
-
});
|
|
44
|
-
hexBlockHeaders = blockHeader;
|
|
45
|
-
fromBlockNumber = blockNumber;
|
|
46
|
-
}
|
|
47
|
-
else {
|
|
48
|
-
hexBlockHeaders += blockHeader;
|
|
49
|
-
}
|
|
50
|
-
difficulty = parsedBlockHeader.difficulty;
|
|
51
|
-
}
|
|
52
|
-
if (hexBlockHeaders) {
|
|
53
|
-
blockHeaders.push({
|
|
54
|
-
hexBlockHeaders,
|
|
55
|
-
fromBlockNumber,
|
|
56
|
-
toBlockNumber: endBlockNumber,
|
|
57
|
-
difficulty,
|
|
58
|
-
});
|
|
59
|
-
}
|
|
60
|
-
return blockHeaders;
|
|
61
|
-
});
|
|
62
|
-
}
|
|
63
|
-
getWrapRequests(addresses, startblockNumber, endBlockNumber) {
|
|
64
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
65
|
-
let transactions = yield this.getMultipleBlocksTransactions(addresses, startblockNumber, endBlockNumber);
|
|
66
|
-
let requests = [];
|
|
67
|
-
let invalidRequests = [];
|
|
68
|
-
for (let inputTx of transactions) {
|
|
69
|
-
let { transaction, request, lockerAddress, lockerLockingScript } = yield this.getWrapRequestByTx(inputTx, inputTx.address);
|
|
70
|
-
if (request.status && "data" in request && request.data) {
|
|
71
|
-
if (!configs_1.teleswap.requestAppId[request.data.requestType].appIds.includes(request.data.appId)) {
|
|
72
|
-
invalidRequests.push({
|
|
73
|
-
transaction,
|
|
74
|
-
request: Object.assign(Object.assign({}, request), { message: "invalid app id", code: "INVALID_APP_ID" }),
|
|
75
|
-
lockerAddress,
|
|
76
|
-
lockerLockingScript,
|
|
77
|
-
});
|
|
78
|
-
}
|
|
79
|
-
else {
|
|
80
|
-
requests.push({
|
|
81
|
-
transaction,
|
|
82
|
-
request,
|
|
83
|
-
lockerAddress,
|
|
84
|
-
lockerLockingScript,
|
|
85
|
-
});
|
|
86
|
-
}
|
|
87
|
-
}
|
|
88
|
-
else if (request.code !== "NO_OP_RETURN") {
|
|
89
|
-
invalidRequests.push({ transaction, request, lockerAddress, lockerLockingScript });
|
|
90
|
-
}
|
|
91
|
-
}
|
|
92
|
-
return { requests, invalidRequests };
|
|
93
|
-
});
|
|
94
|
-
}
|
|
95
|
-
getWrapRequestByTx(inputTransaction, lockerAddress) {
|
|
96
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
97
|
-
let transaction;
|
|
98
|
-
if ("vout" in inputTransaction && "blockNumber" in inputTransaction) {
|
|
99
|
-
transaction = inputTransaction;
|
|
100
|
-
}
|
|
101
|
-
else {
|
|
102
|
-
if (!inputTransaction.txId)
|
|
103
|
-
throw new Error("txId not exist");
|
|
104
|
-
transaction = yield this.getTransaction(inputTransaction.txId);
|
|
105
|
-
}
|
|
106
|
-
let vout = transaction.vout;
|
|
107
|
-
let request = (0, teleswap_helper_1.checkAndParseWrapRequest)(vout, lockerAddress);
|
|
108
|
-
let lockerLockingScript = transaction.addressScript ||
|
|
109
|
-
this.convertAddressToScript(lockerAddress).script.toString("hex");
|
|
110
|
-
return {
|
|
111
|
-
transaction,
|
|
112
|
-
request,
|
|
113
|
-
lockerAddress,
|
|
114
|
-
lockerLockingScript,
|
|
115
|
-
};
|
|
116
|
-
});
|
|
117
|
-
}
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
let transactions = yield this.getMultipleBlocksTransactions(addresses, startBlockNumber, endBlockNumber);
|
|
121
|
-
let validTxs = [];
|
|
122
|
-
for (let transaction of transactions) {
|
|
123
|
-
let address = transaction.address;
|
|
124
|
-
let txBurnInfo = yield this.getTransactionUnwrapInfoByTx(transaction, address);
|
|
125
|
-
if (txBurnInfo) {
|
|
126
|
-
const { burnInfo, lockerAddress, lockerLockingScript } = txBurnInfo;
|
|
127
|
-
validTxs.push({
|
|
128
|
-
transaction,
|
|
129
|
-
burnInfo,
|
|
130
|
-
lockerAddress,
|
|
131
|
-
lockerLockingScript,
|
|
132
|
-
});
|
|
133
|
-
}
|
|
134
|
-
}
|
|
135
|
-
return validTxs;
|
|
136
|
-
});
|
|
137
|
-
}
|
|
138
|
-
getLockersUnwrapMEmpoolTransactions(addresses, startBlockNumber, endBlockNumber) {
|
|
139
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
140
|
-
let transactions = yield this.getMultipleBlocksTransactions(addresses, startBlockNumber, endBlockNumber);
|
|
141
|
-
let validTxs = [];
|
|
142
|
-
for (let transaction of transactions) {
|
|
143
|
-
let address = transaction.address;
|
|
144
|
-
let txBurnInfo = yield this.getTransactionUnwrapInfoByTx(transaction, address);
|
|
145
|
-
if (txBurnInfo) {
|
|
146
|
-
const { burnInfo, lockerAddress, lockerLockingScript } = txBurnInfo;
|
|
147
|
-
validTxs.push({
|
|
148
|
-
transaction,
|
|
149
|
-
burnInfo,
|
|
150
|
-
lockerAddress,
|
|
151
|
-
lockerLockingScript,
|
|
152
|
-
});
|
|
153
|
-
}
|
|
154
|
-
}
|
|
155
|
-
return validTxs;
|
|
156
|
-
});
|
|
157
|
-
}
|
|
158
|
-
getTransactionUnwrapInfoByTx(transaction, lockerAddress) {
|
|
159
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
160
|
-
if (!transaction.txId)
|
|
161
|
-
throw new Error("txId not exist");
|
|
162
|
-
let vin = transaction.vin || (yield this.getTransaction(transaction.txId)).vin;
|
|
163
|
-
let burnInfo = (0, teleswap_helper_1.getBurnTransactionInfo)(lockerAddress, vin, transaction.vout);
|
|
164
|
-
if (!burnInfo)
|
|
165
|
-
return;
|
|
166
|
-
let lockerLockingScript = transaction.addressScript ||
|
|
167
|
-
this.convertAddressToScript(lockerAddress).script.toString("hex");
|
|
168
|
-
return {
|
|
169
|
-
burnInfo,
|
|
170
|
-
lockerAddress,
|
|
171
|
-
lockerLockingScript,
|
|
172
|
-
};
|
|
173
|
-
});
|
|
174
|
-
}
|
|
175
|
-
}
|
|
176
|
-
exports.BitcoinInterfaceTeleswap = BitcoinInterfaceTeleswap;
|
|
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.BitcoinInterfaceTeleswap = void 0;
|
|
16
|
+
const configs_1 = require("@teleportdao/configs");
|
|
17
|
+
const bitcoin_utils_1 = require("./bitcoin-utils");
|
|
18
|
+
const teleswap_helper_1 = require("./helper/teleswap-helper");
|
|
19
|
+
const bitcoin_interface_1 = __importDefault(require("./bitcoin-interface"));
|
|
20
|
+
class BitcoinInterfaceTeleswap extends bitcoin_interface_1.default {
|
|
21
|
+
constructor(connectionInfo, networkName) {
|
|
22
|
+
if (!connectionInfo.rpc) {
|
|
23
|
+
throw new Error("rpc provider is required");
|
|
24
|
+
}
|
|
25
|
+
super(networkName, connectionInfo);
|
|
26
|
+
}
|
|
27
|
+
getHexBlockHeaders(startBlockNumber, endBlockNumber) {
|
|
28
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
29
|
+
const blockHeaders = [];
|
|
30
|
+
let difficulty = null;
|
|
31
|
+
let hexBlockHeaders = "";
|
|
32
|
+
let fromBlockNumber = startBlockNumber;
|
|
33
|
+
for (let blockNumber = startBlockNumber; blockNumber <= endBlockNumber; blockNumber += 1) {
|
|
34
|
+
let blockHeader = yield this.getBlockHeaderHex(blockNumber);
|
|
35
|
+
console.log("block", blockNumber);
|
|
36
|
+
let parsedBlockHeader = (0, bitcoin_utils_1.parseBlockHeader)(blockHeader);
|
|
37
|
+
if (difficulty && parsedBlockHeader.difficulty !== difficulty) {
|
|
38
|
+
blockHeaders.push({
|
|
39
|
+
hexBlockHeaders,
|
|
40
|
+
fromBlockNumber,
|
|
41
|
+
toBlockNumber: blockNumber - 1,
|
|
42
|
+
difficulty,
|
|
43
|
+
});
|
|
44
|
+
hexBlockHeaders = blockHeader;
|
|
45
|
+
fromBlockNumber = blockNumber;
|
|
46
|
+
}
|
|
47
|
+
else {
|
|
48
|
+
hexBlockHeaders += blockHeader;
|
|
49
|
+
}
|
|
50
|
+
difficulty = parsedBlockHeader.difficulty;
|
|
51
|
+
}
|
|
52
|
+
if (hexBlockHeaders) {
|
|
53
|
+
blockHeaders.push({
|
|
54
|
+
hexBlockHeaders,
|
|
55
|
+
fromBlockNumber,
|
|
56
|
+
toBlockNumber: endBlockNumber,
|
|
57
|
+
difficulty,
|
|
58
|
+
});
|
|
59
|
+
}
|
|
60
|
+
return blockHeaders;
|
|
61
|
+
});
|
|
62
|
+
}
|
|
63
|
+
getWrapRequests(addresses, startblockNumber, endBlockNumber) {
|
|
64
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
65
|
+
let transactions = yield this.getMultipleBlocksTransactions(addresses, startblockNumber, endBlockNumber);
|
|
66
|
+
let requests = [];
|
|
67
|
+
let invalidRequests = [];
|
|
68
|
+
for (let inputTx of transactions) {
|
|
69
|
+
let { transaction, request, lockerAddress, lockerLockingScript } = yield this.getWrapRequestByTx(inputTx, inputTx.address);
|
|
70
|
+
if (request.status && "data" in request && request.data) {
|
|
71
|
+
if (!configs_1.teleswap.requestAppId[request.data.requestType].appIds.includes(request.data.appId)) {
|
|
72
|
+
invalidRequests.push({
|
|
73
|
+
transaction,
|
|
74
|
+
request: Object.assign(Object.assign({}, request), { message: "invalid app id", code: "INVALID_APP_ID" }),
|
|
75
|
+
lockerAddress,
|
|
76
|
+
lockerLockingScript,
|
|
77
|
+
});
|
|
78
|
+
}
|
|
79
|
+
else {
|
|
80
|
+
requests.push({
|
|
81
|
+
transaction,
|
|
82
|
+
request,
|
|
83
|
+
lockerAddress,
|
|
84
|
+
lockerLockingScript,
|
|
85
|
+
});
|
|
86
|
+
}
|
|
87
|
+
}
|
|
88
|
+
else if (request.code !== "NO_OP_RETURN") {
|
|
89
|
+
invalidRequests.push({ transaction, request, lockerAddress, lockerLockingScript });
|
|
90
|
+
}
|
|
91
|
+
}
|
|
92
|
+
return { requests, invalidRequests };
|
|
93
|
+
});
|
|
94
|
+
}
|
|
95
|
+
getWrapRequestByTx(inputTransaction, lockerAddress) {
|
|
96
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
97
|
+
let transaction;
|
|
98
|
+
if ("vout" in inputTransaction && "blockNumber" in inputTransaction) {
|
|
99
|
+
transaction = inputTransaction;
|
|
100
|
+
}
|
|
101
|
+
else {
|
|
102
|
+
if (!inputTransaction.txId)
|
|
103
|
+
throw new Error("txId not exist");
|
|
104
|
+
transaction = yield this.getTransaction(inputTransaction.txId);
|
|
105
|
+
}
|
|
106
|
+
let vout = transaction.vout;
|
|
107
|
+
let request = (0, teleswap_helper_1.checkAndParseWrapRequest)(vout, lockerAddress);
|
|
108
|
+
let lockerLockingScript = transaction.addressScript ||
|
|
109
|
+
this.convertAddressToScript(lockerAddress).script.toString("hex");
|
|
110
|
+
return {
|
|
111
|
+
transaction,
|
|
112
|
+
request,
|
|
113
|
+
lockerAddress,
|
|
114
|
+
lockerLockingScript,
|
|
115
|
+
};
|
|
116
|
+
});
|
|
117
|
+
}
|
|
118
|
+
}
|
|
119
|
+
exports.BitcoinInterfaceTeleswap = BitcoinInterfaceTeleswap;
|
|
177
120
|
//# sourceMappingURL=bitcoin-interface-teleswap.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"bitcoin-interface-teleswap.js","sourceRoot":"","sources":["../src/bitcoin-interface-teleswap.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;AACA,kDAA+C;AAC/C,mDAAkD;AAClD,8DAKiC;AACjC,4EAAkD;AAwClD,MAAa,wBAAyB,SAAQ,2BAAgB;IAC5D,YAAY,cAAyC,EAAE,WAAmB;QACxE,IAAI,CAAC,cAAc,CAAC,GAAG,EAAE;YACvB,MAAM,IAAI,KAAK,CAAC,0BAA0B,CAAC,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,IAAI,CAAC,sBAAsB,CAAC,aAAa,CAAC,CAAC,MAAO,CAAC,QAAQ,CAAC,KAAK,CAAC,CAAA;YAEpE,OAAO;gBACL,WAAW;gBACX,OAAO;gBACP,aAAa;gBACb,mBAAmB;aACpB,CAAA;QACH,CAAC;KAAA;CA6EF;AApMD,4DAoMC"}
|
|
@@ -1,21 +1,21 @@
|
|
|
1
|
-
/// <reference types="node" />
|
|
2
|
-
import type { Network } from "bitcoinjs-lib";
|
|
3
|
-
export declare class BitcoinInterfaceUtils {
|
|
4
|
-
testnet: boolean;
|
|
5
|
-
network: Network;
|
|
6
|
-
constructor(networkName: string);
|
|
7
|
-
convertHashToAddress(hashHex: string, addressType: string): string;
|
|
8
|
-
convertScriptToAddress(scriptHex: string, addressType: string): string;
|
|
9
|
-
convertAddressToScript(address: string): {
|
|
10
|
-
script: Buffer | undefined;
|
|
11
|
-
hash: Buffer | undefined;
|
|
12
|
-
addressType: "p2tr" | "p2wpkh" | "p2sh" | "p2pkh";
|
|
13
|
-
};
|
|
14
|
-
convertAddressToObject(address: string): {
|
|
15
|
-
addressObject: import("bitcoinjs-lib").Payment;
|
|
16
|
-
addressType: "p2tr" | "p2wpkh" | "p2sh" | "p2pkh";
|
|
17
|
-
};
|
|
18
|
-
createAddressObjectByPublicKey(publicKey: string, addressType: string): import("bitcoinjs-lib").Payment;
|
|
19
|
-
}
|
|
20
|
-
export default BitcoinInterfaceUtils;
|
|
1
|
+
/// <reference types="node" />
|
|
2
|
+
import type { Network } from "bitcoinjs-lib";
|
|
3
|
+
export declare class BitcoinInterfaceUtils {
|
|
4
|
+
testnet: boolean;
|
|
5
|
+
network: Network;
|
|
6
|
+
constructor(networkName: string);
|
|
7
|
+
convertHashToAddress(hashHex: string, addressType: string): string;
|
|
8
|
+
convertScriptToAddress(scriptHex: string, addressType: string): string;
|
|
9
|
+
convertAddressToScript(address: string): {
|
|
10
|
+
script: Buffer | undefined;
|
|
11
|
+
hash: Buffer | undefined;
|
|
12
|
+
addressType: "p2tr" | "p2wpkh" | "p2sh" | "p2pkh";
|
|
13
|
+
};
|
|
14
|
+
convertAddressToObject(address: string): {
|
|
15
|
+
addressObject: import("bitcoinjs-lib").Payment;
|
|
16
|
+
addressType: "p2tr" | "p2wpkh" | "p2sh" | "p2pkh";
|
|
17
|
+
};
|
|
18
|
+
createAddressObjectByPublicKey(publicKey: string, addressType: string): import("bitcoinjs-lib").Payment;
|
|
19
|
+
}
|
|
20
|
+
export default BitcoinInterfaceUtils;
|
|
21
21
|
//# sourceMappingURL=bitcoin-interface-utils.d.ts.map
|
|
@@ -1,46 +1,46 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
-
};
|
|
5
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
exports.BitcoinInterfaceUtils = void 0;
|
|
7
|
-
const networks_1 = __importDefault(require("./utils/networks"));
|
|
8
|
-
const bitcoin_utils_1 = require("./bitcoin-utils");
|
|
9
|
-
class BitcoinInterfaceUtils {
|
|
10
|
-
constructor(networkName) {
|
|
11
|
-
this.testnet = networkName.includes("_testnet");
|
|
12
|
-
this.network = networks_1.default[networkName];
|
|
13
|
-
}
|
|
14
|
-
convertHashToAddress(hashHex, addressType) {
|
|
15
|
-
let addressObj = (0, bitcoin_utils_1.createAddressObjectByHash)({ addressType, hash: Buffer.from(hashHex, "hex") }, this.network);
|
|
16
|
-
if (!addressObj.address)
|
|
17
|
-
throw new Error("incorrect input");
|
|
18
|
-
return addressObj.address;
|
|
19
|
-
}
|
|
20
|
-
convertScriptToAddress(scriptHex, addressType) {
|
|
21
|
-
let addressObj = (0, bitcoin_utils_1.createAddressObjectByScript)({ addressType, script: Buffer.from(scriptHex, "hex") }, this.network);
|
|
22
|
-
if (!addressObj.address)
|
|
23
|
-
throw new Error("incorrect input");
|
|
24
|
-
return addressObj.address;
|
|
25
|
-
}
|
|
26
|
-
convertAddressToScript(address) {
|
|
27
|
-
let { addressObject, addressType } = (0, bitcoin_utils_1.createAddressObjectByAddress)(address, this.network);
|
|
28
|
-
const hash = addressType === "p2tr" ? addressObject.pubkey : addressObject.hash;
|
|
29
|
-
return {
|
|
30
|
-
script: addressObject.output,
|
|
31
|
-
hash,
|
|
32
|
-
addressType,
|
|
33
|
-
};
|
|
34
|
-
}
|
|
35
|
-
convertAddressToObject(address) {
|
|
36
|
-
let addObj = (0, bitcoin_utils_1.createAddressObjectByAddress)(address, this.network);
|
|
37
|
-
return addObj;
|
|
38
|
-
}
|
|
39
|
-
createAddressObjectByPublicKey(publicKey, addressType) {
|
|
40
|
-
let addObj = (0, bitcoin_utils_1.createAddressObjectByPublicKey)({ publicKey: Buffer.from(publicKey, "hex"), addressType }, this.network);
|
|
41
|
-
return addObj;
|
|
42
|
-
}
|
|
43
|
-
}
|
|
44
|
-
exports.BitcoinInterfaceUtils = BitcoinInterfaceUtils;
|
|
45
|
-
exports.default = BitcoinInterfaceUtils;
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.BitcoinInterfaceUtils = void 0;
|
|
7
|
+
const networks_1 = __importDefault(require("./utils/networks"));
|
|
8
|
+
const bitcoin_utils_1 = require("./bitcoin-utils");
|
|
9
|
+
class BitcoinInterfaceUtils {
|
|
10
|
+
constructor(networkName) {
|
|
11
|
+
this.testnet = networkName.includes("_testnet");
|
|
12
|
+
this.network = networks_1.default[networkName];
|
|
13
|
+
}
|
|
14
|
+
convertHashToAddress(hashHex, addressType) {
|
|
15
|
+
let addressObj = (0, bitcoin_utils_1.createAddressObjectByHash)({ addressType, hash: Buffer.from(hashHex, "hex") }, this.network);
|
|
16
|
+
if (!addressObj.address)
|
|
17
|
+
throw new Error("incorrect input");
|
|
18
|
+
return addressObj.address;
|
|
19
|
+
}
|
|
20
|
+
convertScriptToAddress(scriptHex, addressType) {
|
|
21
|
+
let addressObj = (0, bitcoin_utils_1.createAddressObjectByScript)({ addressType, script: Buffer.from(scriptHex, "hex") }, this.network);
|
|
22
|
+
if (!addressObj.address)
|
|
23
|
+
throw new Error("incorrect input");
|
|
24
|
+
return addressObj.address;
|
|
25
|
+
}
|
|
26
|
+
convertAddressToScript(address) {
|
|
27
|
+
let { addressObject, addressType } = (0, bitcoin_utils_1.createAddressObjectByAddress)(address, this.network);
|
|
28
|
+
const hash = addressType === "p2tr" ? addressObject.pubkey : addressObject.hash;
|
|
29
|
+
return {
|
|
30
|
+
script: addressObject.output,
|
|
31
|
+
hash,
|
|
32
|
+
addressType,
|
|
33
|
+
};
|
|
34
|
+
}
|
|
35
|
+
convertAddressToObject(address) {
|
|
36
|
+
let addObj = (0, bitcoin_utils_1.createAddressObjectByAddress)(address, this.network);
|
|
37
|
+
return addObj;
|
|
38
|
+
}
|
|
39
|
+
createAddressObjectByPublicKey(publicKey, addressType) {
|
|
40
|
+
let addObj = (0, bitcoin_utils_1.createAddressObjectByPublicKey)({ publicKey: Buffer.from(publicKey, "hex"), addressType }, this.network);
|
|
41
|
+
return addObj;
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
exports.BitcoinInterfaceUtils = BitcoinInterfaceUtils;
|
|
45
|
+
exports.default = BitcoinInterfaceUtils;
|
|
46
46
|
//# sourceMappingURL=bitcoin-interface-utils.js.map
|