@teleportdao/bitcoin 2.0.4 → 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.
- package/dist/bitcoin-interface-ordinal.d.ts +108 -108
- package/dist/bitcoin-interface-ordinal.js +140 -140
- package/dist/bitcoin-interface-teleswap.d.ts +101 -101
- package/dist/bitcoin-interface-teleswap.d.ts.map +1 -1
- package/dist/bitcoin-interface-teleswap.js +176 -165
- 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 +28 -28
- package/dist/bitcoin-interface-wallet.js +125 -125
- package/dist/bitcoin-interface.d.ts +66 -66
- package/dist/bitcoin-interface.js +119 -119
- 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.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 +495 -495
- package/dist/ordinal-wallet.js +386 -386
- 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.js +54 -54
- 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.js +447 -447
- package/dist/type.d.ts +61 -61
- 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 +251 -237
- package/src/bitcoin-interface-utils.ts +60 -60
- package/src/bitcoin-interface-wallet.ts +114 -114
- package/src/bitcoin-interface.ts +156 -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 +659 -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 +690 -690
- package/src/type.ts +74 -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,120 +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.BitcoinInterface = void 0;
|
|
16
|
-
const providers_1 = require("@teleportdao/providers");
|
|
17
|
-
const tools_1 = require("./utils/tools");
|
|
18
|
-
const bitcoin_utils_1 = require("./bitcoin-utils");
|
|
19
|
-
const bitcoin_interface_wallet_1 = __importDefault(require("./bitcoin-interface-wallet"));
|
|
20
|
-
class BitcoinInterface extends bitcoin_interface_wallet_1.default {
|
|
21
|
-
constructor(networkName, connectionInfo) {
|
|
22
|
-
super(networkName, connectionInfo);
|
|
23
|
-
if (connectionInfo === null || connectionInfo === void 0 ? void 0 : connectionInfo.rpc) {
|
|
24
|
-
this.rpcProvider = providers_1.bitcoin.getRpcProvider(connectionInfo.rpc);
|
|
25
|
-
}
|
|
26
|
-
}
|
|
27
|
-
getLatestBlockNumber() {
|
|
28
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
29
|
-
let latestHeight = yield (this.rpcProvider || this.apiProvider).getLatestBlockNumber();
|
|
30
|
-
return latestHeight;
|
|
31
|
-
});
|
|
32
|
-
}
|
|
33
|
-
getBlockHash(blockNumber) {
|
|
34
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
35
|
-
let headerHash = yield (0, tools_1.runWithRetries)(() => (this.rpcProvider || this.apiProvider).getBlockHash(blockNumber));
|
|
36
|
-
return headerHash;
|
|
37
|
-
});
|
|
38
|
-
}
|
|
39
|
-
getBlockHeaderHex(blockNumber) {
|
|
40
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
41
|
-
let headerHex = yield (0, tools_1.runWithRetries)(() => (this.rpcProvider || this.apiProvider).getBlockHeaderHex(blockNumber));
|
|
42
|
-
return headerHex;
|
|
43
|
-
});
|
|
44
|
-
}
|
|
45
|
-
getTransaction(txId) {
|
|
46
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
47
|
-
return (this.rpcProvider || this.apiProvider).getTransaction(txId);
|
|
48
|
-
});
|
|
49
|
-
}
|
|
50
|
-
getRawTransaction(txId) {
|
|
51
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
52
|
-
return (this.rpcProvider || this.apiProvider).getRawTransaction(txId);
|
|
53
|
-
});
|
|
54
|
-
}
|
|
55
|
-
sendRawTransaction(txId) {
|
|
56
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
57
|
-
return (this.rpcProvider || this.apiProvider).sendRawTransaction(txId);
|
|
58
|
-
});
|
|
59
|
-
}
|
|
60
|
-
getMerkleProof(txId, blockHash) {
|
|
61
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
62
|
-
if (!this.rpcProvider) {
|
|
63
|
-
return this.apiProvider.getMerkleProof(txId);
|
|
64
|
-
}
|
|
65
|
-
let txIds = yield (0, tools_1.runWithRetries)(() => this.rpcProvider.getBlockTransactionIds(blockHash), {
|
|
66
|
-
maxTries: 10,
|
|
67
|
-
retrySleep: 2000,
|
|
68
|
-
});
|
|
69
|
-
let proof = (0, bitcoin_utils_1.calculateMerkleProof)(txIds, txId);
|
|
70
|
-
return proof;
|
|
71
|
-
});
|
|
72
|
-
}
|
|
73
|
-
getRequestProof(transaction) {
|
|
74
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
75
|
-
let transactionHex = transaction.hex || (yield this.getRawTransaction(transaction.txId));
|
|
76
|
-
let blockHash = transaction.blockHash;
|
|
77
|
-
let blockNumber = transaction.blockNumber;
|
|
78
|
-
if (!(transaction.blockHash && transaction.blockNumber)) {
|
|
79
|
-
let txInfo = yield this.getTransaction(transaction.txId);
|
|
80
|
-
blockHash = txInfo.blockHash;
|
|
81
|
-
blockNumber = txInfo.blockNumber;
|
|
82
|
-
}
|
|
83
|
-
let parsedTx = (0, bitcoin_utils_1.parseRawTransaction)(transactionHex);
|
|
84
|
-
let merkleProof = transaction.merkleProof || (yield this.getMerkleProof(transaction.txId, blockHash));
|
|
85
|
-
return {
|
|
86
|
-
parsedTx,
|
|
87
|
-
merkleProof,
|
|
88
|
-
blockNumber: blockNumber,
|
|
89
|
-
blockHash: blockHash,
|
|
90
|
-
};
|
|
91
|
-
});
|
|
92
|
-
}
|
|
93
|
-
getBlockTransactions(addresses, blockNumber, inputTxIds = []) {
|
|
94
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
95
|
-
if (!this.rpcProvider) {
|
|
96
|
-
throw new Error("RPC provider not set");
|
|
97
|
-
}
|
|
98
|
-
let rawBlockHex = yield (0, tools_1.runWithRetries)(() => this.rpcProvider.getBlockByBlockNumber(blockNumber, 0), {
|
|
99
|
-
maxTries: 10,
|
|
100
|
-
retrySleep: 2000,
|
|
101
|
-
});
|
|
102
|
-
return (0, bitcoin_utils_1.extractTransactionsAndBlockInfoFromRawBlock)(rawBlockHex, blockNumber, addresses, inputTxIds, this.network);
|
|
103
|
-
});
|
|
104
|
-
}
|
|
105
|
-
getMultipleBlocksTransactions(addresses, startBlockNumber, endBlockNumber, inputTxIds = []) {
|
|
106
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
107
|
-
let blockTxs = [];
|
|
108
|
-
for (let blockNumber = +startBlockNumber + 1; blockNumber <= endBlockNumber; blockNumber += 1) {
|
|
109
|
-
console.log(blockNumber);
|
|
110
|
-
const response = yield this.getBlockTransactions(addresses, blockNumber, inputTxIds);
|
|
111
|
-
blockTxs.push(response.withdrawTxs, response.depositTxs);
|
|
112
|
-
}
|
|
113
|
-
blockTxs = yield Promise.all(blockTxs);
|
|
114
|
-
return blockTxs.flat(1);
|
|
115
|
-
});
|
|
116
|
-
}
|
|
117
|
-
}
|
|
118
|
-
exports.BitcoinInterface = BitcoinInterface;
|
|
119
|
-
exports.default = BitcoinInterface;
|
|
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.BitcoinInterface = void 0;
|
|
16
|
+
const providers_1 = require("@teleportdao/providers");
|
|
17
|
+
const tools_1 = require("./utils/tools");
|
|
18
|
+
const bitcoin_utils_1 = require("./bitcoin-utils");
|
|
19
|
+
const bitcoin_interface_wallet_1 = __importDefault(require("./bitcoin-interface-wallet"));
|
|
20
|
+
class BitcoinInterface extends bitcoin_interface_wallet_1.default {
|
|
21
|
+
constructor(networkName, connectionInfo) {
|
|
22
|
+
super(networkName, connectionInfo);
|
|
23
|
+
if (connectionInfo === null || connectionInfo === void 0 ? void 0 : connectionInfo.rpc) {
|
|
24
|
+
this.rpcProvider = providers_1.bitcoin.getRpcProvider(connectionInfo.rpc);
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
getLatestBlockNumber() {
|
|
28
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
29
|
+
let latestHeight = yield (this.rpcProvider || this.apiProvider).getLatestBlockNumber();
|
|
30
|
+
return latestHeight;
|
|
31
|
+
});
|
|
32
|
+
}
|
|
33
|
+
getBlockHash(blockNumber) {
|
|
34
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
35
|
+
let headerHash = yield (0, tools_1.runWithRetries)(() => (this.rpcProvider || this.apiProvider).getBlockHash(blockNumber));
|
|
36
|
+
return headerHash;
|
|
37
|
+
});
|
|
38
|
+
}
|
|
39
|
+
getBlockHeaderHex(blockNumber) {
|
|
40
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
41
|
+
let headerHex = yield (0, tools_1.runWithRetries)(() => (this.rpcProvider || this.apiProvider).getBlockHeaderHex(blockNumber));
|
|
42
|
+
return headerHex;
|
|
43
|
+
});
|
|
44
|
+
}
|
|
45
|
+
getTransaction(txId) {
|
|
46
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
47
|
+
return (this.rpcProvider || this.apiProvider).getTransaction(txId);
|
|
48
|
+
});
|
|
49
|
+
}
|
|
50
|
+
getRawTransaction(txId) {
|
|
51
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
52
|
+
return (this.rpcProvider || this.apiProvider).getRawTransaction(txId);
|
|
53
|
+
});
|
|
54
|
+
}
|
|
55
|
+
sendRawTransaction(txId) {
|
|
56
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
57
|
+
return (this.rpcProvider || this.apiProvider).sendRawTransaction(txId);
|
|
58
|
+
});
|
|
59
|
+
}
|
|
60
|
+
getMerkleProof(txId, blockHash) {
|
|
61
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
62
|
+
if (!this.rpcProvider) {
|
|
63
|
+
return this.apiProvider.getMerkleProof(txId);
|
|
64
|
+
}
|
|
65
|
+
let txIds = yield (0, tools_1.runWithRetries)(() => this.rpcProvider.getBlockTransactionIds(blockHash), {
|
|
66
|
+
maxTries: 10,
|
|
67
|
+
retrySleep: 2000,
|
|
68
|
+
});
|
|
69
|
+
let proof = (0, bitcoin_utils_1.calculateMerkleProof)(txIds, txId);
|
|
70
|
+
return proof;
|
|
71
|
+
});
|
|
72
|
+
}
|
|
73
|
+
getRequestProof(transaction) {
|
|
74
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
75
|
+
let transactionHex = transaction.hex || (yield this.getRawTransaction(transaction.txId));
|
|
76
|
+
let blockHash = transaction.blockHash;
|
|
77
|
+
let blockNumber = transaction.blockNumber;
|
|
78
|
+
if (!(transaction.blockHash && transaction.blockNumber)) {
|
|
79
|
+
let txInfo = yield this.getTransaction(transaction.txId);
|
|
80
|
+
blockHash = txInfo.blockHash;
|
|
81
|
+
blockNumber = txInfo.blockNumber;
|
|
82
|
+
}
|
|
83
|
+
let parsedTx = (0, bitcoin_utils_1.parseRawTransaction)(transactionHex);
|
|
84
|
+
let merkleProof = transaction.merkleProof || (yield this.getMerkleProof(transaction.txId, blockHash));
|
|
85
|
+
return {
|
|
86
|
+
parsedTx,
|
|
87
|
+
merkleProof,
|
|
88
|
+
blockNumber: blockNumber,
|
|
89
|
+
blockHash: blockHash,
|
|
90
|
+
};
|
|
91
|
+
});
|
|
92
|
+
}
|
|
93
|
+
getBlockTransactions(addresses, blockNumber, inputTxIds = []) {
|
|
94
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
95
|
+
if (!this.rpcProvider) {
|
|
96
|
+
throw new Error("RPC provider not set");
|
|
97
|
+
}
|
|
98
|
+
let rawBlockHex = yield (0, tools_1.runWithRetries)(() => this.rpcProvider.getBlockByBlockNumber(blockNumber, 0), {
|
|
99
|
+
maxTries: 10,
|
|
100
|
+
retrySleep: 2000,
|
|
101
|
+
});
|
|
102
|
+
return (0, bitcoin_utils_1.extractTransactionsAndBlockInfoFromRawBlock)(rawBlockHex, blockNumber, addresses, inputTxIds, this.network);
|
|
103
|
+
});
|
|
104
|
+
}
|
|
105
|
+
getMultipleBlocksTransactions(addresses, startBlockNumber, endBlockNumber, inputTxIds = []) {
|
|
106
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
107
|
+
let blockTxs = [];
|
|
108
|
+
for (let blockNumber = +startBlockNumber + 1; blockNumber <= endBlockNumber; blockNumber += 1) {
|
|
109
|
+
console.log(blockNumber);
|
|
110
|
+
const response = yield this.getBlockTransactions(addresses, blockNumber, inputTxIds);
|
|
111
|
+
blockTxs.push(response.withdrawTxs, response.depositTxs);
|
|
112
|
+
}
|
|
113
|
+
blockTxs = yield Promise.all(blockTxs);
|
|
114
|
+
return blockTxs.flat(1);
|
|
115
|
+
});
|
|
116
|
+
}
|
|
117
|
+
}
|
|
118
|
+
exports.BitcoinInterface = BitcoinInterface;
|
|
119
|
+
exports.default = BitcoinInterface;
|
|
120
120
|
//# sourceMappingURL=bitcoin-interface.js.map
|
package/dist/bitcoin-utils.d.ts
CHANGED
|
@@ -1,97 +1,97 @@
|
|
|
1
|
-
/// <reference types="node" />
|
|
2
|
-
import * as bitcoin from "bitcoinjs-lib";
|
|
3
|
-
import networks from "./utils/networks";
|
|
4
|
-
import { Transaction } from "./type";
|
|
5
|
-
export { networks };
|
|
6
|
-
export declare function generateMnemonic(): string;
|
|
7
|
-
export declare function getPrivateKeyHexFromMnemonic(mnemonic: string, index?: number, isChange?: boolean): Promise<string>;
|
|
8
|
-
export declare function reverseBytes(hexInput: string): string;
|
|
9
|
-
export declare function getPublicKeyHexByXpubAndIndex(xpub: string, index?: number, isChange?: boolean, network?: bitcoin.networks.Network): string;
|
|
10
|
-
export declare function getPubKeyFromPrivateKeyWIF(privateKeyWIF: string, network?: bitcoin.networks.Network): Buffer;
|
|
11
|
-
export declare function getPubKeyFromPrivateKeyHex(privateKeyHex: string, network?: bitcoin.networks.Network): Buffer;
|
|
12
|
-
export declare function getPrivateKeyHexFromWIF(privateKeyWIF: string, network?: bitcoin.networks.Network): string;
|
|
13
|
-
export declare function parseRawTransaction(rawTransaction: string): {
|
|
14
|
-
version: string;
|
|
15
|
-
flag: string;
|
|
16
|
-
vin: string;
|
|
17
|
-
vout: string;
|
|
18
|
-
witness: string;
|
|
19
|
-
locktime: string;
|
|
20
|
-
};
|
|
21
|
-
export declare function calculateMerkleProof(blockTransactions: string[], txId: string, blockMerkleRoot?: string): {
|
|
22
|
-
intermediateNodes: string;
|
|
23
|
-
transactionIndex: number;
|
|
24
|
-
};
|
|
25
|
-
export declare function parseBlockHeader(headerHex: string): {
|
|
26
|
-
version: string;
|
|
27
|
-
previousBlockHash: string;
|
|
28
|
-
merkleRoot: string;
|
|
29
|
-
timestamp: string;
|
|
30
|
-
difficulty: string;
|
|
31
|
-
nonce: string;
|
|
32
|
-
};
|
|
33
|
-
export declare function getAddressType(address: string, network?: bitcoin.networks.Network): "p2tr" | "p2wpkh" | "p2sh" | "p2pkh";
|
|
34
|
-
export declare function createAddressObjectByAddress(address: string, network?: bitcoin.networks.Network): {
|
|
35
|
-
addressObject: bitcoin.payments.Payment;
|
|
36
|
-
addressType: "p2tr" | "p2wpkh" | "p2sh" | "p2pkh";
|
|
37
|
-
};
|
|
38
|
-
export declare function convertBitcoinScriptToAddress(script: Buffer, network?: bitcoin.networks.Network): string | undefined;
|
|
39
|
-
export declare function parseRawBlock(rawBlockHex: string, blockNumber?: number, network?: bitcoin.networks.Network): {
|
|
40
|
-
blockNumber: number | undefined;
|
|
41
|
-
merkleRoot: string;
|
|
42
|
-
prvBlockHash: string;
|
|
43
|
-
transactions: {
|
|
44
|
-
txId: string;
|
|
45
|
-
version: number;
|
|
46
|
-
locktime: number;
|
|
47
|
-
blockNumber: number | undefined;
|
|
48
|
-
blockHash: string;
|
|
49
|
-
vout: {
|
|
50
|
-
address: string | undefined;
|
|
51
|
-
script: string;
|
|
52
|
-
value: number;
|
|
53
|
-
index: number;
|
|
54
|
-
}[];
|
|
55
|
-
vin: {
|
|
56
|
-
txId: string;
|
|
57
|
-
index: number;
|
|
58
|
-
}[];
|
|
59
|
-
}[] | undefined;
|
|
60
|
-
};
|
|
61
|
-
export declare function extractTransactionsAndBlockInfoFromRawBlock(rawBlockHex: string, blockNumber: number, addresses?: string[], inputTxIds?: {
|
|
62
|
-
txId: string;
|
|
63
|
-
index: number;
|
|
64
|
-
address: string;
|
|
65
|
-
script?: string;
|
|
66
|
-
value?: number;
|
|
67
|
-
}[], network?: bitcoin.networks.Network): {
|
|
68
|
-
blockInfo: {
|
|
69
|
-
blockNumber: number;
|
|
70
|
-
blockHash: string;
|
|
71
|
-
merkleRoot: string;
|
|
72
|
-
prvBlockHash: string;
|
|
73
|
-
};
|
|
74
|
-
withdrawTxs: Transaction[];
|
|
75
|
-
depositTxs: Transaction[];
|
|
76
|
-
};
|
|
77
|
-
export declare function validateAddress(address: string, network?: bitcoin.networks.Network): boolean;
|
|
78
|
-
export declare function createAddressObjectByScript({ addressType, script }: {
|
|
79
|
-
addressType: string;
|
|
80
|
-
script: Buffer;
|
|
81
|
-
}, network?: bitcoin.Network): bitcoin.payments.Payment;
|
|
82
|
-
export declare function createAddressObjectByHash({ addressType, hash }: {
|
|
83
|
-
addressType: string;
|
|
84
|
-
hash: Buffer;
|
|
85
|
-
}, network?: bitcoin.Network): bitcoin.payments.Payment;
|
|
86
|
-
export declare function createAddressObjectByPublicKey({ addressType, publicKey }: {
|
|
87
|
-
addressType: string;
|
|
88
|
-
publicKey: Buffer;
|
|
89
|
-
}, network?: bitcoin.Network): bitcoin.payments.Payment;
|
|
90
|
-
export declare function publicKeyConvertor(publicKeyHex: string, compressed?: boolean): string;
|
|
91
|
-
export declare const addressTypeHelper: {
|
|
92
|
-
addressTypesNumber: {
|
|
93
|
-
[key: string]: number;
|
|
94
|
-
};
|
|
95
|
-
addressTypes: string[];
|
|
96
|
-
};
|
|
1
|
+
/// <reference types="node" />
|
|
2
|
+
import * as bitcoin from "bitcoinjs-lib";
|
|
3
|
+
import networks from "./utils/networks";
|
|
4
|
+
import { Transaction } from "./type";
|
|
5
|
+
export { networks };
|
|
6
|
+
export declare function generateMnemonic(): string;
|
|
7
|
+
export declare function getPrivateKeyHexFromMnemonic(mnemonic: string, index?: number, isChange?: boolean): Promise<string>;
|
|
8
|
+
export declare function reverseBytes(hexInput: string): string;
|
|
9
|
+
export declare function getPublicKeyHexByXpubAndIndex(xpub: string, index?: number, isChange?: boolean, network?: bitcoin.networks.Network): string;
|
|
10
|
+
export declare function getPubKeyFromPrivateKeyWIF(privateKeyWIF: string, network?: bitcoin.networks.Network): Buffer;
|
|
11
|
+
export declare function getPubKeyFromPrivateKeyHex(privateKeyHex: string, network?: bitcoin.networks.Network): Buffer;
|
|
12
|
+
export declare function getPrivateKeyHexFromWIF(privateKeyWIF: string, network?: bitcoin.networks.Network): string;
|
|
13
|
+
export declare function parseRawTransaction(rawTransaction: string): {
|
|
14
|
+
version: string;
|
|
15
|
+
flag: string;
|
|
16
|
+
vin: string;
|
|
17
|
+
vout: string;
|
|
18
|
+
witness: string;
|
|
19
|
+
locktime: string;
|
|
20
|
+
};
|
|
21
|
+
export declare function calculateMerkleProof(blockTransactions: string[], txId: string, blockMerkleRoot?: string): {
|
|
22
|
+
intermediateNodes: string;
|
|
23
|
+
transactionIndex: number;
|
|
24
|
+
};
|
|
25
|
+
export declare function parseBlockHeader(headerHex: string): {
|
|
26
|
+
version: string;
|
|
27
|
+
previousBlockHash: string;
|
|
28
|
+
merkleRoot: string;
|
|
29
|
+
timestamp: string;
|
|
30
|
+
difficulty: string;
|
|
31
|
+
nonce: string;
|
|
32
|
+
};
|
|
33
|
+
export declare function getAddressType(address: string, network?: bitcoin.networks.Network): "p2tr" | "p2wpkh" | "p2sh" | "p2pkh";
|
|
34
|
+
export declare function createAddressObjectByAddress(address: string, network?: bitcoin.networks.Network): {
|
|
35
|
+
addressObject: bitcoin.payments.Payment;
|
|
36
|
+
addressType: "p2tr" | "p2wpkh" | "p2sh" | "p2pkh";
|
|
37
|
+
};
|
|
38
|
+
export declare function convertBitcoinScriptToAddress(script: Buffer, network?: bitcoin.networks.Network): string | undefined;
|
|
39
|
+
export declare function parseRawBlock(rawBlockHex: string, blockNumber?: number, network?: bitcoin.networks.Network): {
|
|
40
|
+
blockNumber: number | undefined;
|
|
41
|
+
merkleRoot: string;
|
|
42
|
+
prvBlockHash: string;
|
|
43
|
+
transactions: {
|
|
44
|
+
txId: string;
|
|
45
|
+
version: number;
|
|
46
|
+
locktime: number;
|
|
47
|
+
blockNumber: number | undefined;
|
|
48
|
+
blockHash: string;
|
|
49
|
+
vout: {
|
|
50
|
+
address: string | undefined;
|
|
51
|
+
script: string;
|
|
52
|
+
value: number;
|
|
53
|
+
index: number;
|
|
54
|
+
}[];
|
|
55
|
+
vin: {
|
|
56
|
+
txId: string;
|
|
57
|
+
index: number;
|
|
58
|
+
}[];
|
|
59
|
+
}[] | undefined;
|
|
60
|
+
};
|
|
61
|
+
export declare function extractTransactionsAndBlockInfoFromRawBlock(rawBlockHex: string, blockNumber: number, addresses?: string[], inputTxIds?: {
|
|
62
|
+
txId: string;
|
|
63
|
+
index: number;
|
|
64
|
+
address: string;
|
|
65
|
+
script?: string;
|
|
66
|
+
value?: number;
|
|
67
|
+
}[], network?: bitcoin.networks.Network): {
|
|
68
|
+
blockInfo: {
|
|
69
|
+
blockNumber: number;
|
|
70
|
+
blockHash: string;
|
|
71
|
+
merkleRoot: string;
|
|
72
|
+
prvBlockHash: string;
|
|
73
|
+
};
|
|
74
|
+
withdrawTxs: Transaction[];
|
|
75
|
+
depositTxs: Transaction[];
|
|
76
|
+
};
|
|
77
|
+
export declare function validateAddress(address: string, network?: bitcoin.networks.Network): boolean;
|
|
78
|
+
export declare function createAddressObjectByScript({ addressType, script }: {
|
|
79
|
+
addressType: string;
|
|
80
|
+
script: Buffer;
|
|
81
|
+
}, network?: bitcoin.Network): bitcoin.payments.Payment;
|
|
82
|
+
export declare function createAddressObjectByHash({ addressType, hash }: {
|
|
83
|
+
addressType: string;
|
|
84
|
+
hash: Buffer;
|
|
85
|
+
}, network?: bitcoin.Network): bitcoin.payments.Payment;
|
|
86
|
+
export declare function createAddressObjectByPublicKey({ addressType, publicKey }: {
|
|
87
|
+
addressType: string;
|
|
88
|
+
publicKey: Buffer;
|
|
89
|
+
}, network?: bitcoin.Network): bitcoin.payments.Payment;
|
|
90
|
+
export declare function publicKeyConvertor(publicKeyHex: string, compressed?: boolean): string;
|
|
91
|
+
export declare const addressTypeHelper: {
|
|
92
|
+
addressTypesNumber: {
|
|
93
|
+
[key: string]: number;
|
|
94
|
+
};
|
|
95
|
+
addressTypes: string[];
|
|
96
|
+
};
|
|
97
97
|
//# sourceMappingURL=bitcoin-utils.d.ts.map
|