@teleportdao/bitcoin 2.2.5 → 2.2.7-beta.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,122 @@
1
+ /// <reference types="node" />
2
+ import { Network, Payment } from "bitcoinjs-lib";
3
+ import { BitcoinTransactionBuilder } from "./transaction-builder";
4
+ import type { RPCConnectionInfo, UtxoConnectionInfo } from "./type";
5
+ import type { ExtendedUtxo, SignerInfo, Target, TargetAddress } from "./transaction-builder/transaction-builder";
6
+ import BitcoinSigner from "./sign/sign-transaction";
7
+ import { BitcoinInterfaceWallet } from "./bitcoin-interface-wallet";
8
+ export type FeeRateType = "normal" | "slow" | "fast" | number;
9
+ export declare class BitcoinBaseWallet {
10
+ SINGLESIG_TYPES: string[];
11
+ MULTISIG_TYPES: string[];
12
+ network: Network;
13
+ hdWalletPath: {
14
+ p2pkh: string;
15
+ p2wpkh: string;
16
+ "p2sh-p2wpkh": string;
17
+ p2sh: string;
18
+ p2wsh: string;
19
+ "p2sh-p2wsh": string;
20
+ p2tr: string;
21
+ };
22
+ transactionBuilder: BitcoinTransactionBuilder;
23
+ btcInterface: BitcoinInterfaceWallet;
24
+ signer: BitcoinSigner;
25
+ currentAccount?: string;
26
+ currentAccountType?: string;
27
+ addressObj?: Payment;
28
+ privateKey?: Buffer;
29
+ publicKey?: Buffer;
30
+ multisig?: {
31
+ publicKeys: Buffer[];
32
+ numberOfSigners: number;
33
+ };
34
+ constructor(networkName: string, connectionInfo?: {
35
+ utxo?: UtxoConnectionInfo;
36
+ rpc?: RPCConnectionInfo;
37
+ });
38
+ static satoshiToBTC(satoshi: number | string): string;
39
+ static btcToSatoshi(btc: number | string): string;
40
+ get bitcoinAddress(): string | undefined;
41
+ get signerInfo(): {
42
+ address: string;
43
+ addressType: string;
44
+ publicKey: string;
45
+ publicKeys: string[] | undefined;
46
+ numberOfSigners: number | undefined;
47
+ } | undefined;
48
+ setAccountPrivateKey(privateKeyHex: string, accountType?: string): void;
49
+ setAccountType(accountType?: string, multisig?: {
50
+ publicKeys: string[];
51
+ numberOfSigners?: number;
52
+ }): string;
53
+ setAccountPrivateKeyByMnemonic({ mnemonic, mnemonicPassword, index, walletNumber, addressType, }: {
54
+ mnemonic: string;
55
+ mnemonicPassword?: string;
56
+ index?: number;
57
+ walletNumber?: number;
58
+ addressType?: string;
59
+ }): string;
60
+ checkBalanceIsSufficient({ targets, extendedUtxo, changeAddress, feeRate, }: {
61
+ targets: Target[];
62
+ extendedUtxo: ExtendedUtxo[];
63
+ changeAddress: string;
64
+ feeRate: number;
65
+ }): boolean;
66
+ getExtendedUtxo(input: SignerInfo): Promise<{
67
+ hash: string;
68
+ value: number;
69
+ index: number;
70
+ signerInfo: SignerInfo;
71
+ }[]>;
72
+ getFeeRate(feeRate?: FeeRateType): Promise<number>;
73
+ sendBTC(receiverAddress: string, amountInSatoshi: number | "all", fee?: FeeRateType, staticExtendedUtxo?: ExtendedUtxo[]): Promise<any>;
74
+ sendBTCMultipleAddress(receivers: TargetAddress[], fee?: FeeRateType, staticExtendedUtxo?: ExtendedUtxo[]): Promise<any>;
75
+ sendBTCToMultipleAddressUnsignedTx(receivers: TargetAddress[], signerInfo: SignerInfo, fee?: FeeRateType, staticExtendedUtxo?: ExtendedUtxo[], fullAmount?: boolean): Promise<{
76
+ unsignedTransaction: string;
77
+ outputs: Target[];
78
+ inputs: {
79
+ hash: string;
80
+ value: number;
81
+ index: number;
82
+ signerInfo: SignerInfo;
83
+ }[];
84
+ fee: number;
85
+ change: import("./transaction-builder").ChangeTarget | undefined;
86
+ possibleTxId: string | undefined;
87
+ }>;
88
+ sendBTCUnsignedTx(receiver: string, amountInSatoshi: number | "all", signerInfo: SignerInfo, fee?: FeeRateType, staticExtendedUtxo?: ExtendedUtxo[]): Promise<{
89
+ unsignedTransaction: string;
90
+ outputs: Target[];
91
+ inputs: {
92
+ hash: string;
93
+ value: number;
94
+ index: number;
95
+ signerInfo: SignerInfo;
96
+ }[];
97
+ fee: number;
98
+ change: import("./transaction-builder").ChangeTarget | undefined;
99
+ possibleTxId: string | undefined;
100
+ }>;
101
+ sendSignedTx(signedTx: string): Promise<any>;
102
+ sendSignedPsbt(signedPsbt: string): Promise<any>;
103
+ sendSignedPsbtWithRetry(signedPsbt: string, { maxTries, retrySleep }?: {
104
+ maxTries?: number | undefined;
105
+ retrySleep?: number | undefined;
106
+ }): Promise<any>;
107
+ sendMultiSignedPsbt(signedPsbts?: string[]): Promise<any>;
108
+ increaseTransactionFeeUnsignedPsbt(txId: string, signerInfos: SignerInfo[], extraExtendedUtxo: ExtendedUtxo[], changeAddress: string, staticFeeRate?: number): Promise<{
109
+ unsignedTransaction: string;
110
+ outputs: Target[];
111
+ inputs: {
112
+ hash: string;
113
+ value: number;
114
+ index: number;
115
+ signerInfo: SignerInfo;
116
+ }[];
117
+ fee: number;
118
+ change: import("./transaction-builder").ChangeTarget | undefined;
119
+ possibleTxId: string | undefined;
120
+ }>;
121
+ }
122
+ //# sourceMappingURL=bitcoin-wallet-base%20copy.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"bitcoin-wallet-base copy.d.ts","sourceRoot":"","sources":["../src/bitcoin-wallet-base copy.ts"],"names":[],"mappings":";AAEA,OAAO,EAAE,OAAO,EAAE,OAAO,EAAE,MAAM,eAAe,CAAA;AAIhD,OAAO,EAAE,yBAAyB,EAAE,MAAM,uBAAuB,CAAA;AACjE,OAAO,KAAK,EAAE,iBAAiB,EAAE,kBAAkB,EAAE,MAAM,QAAQ,CAAA;AAEnE,OAAO,KAAK,EACV,YAAY,EACZ,UAAU,EACV,MAAM,EACN,aAAa,EACd,MAAM,2CAA2C,CAAA;AAClD,OAAO,aAAa,MAAM,yBAAyB,CAAA;AAInD,OAAO,EAAE,sBAAsB,EAAE,MAAM,4BAA4B,CAAA;AAKnE,MAAM,MAAM,WAAW,GAAG,QAAQ,GAAG,MAAM,GAAG,MAAM,GAAG,MAAM,CAAA;AAC7D,qBAA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AAM;IAMjC,uBAAuB,CAAC,UAAU,EAAE,MAAM,EAAE,EAAE,QAAY,EAAE,UAAiB,EAAE;;;KAAK;IAOpF,mBAAmB,CAAC,WAAW,GAAE,MAAM,EAAO;IAO9C,kCAAkC,CACtC,IAAI,EAAE,MAAM,EACZ,WAAW,EAAE,UAAU,EAAE,EACzB,iBAAiB,EAAE,YAAY,EAAE,EACjC,aAAa,EAAE,MAAM,EACrB,aAAa,CAAC,EAAE,MAAM;;;;;;;;;;;;;CA0CzB"}
@@ -0,0 +1,279 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
15
+ }) : function(o, v) {
16
+ o["default"] = v;
17
+ });
18
+ var __importStar = (this && this.__importStar) || function (mod) {
19
+ if (mod && mod.__esModule) return mod;
20
+ var result = {};
21
+ if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
22
+ __setModuleDefault(result, mod);
23
+ return result;
24
+ };
25
+ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
26
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
27
+ return new (P || (P = Promise))(function (resolve, reject) {
28
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
29
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
30
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
31
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
32
+ });
33
+ };
34
+ var __importDefault = (this && this.__importDefault) || function (mod) {
35
+ return (mod && mod.__esModule) ? mod : { "default": mod };
36
+ };
37
+ Object.defineProperty(exports, "__esModule", { value: true });
38
+ exports.BitcoinBaseWallet = void 0;
39
+ const bip39 = __importStar(require("bip39"));
40
+ const configs_1 = require("@teleportdao/configs");
41
+ const bip32_1 = __importDefault(require("bip32"));
42
+ const secp256k1_1 = __importDefault(require("@bitcoinerlab/secp256k1"));
43
+ const bignumber_js_1 = __importDefault(require("bignumber.js"));
44
+ const transaction_builder_1 = require("./transaction-builder");
45
+ const sign_transaction_1 = __importDefault(require("./sign/sign-transaction"));
46
+ const bitcoin_utils_1 = require("./bitcoin-utils");
47
+ const networks_1 = __importDefault(require("./utils/networks"));
48
+ const tools_1 = require("./utils/tools");
49
+ const bip32 = (0, bip32_1.default)(secp256k1_1.default);
50
+ class BitcoinBaseWallet {
51
+ constructor(networkName, connectionInfo) {
52
+ this.SINGLESIG_TYPES = ["p2pkh", "p2wpkh", "p2sh-p2wpkh", "p2tr"];
53
+ this.MULTISIG_TYPES = ["p2sh", "p2wsh", "p2sh-p2wsh"];
54
+ this.network = networks_1.default[networkName];
55
+ this.hdWalletPath = configs_1.hdWalletPath.bitcoin;
56
+ this.transactionBuilder = new transaction_builder_1.BitcoinTransactionBuilder(networkName, this.network, connectionInfo);
57
+ this.btcInterface = this.transactionBuilder.btcInterface;
58
+ this.signer = new sign_transaction_1.default(this.network);
59
+ this.currentAccount = undefined;
60
+ this.currentAccountType = undefined;
61
+ this.privateKey = undefined;
62
+ this.publicKey = undefined;
63
+ }
64
+ static satoshiToBTC(satoshi) {
65
+ return new bignumber_js_1.default(satoshi).dividedBy(1e8).toString();
66
+ }
67
+ static btcToSatoshi(btc) {
68
+ return new bignumber_js_1.default(btc).multipliedBy(1e8).toFixed(0);
69
+ }
70
+ get bitcoinAddress() {
71
+ return this.currentAccount;
72
+ }
73
+ get signerInfo() {
74
+ var _a, _b;
75
+ return this.privateKey
76
+ ? {
77
+ address: this.bitcoinAddress,
78
+ addressType: this.currentAccountType,
79
+ publicKey: this.publicKey.toString("hex"),
80
+ publicKeys: (_a = this.multisig) === null || _a === void 0 ? void 0 : _a.publicKeys.map((p) => p.toString("hex")),
81
+ numberOfSigners: (_b = this.multisig) === null || _b === void 0 ? void 0 : _b.numberOfSigners,
82
+ }
83
+ : undefined;
84
+ }
85
+ setAccountPrivateKey(privateKeyHex, accountType = "p2wpkh") {
86
+ this.privateKey = Buffer.from(privateKeyHex, "hex");
87
+ let publicKey = (0, bitcoin_utils_1.getPubKeyFromPrivateKeyHex)(privateKeyHex, this.network);
88
+ this.publicKey = publicKey;
89
+ this.setAccountType(accountType);
90
+ }
91
+ setAccountType(accountType = "p2wpkh", multisig) {
92
+ if (!this.publicKey) {
93
+ throw new Error("account not initialized");
94
+ }
95
+ let addressObj;
96
+ if (this.SINGLESIG_TYPES.includes(accountType)) {
97
+ addressObj = this.btcInterface.createAddressObjectByPublicKey(this.publicKey.toString("hex"), accountType);
98
+ }
99
+ else {
100
+ if (!multisig) {
101
+ throw new Error("multisig is required");
102
+ }
103
+ const m = {
104
+ publicKeys: multisig.publicKeys.map((p) => Buffer.from(p, "hex")),
105
+ numberOfSigners: multisig.numberOfSigners || multisig.publicKeys.length,
106
+ };
107
+ addressObj = this.btcInterface.createMultisigAddressObjectByPublicKeys(m, accountType);
108
+ this.multisig = m;
109
+ }
110
+ this.currentAccount = addressObj.address;
111
+ this.currentAccountType = accountType;
112
+ this.addressObj = addressObj;
113
+ if (!addressObj.address)
114
+ throw new Error("address not exist");
115
+ return addressObj.address;
116
+ }
117
+ setAccountPrivateKeyByMnemonic({ mnemonic, mnemonicPassword = "", index = 0, walletNumber = 0, addressType = "p2sh-p2wpkh", }) {
118
+ if (!bip39.validateMnemonic(mnemonic))
119
+ throw new Error("invalid mnemonic");
120
+ const seed = bip39.mnemonicToSeedSync(mnemonic, mnemonicPassword);
121
+ const node = bip32.fromSeed(seed);
122
+ let basePath = this.hdWalletPath[addressType];
123
+ if (!basePath) {
124
+ throw new Error("incorrect path or addressType");
125
+ }
126
+ const path = `${basePath}/${walletNumber}`;
127
+ const account = node.derivePath(path);
128
+ const userKeyPair = account.derive(index);
129
+ this.setAccountPrivateKey(userKeyPair.privateKey.toString("hex"));
130
+ return this.setAccountType(addressType);
131
+ }
132
+ checkBalanceIsSufficient({ targets, extendedUtxo, changeAddress, feeRate, }) {
133
+ try {
134
+ this.transactionBuilder.helperHandleInputsAndOutputs({
135
+ targets,
136
+ extendedUtxo,
137
+ changeObject: {
138
+ address: changeAddress,
139
+ },
140
+ feeRate,
141
+ });
142
+ return true;
143
+ }
144
+ catch (err) {
145
+ return false;
146
+ }
147
+ }
148
+ getExtendedUtxo(input) {
149
+ return __awaiter(this, void 0, void 0, function* () {
150
+ return this.btcInterface.getExtendedUtxo(input);
151
+ });
152
+ }
153
+ getFeeRate(feeRate = "normal") {
154
+ return __awaiter(this, void 0, void 0, function* () {
155
+ if (feeRate === 0)
156
+ throw new Error("feeRate should be greater than 0");
157
+ if (+feeRate > 0)
158
+ return +feeRate;
159
+ if (typeof feeRate === "string")
160
+ return this.btcInterface.getFeeRate(feeRate);
161
+ throw new Error("incorrect feeRate");
162
+ });
163
+ }
164
+ sendBTC(receiverAddress, amountInSatoshi, fee = "normal", staticExtendedUtxo) {
165
+ return __awaiter(this, void 0, void 0, function* () {
166
+ if (!this.signerInfo || !this.privateKey) {
167
+ throw new Error("account not initialized");
168
+ }
169
+ const unsignedTx = yield this.sendBTCUnsignedTx(receiverAddress, amountInSatoshi, this.signerInfo, fee, staticExtendedUtxo);
170
+ let signedPsbt = yield this.signer.signPsbt(unsignedTx, this.privateKey);
171
+ let signedTx = this.signer.finalizePsbts([signedPsbt]);
172
+ let txId = yield this.sendSignedTx(signedTx);
173
+ return txId;
174
+ });
175
+ }
176
+ sendBTCMultipleAddress(receivers, fee = "normal", staticExtendedUtxo) {
177
+ return __awaiter(this, void 0, void 0, function* () {
178
+ if (!this.signerInfo || !this.privateKey) {
179
+ throw new Error("account not initialized");
180
+ }
181
+ const unsignedTx = yield this.sendBTCToMultipleAddressUnsignedTx(receivers, this.signerInfo, fee, staticExtendedUtxo);
182
+ let signedPsbt = yield this.signer.signPsbt(unsignedTx, this.privateKey);
183
+ let signedTx = this.signer.finalizePsbts([signedPsbt]);
184
+ let txId = yield this.sendSignedTx(signedTx);
185
+ return txId;
186
+ });
187
+ }
188
+ sendBTCToMultipleAddressUnsignedTx(receivers, signerInfo, fee = "normal", staticExtendedUtxo, fullAmount = false) {
189
+ return __awaiter(this, void 0, void 0, function* () {
190
+ if (!fullAmount) {
191
+ receivers.forEach((r) => {
192
+ if ((0, bignumber_js_1.default)(r.value).isEqualTo(0))
193
+ throw new Error("incorrect amount");
194
+ });
195
+ }
196
+ else if (receivers.length > 1)
197
+ throw new Error("fullAmount only support one receiver");
198
+ let feeRate = yield this.getFeeRate(fee);
199
+ let extendedUtxo = staticExtendedUtxo || (yield this.getExtendedUtxo(signerInfo));
200
+ let unsignedTx = yield this.transactionBuilder.processUnsignedTransaction({
201
+ extendedUtxo,
202
+ targets: receivers,
203
+ changeAddress: signerInfo.address,
204
+ feeRate,
205
+ fullAmount,
206
+ });
207
+ return unsignedTx;
208
+ });
209
+ }
210
+ sendBTCUnsignedTx(receiver, amountInSatoshi, signerInfo, fee = "normal", staticExtendedUtxo) {
211
+ return __awaiter(this, void 0, void 0, function* () {
212
+ return this.sendBTCToMultipleAddressUnsignedTx([{ address: receiver, value: amountInSatoshi === "all" ? 0 : amountInSatoshi }], signerInfo, fee, staticExtendedUtxo, amountInSatoshi === "all");
213
+ });
214
+ }
215
+ sendSignedTx(signedTx) {
216
+ return __awaiter(this, void 0, void 0, function* () {
217
+ let txId = yield this.btcInterface.sendRawTransaction(signedTx);
218
+ return txId;
219
+ });
220
+ }
221
+ sendSignedPsbt(signedPsbt) {
222
+ return __awaiter(this, void 0, void 0, function* () {
223
+ let signedTx = this.signer.finalizePsbts([signedPsbt]);
224
+ let txId = yield this.sendSignedTx(signedTx);
225
+ return txId;
226
+ });
227
+ }
228
+ sendSignedPsbtWithRetry(signedPsbt, { maxTries = 5, retrySleep = 5000 } = {}) {
229
+ return __awaiter(this, void 0, void 0, function* () {
230
+ return (0, tools_1.runWithRetries)(() => this.sendSignedPsbt(signedPsbt), {
231
+ retrySleep,
232
+ maxTries,
233
+ });
234
+ });
235
+ }
236
+ sendMultiSignedPsbt(signedPsbts = []) {
237
+ return __awaiter(this, void 0, void 0, function* () {
238
+ let signedTx = this.signer.finalizePsbts(signedPsbts);
239
+ let txId = yield this.btcInterface.sendRawTransaction(signedTx);
240
+ return txId;
241
+ });
242
+ }
243
+ increaseTransactionFeeUnsignedPsbt(txId, signerInfos, extraExtendedUtxo, changeAddress, staticFeeRate) {
244
+ return __awaiter(this, void 0, void 0, function* () {
245
+ let transaction = yield this.btcInterface.apiProvider.getTransaction(txId);
246
+ let extendedUtxo = transaction.vin.map((vi) => ({
247
+ signerInfo: signerInfos.find((s) => s.address === vi.address),
248
+ hash: vi.txId,
249
+ value: +vi.value,
250
+ index: vi.index,
251
+ }));
252
+ if (extendedUtxo.find((x) => { var _a; return !((_a = x.signerInfo) === null || _a === void 0 ? void 0 : _a.address); })) {
253
+ throw new Error("signerInfo not match");
254
+ }
255
+ let changeIndex = transaction.vout.findIndex((vo) => transaction.vin.find((vi) => vo.address === vi.address || vo.address === changeAddress));
256
+ const feeRate = staticFeeRate || (yield this.btcInterface.getFeeRate("fast"));
257
+ let targets = transaction.vout
258
+ .filter((_, index) => index !== changeIndex)
259
+ .map((vo) => vo.address
260
+ ? {
261
+ address: vo.address,
262
+ value: vo.value,
263
+ }
264
+ : {
265
+ script: Buffer.from(vo.script, "hex"),
266
+ value: vo.value,
267
+ });
268
+ return this.transactionBuilder.processUnsignedTransaction({
269
+ extendedUtxo: [...extendedUtxo, ...extraExtendedUtxo],
270
+ targets,
271
+ feeRate,
272
+ changeAddress: changeIndex >= 0 ? transaction.vout[changeIndex].address : changeAddress,
273
+ selectType: "inOrder",
274
+ });
275
+ });
276
+ }
277
+ }
278
+ exports.BitcoinBaseWallet = BitcoinBaseWallet;
279
+ //# sourceMappingURL=bitcoin-wallet-base%20copy.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"bitcoin-wallet-base copy.js","sourceRoot":"","sources":["../src/bitcoin-wallet-base copy.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,6CAA8B;AAC9B,kDAAmD;AAEnD,kDAAgC;AAChC,wEAAyC;AACzC,gEAAoC;AACpC,+DAAiE;AASjE,+EAAmD;AAEnD,mDAA4D;AAC5D,gEAAuC;AAEvC,yCAA8C;AAE9C,MAAM,KAAK,GAAG,IAAA,eAAY,EAAC,mBAAG,CAAC,CAAA;AAG/B,MAAa,iBAAiB;IAkC5B,YACE,WAAmB,EACnB,cAIC;QAvCH,oBAAe,GAAG,CAAC,OAAO,EAAE,QAAQ,EAAE,aAAa,EAAE,MAAM,CAAC,CAAA;QAC5D,mBAAc,GAAG,CAAC,MAAM,EAAE,OAAO,EAAE,YAAY,CAAC,CAAA;QAwC9C,IAAI,CAAC,OAAO,GAAG,kBAAQ,CAAC,WAAW,CAAC,CAAA;QACpC,IAAI,CAAC,YAAY,GAAG,sBAAY,CAAC,OAAO,CAAA;QAExC,IAAI,CAAC,kBAAkB,GAAG,IAAI,+CAAyB,CACrD,WAAW,EACX,IAAI,CAAC,OAAO,EACZ,cAAc,CACf,CAAA;QACD,IAAI,CAAC,YAAY,GAAG,IAAI,CAAC,kBAAkB,CAAC,YAAY,CAAA;QAExD,IAAI,CAAC,MAAM,GAAG,IAAI,0BAAa,CAAC,IAAI,CAAC,OAAO,CAAC,CAAA;QAG7C,IAAI,CAAC,cAAc,GAAG,SAAS,CAAA;QAC/B,IAAI,CAAC,kBAAkB,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AI,OAAO,GAAG,WAAW,CAAC,IAAI;iBAC3B,MAAM,CAAC,CAAC,CAAC,EAAE,KAAK,EAAE,EAAE,CAAC,KAAK,KAAK,WAAW,CAAC;iBAC3C,GAAG,CAAC,CAAC,EAAE,EAAE,EAAE,CACV,EAAE,CAAC,OAAO;gBACR,CAAC,CAAC;oBACE,OAAO,EAAE,EAAE,CAAC,OAAO;oBACnB,KAAK,EAAE,EAAE,CAAC,KAAK;iBAChB;gBACH,CAAC,CAAC;oBACE,MAAM,EAAE,MAAM,CAAC,IAAI,CAAC,EAAE,CAAC,MAAM,EAAE,KAAK,CAAC;oBACrC,KAAK,EAAE,EAAE,CAAC,KAAK;iBAChB,CACN,CAAA;YACH,OAAO,IAAI,CAAC,kBAAkB,CAAC,0BAA0B,CAAC;gBACxD,YAAY,EAAE,CAAC,GAAG,YAAY,EAAE,GAAG,iBAAiB,CAAC;gBACrD,OAAO;gBACP,OAAO;gBACP,aAAa,EAAE,WAAW,IAAI,CAAC,CAAC,CAAC,CAAC,WAAW,CAAC,IAAI,CAAC,WAAW,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,aAAa;gBACvF,UAAU,EAAE,SAAS;aACtB,CAAC,CAAA;QACJ,CAAC;KAAA;CACF;AAtWD,8CAsWC"}
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=multisig-coordinator-wallet.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"multisig-coordinator-wallet.d.ts","sourceRoot":"","sources":["../src/multisig-coordinator-wallet.ts"],"names":[],"mappings":""}
@@ -0,0 +1,6 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ const bitcoin_wallet_base_1 = require("./bitcoin-wallet-base");
4
+ class BitcoinMultiSigWithCoordinatorWallet extends bitcoin_wallet_base_1.BitcoinBaseWallet {
5
+ }
6
+ //# sourceMappingURL=multisig-coordinator-wallet.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"multisig-coordinator-wallet.js","sourceRoot":"","sources":["../src/multisig-coordinator-wallet.ts"],"names":[],"mappings":";;AAAA,+DAAyD;AAEzD,MAAM,oCAAqC,SAAQ,uCAAiB;CAMnE"}
@@ -0,0 +1,40 @@
1
+ import { TeleportdaoMultisigCoordinator, TxRequest } from "@teleportdao/providers";
2
+ import { BitcoinBaseWallet, FeeRateType } from "./bitcoin-wallet-base";
3
+ import { ExtendedUnsignedTransaction, ExtendedUtxo, SignerInfo, TargetAddress } from "./transaction-builder";
4
+ export declare class MultisigWalletHelper {
5
+ baseWallet: BitcoinBaseWallet;
6
+ coordinator: TeleportdaoMultisigCoordinator;
7
+ acceptableFeeDiff: number;
8
+ txCheckConfig: {
9
+ sleepTime: number;
10
+ maxRetry: number;
11
+ };
12
+ txCounter?: number;
13
+ txCounterMonitor: boolean;
14
+ constructor(baseWallet: BitcoinBaseWallet, coordinatorUrl: string, coordinatorApiKey: string, txCounterMonitor?: boolean, acceptableFeeDiffPercentage?: number, txCheckConfig?: {
15
+ sleepTime: number;
16
+ maxRetry: number;
17
+ });
18
+ get bitcoinAddress(): string | undefined;
19
+ setAccountType(addressType: "p2sh" | "p2wsh" | "p2sh-p2wsh", publicKeys: string[], numberOfSigners?: number): string;
20
+ setTxCounter(txCounter: number): Promise<void>;
21
+ resetTxCounter(): Promise<number>;
22
+ step1SendBTCToMultipleAddressUnsigned(receivers: TargetAddress[], signerInfo: SignerInfo, fee?: FeeRateType, staticExtendedUtxo?: ExtendedUtxo[], fullAmount?: boolean): Promise<{
23
+ txRequest: TxRequest;
24
+ unsignedTx: ExtendedUnsignedTransaction;
25
+ }>;
26
+ step2WaitForUnsignedTxApproval(input: {
27
+ unsignedTx: ExtendedUnsignedTransaction;
28
+ txRequest: TxRequest;
29
+ }): Promise<{
30
+ unsignedTx: ExtendedUnsignedTransaction;
31
+ txRequest: TxRequest;
32
+ }>;
33
+ step3SignTxAndWaitForBroadcast(input: {
34
+ unsignedTx: ExtendedUnsignedTransaction;
35
+ txRequest: TxRequest;
36
+ }): Promise<TxRequest>;
37
+ sendBTCMultipleAddress(receivers: TargetAddress[], fee?: FeeRateType, staticExtendedUtxo?: ExtendedUtxo[], fullAmount?: boolean): Promise<TxRequest>;
38
+ sendBTC(receiverAddress: string, amountInSatoshi: number | "all", fee?: FeeRateType, staticExtendedUtxo?: ExtendedUtxo[]): Promise<TxRequest>;
39
+ }
40
+ //# sourceMappingURL=multisig-wallet-helper.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"multisig-wallet-helper.d.ts","sourceRoot":"","sources":["../src/multisig-wallet-helper.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,8BAA8B,EAAE,SAAS,EAAE,MAAM,wBAAwB,CAAA;AAElF,OAAO,EAAE,iBAAiB,EAAE,WAAW,EAAE,MAAM,uBAAuB,CAAA;AACtE,OAAO,EACL,2BAA2B,EAC3B,YAAY,EACZ,UAAU,EACV,aAAa,EACd,MAAM,uBAAuB,CAAA;AAE9B,qBAAa,oBAAoB;IAC/B,UAAU,EAAE,iBAAiB,CAAA;IAC7B,WAAW,EAAE,8BAA8B,CAAA;IAC3C,iBAAiB,EAAE,MAAM,CAAA;IACzB,aAAa,EAAE;QAAE,SAAS,EAAE,MAAM,CAAC;QAAC,QAAQ,EAAE,MAAM,CAAA;KAAE,CAAA;IACtD,SAAS,CAAC,EAAE,MAAM,CAAA;IAClB,gBAAgB,EAAE,OAAO,CAAA;gBAEvB,UAAU,EAAE,iBAAiB,EAC7B,cAAc,EAAE,MAAM,EACtB,iBAAiB,EAAE,MAAM,EACzB,gBAAgB,UAAO,EACvB,2BAA2B,CAAC,EAAE,MAAM,EACpC,aAAa,CAAC,EAAE;QAAE,SAAS,EAAE,MAAM,CAAC;QAAC,QAAQ,EAAE,MAAM,CAAA;KAAE;IAazD,IAAI,cAAc,uBAEjB;IAED,cAAc,CACZ,WAAW,EAAE,MAAM,GAAG,OAAO,GAAG,YAAY,EAC5C,UAAU,EAAE,MAAM,EAAE,EACpB,eAAe,CAAC,EAAE,MAAM;IAQpB,YAAY,CAAC,SAAS,EAAE,MAAM;IAI9B,cAAc;IAMd,qCAAqC,CACzC,SAAS,EAAE,aAAa,EAAE,EAC1B,UAAU,EAAE,UAAU,EACtB,GAAG,GAAE,WAAsB,EAC3B,kBAAkB,CAAC,EAAE,YAAY,EAAE,EACnC,UAAU,UAAQ;;;;IAkCd,8BAA8B,CAAC,KAAK,EAAE;QAC1C,UAAU,EAAE,2BAA2B,CAAA;QACvC,SAAS,EAAE,SAAS,CAAA;KACrB;;;;IA6EK,8BAA8B,CAAC,KAAK,EAAE;QAC1C,UAAU,EAAE,2BAA2B,CAAA;QACvC,SAAS,EAAE,SAAS,CAAA;KACrB;IA4BK,sBAAsB,CAC1B,SAAS,EAAE,aAAa,EAAE,EAC1B,GAAG,GAAE,WAAsB,EAC3B,kBAAkB,CAAC,EAAE,YAAY,EAAE,EACnC,UAAU,UAAQ;IAkBd,OAAO,CACX,eAAe,EAAE,MAAM,EACvB,eAAe,EAAE,MAAM,GAAG,KAAK,EAC/B,GAAG,GAAE,WAAsB,EAC3B,kBAAkB,CAAC,EAAE,YAAY,EAAE;CAUtC"}
@@ -0,0 +1,172 @@
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.MultisigWalletHelper = void 0;
16
+ const providers_1 = require("@teleportdao/providers");
17
+ const bignumber_js_1 = __importDefault(require("bignumber.js"));
18
+ class MultisigWalletHelper {
19
+ constructor(baseWallet, coordinatorUrl, coordinatorApiKey, txCounterMonitor = true, acceptableFeeDiffPercentage, txCheckConfig) {
20
+ this.baseWallet = baseWallet;
21
+ this.coordinator = new providers_1.TeleportdaoMultisigCoordinator(coordinatorUrl, coordinatorApiKey);
22
+ this.acceptableFeeDiff = acceptableFeeDiffPercentage || 30;
23
+ this.txCheckConfig = txCheckConfig || {
24
+ sleepTime: 1500,
25
+ maxRetry: 30,
26
+ };
27
+ this.txCounterMonitor = txCounterMonitor;
28
+ this.txCounter = undefined;
29
+ }
30
+ get bitcoinAddress() {
31
+ return this.baseWallet.bitcoinAddress;
32
+ }
33
+ setAccountType(addressType, publicKeys, numberOfSigners) {
34
+ return this.baseWallet.setAccountType(addressType, {
35
+ publicKeys,
36
+ numberOfSigners,
37
+ });
38
+ }
39
+ setTxCounter(txCounter) {
40
+ return __awaiter(this, void 0, void 0, function* () {
41
+ if (this.txCounterMonitor)
42
+ this.txCounter = txCounter;
43
+ });
44
+ }
45
+ resetTxCounter() {
46
+ return __awaiter(this, void 0, void 0, function* () {
47
+ const wallet = yield this.coordinator.getWallet();
48
+ this.setTxCounter(wallet.txCounter);
49
+ return wallet.txCounter;
50
+ });
51
+ }
52
+ step1SendBTCToMultipleAddressUnsigned(receivers, signerInfo, fee = "normal", staticExtendedUtxo, fullAmount = false) {
53
+ return __awaiter(this, void 0, void 0, function* () {
54
+ let unsignedTx = yield this.baseWallet.sendBTCToMultipleAddressUnsignedTx(receivers, signerInfo, fee, staticExtendedUtxo, fullAmount);
55
+ let txRequest = yield this.coordinator.createOrConfirmNewTx({
56
+ inputs: unsignedTx.inputs.map((x) => ({
57
+ hash: x.hash,
58
+ index: x.index,
59
+ value: x.value,
60
+ })),
61
+ outputs: unsignedTx.outputs,
62
+ feeRate: unsignedTx.feeRate,
63
+ unsignedPsbt: unsignedTx.unsignedTransaction,
64
+ txCounter: this.txCounter,
65
+ });
66
+ if (txRequest.status !== "Rejected" && txRequest.status !== "Broadcasted") {
67
+ this.setTxCounter(txRequest.txCounter);
68
+ }
69
+ else {
70
+ yield this.resetTxCounter();
71
+ }
72
+ return {
73
+ txRequest,
74
+ unsignedTx,
75
+ };
76
+ });
77
+ }
78
+ step2WaitForUnsignedTxApproval(input) {
79
+ return __awaiter(this, void 0, void 0, function* () {
80
+ const feeRateDiffPercentage = this.acceptableFeeDiff;
81
+ let newUnsignedTx = input.unsignedTx;
82
+ let newTxRequest = input.txRequest;
83
+ if (newTxRequest.status === "Pending") {
84
+ this.setTxCounter(newTxRequest.txCounter);
85
+ if (newTxRequest.unsignedPsbt !== newUnsignedTx.unsignedTransaction) {
86
+ const feeDiff = (0, bignumber_js_1.default)(newTxRequest.feeRate)
87
+ .minus(newUnsignedTx.feeRate)
88
+ .abs()
89
+ .dividedBy(newUnsignedTx.feeRate);
90
+ if (!feeDiff.isLessThan(feeRateDiffPercentage / 100)) {
91
+ const txRequest = yield this.coordinator.rejectTxRequest(newTxRequest.id);
92
+ this.setTxCounter((this.txCounter || txRequest.txCounter) + 1);
93
+ throw new Error("Reject because of Invalid FeeRate");
94
+ }
95
+ const { signerInfo } = newUnsignedTx.inputs[0];
96
+ newUnsignedTx = yield this.baseWallet.sendBTCToMultipleAddressUnsignedTx(newUnsignedTx.outputs, signerInfo, +newTxRequest.feeRate, newTxRequest.inputs.map((x) => (Object.assign(Object.assign({}, x), { signerInfo }))));
97
+ let updatedTxRequest = yield this.coordinator.confirmOrRejectTxRequest(newTxRequest.id, newUnsignedTx.unsignedTransaction);
98
+ if (updatedTxRequest.status === "Rejected" ||
99
+ updatedTxRequest.unsignedPsbt !== newUnsignedTx.unsignedTransaction) {
100
+ this.setTxCounter((this.txCounter || updatedTxRequest.txCounter) + 1);
101
+ throw new Error("Reject because of invalid outputs");
102
+ }
103
+ newTxRequest = updatedTxRequest;
104
+ }
105
+ const updatedTxRequest = yield this.coordinator.waitTxStatusChange(newTxRequest.id, "Pending", this.txCheckConfig.sleepTime, this.txCheckConfig.maxRetry);
106
+ if (!updatedTxRequest) {
107
+ yield this.coordinator.rejectTxRequest(newTxRequest.id);
108
+ if (this.txCounter)
109
+ this.setTxCounter(this.txCounter + 1);
110
+ throw new Error("Tx Timeout");
111
+ }
112
+ newTxRequest = updatedTxRequest;
113
+ if (newTxRequest.status === "Rejected") {
114
+ if (this.txCounter)
115
+ this.setTxCounter(this.txCounter + 1);
116
+ throw new Error("Tx Rejected");
117
+ }
118
+ }
119
+ if (newTxRequest.status === "Rejected") {
120
+ yield this.resetTxCounter();
121
+ throw new Error("Tx was Rejected");
122
+ }
123
+ return {
124
+ unsignedTx: newUnsignedTx,
125
+ txRequest: newTxRequest,
126
+ };
127
+ });
128
+ }
129
+ step3SignTxAndWaitForBroadcast(input) {
130
+ return __awaiter(this, void 0, void 0, function* () {
131
+ if (!this.baseWallet.privateKey)
132
+ throw new Error("account is not initialized");
133
+ const { unsignedTx, txRequest } = input;
134
+ let newTxRequest = txRequest;
135
+ if (newTxRequest.status === "Approved") {
136
+ const signed = yield this.baseWallet.signer.signPsbt(unsignedTx, this.baseWallet.privateKey);
137
+ newTxRequest = yield this.coordinator.submitSignedPsbt(newTxRequest.id, signed);
138
+ }
139
+ if (newTxRequest.status === "Approved") {
140
+ if (this.txCounter)
141
+ this.setTxCounter(newTxRequest.txCounter);
142
+ const finalTx = yield this.coordinator.waitTxStatusChange(newTxRequest.id, "Approved", this.txCheckConfig.sleepTime, this.txCheckConfig.maxRetry);
143
+ if (!finalTx || finalTx.status === "Failed") {
144
+ throw new Error("Tx not broadcasted for long time");
145
+ }
146
+ newTxRequest = finalTx;
147
+ if (this.txCounter)
148
+ this.setTxCounter(this.txCounter + 1);
149
+ }
150
+ return newTxRequest;
151
+ });
152
+ }
153
+ sendBTCMultipleAddress(receivers, fee = "normal", staticExtendedUtxo, fullAmount = false) {
154
+ return __awaiter(this, void 0, void 0, function* () {
155
+ if (!this.baseWallet.signerInfo || !this.baseWallet.privateKey) {
156
+ throw new Error("account not initialized");
157
+ }
158
+ let unsignedResponse = yield this.step1SendBTCToMultipleAddressUnsigned(receivers, this.baseWallet.signerInfo, fee, staticExtendedUtxo, fullAmount);
159
+ unsignedResponse = yield this.step2WaitForUnsignedTxApproval(unsignedResponse);
160
+ const txRequest = yield this.step3SignTxAndWaitForBroadcast(unsignedResponse);
161
+ return txRequest;
162
+ });
163
+ }
164
+ sendBTC(receiverAddress, amountInSatoshi, fee = "normal", staticExtendedUtxo) {
165
+ return __awaiter(this, void 0, void 0, function* () {
166
+ const txRequest = yield this.sendBTCMultipleAddress([{ address: receiverAddress, value: amountInSatoshi === "all" ? 0 : amountInSatoshi }], fee, staticExtendedUtxo, amountInSatoshi === "all");
167
+ return txRequest;
168
+ });
169
+ }
170
+ }
171
+ exports.MultisigWalletHelper = MultisigWalletHelper;
172
+ //# sourceMappingURL=multisig-wallet-helper.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"multisig-wallet-helper.js","sourceRoot":"","sources":["../src/multisig-wallet-helper.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;AAAA,sDAAkF;AAClF,gEAAoC;AASpC,MAAa,oBAAoB;IAO/B,YACE,UAA6B,EAC7B,cAAsB,EACtB,iBAAyB,EACzB,gBAAgB,GAAG,IAAI,EACvB,2BAAoC,EACpC,aAAuD;QAEvD,IAAI,CAAC,UAAU,GAAG,UAAU,CAAA;QAC5B,IAAI,CAAC,WAAW,GAAG,IAAI,0CAA8B,CAAC,cAAc,EAAE,iBAAiB,CAAC,CAAA;QACxF,IAAI,CAAC,iBAAiB,GAAG,2BAA2B,IAAI,EAAE,CAAA;QAC1D,IAAI,CAAC,aAAa,GAAG,aAAa,IAAI;YACpC,SAAS,EAAE,IAAI;YACf,QAAQ,EAAE,EAAE;SACb,CAAA;QACD,IAAI,CAAC,gBAAgB,GAAG,gBAAgB,CAAA;QACxC,IAAI,CAAC,S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AAC,EACtF,GAAG,EACH,kBAAkB,EAClB,eAAe,KAAK,KAAK,CAC1B,CAAA;YACD,OAAO,SAAS,CAAA;QAClB,CAAC;KAAA;CACF;AA7OD,oDA6OC"}
@@ -0,0 +1,20 @@
1
+ import { TeleportdaoMultisigCoordinator, TxRequest } from "@teleportdao/providers";
2
+ import { BitcoinBaseWallet, FeeRateType } from "./bitcoin-wallet-base";
3
+ import { ExtendedUnsignedTransaction, ExtendedUtxo, SignerInfo, TargetAddress } from "./transaction-builder";
4
+ export declare class MultisigWalletHelper {
5
+ baseWallet: BitcoinBaseWallet;
6
+ coordinator: TeleportdaoMultisigCoordinator;
7
+ constructor(baseWallet: BitcoinBaseWallet, coordinatorApiKey: string, coordinatorUrl: string);
8
+ step1SendBTCToMultipleAddressUnsigned(receivers: TargetAddress[], signerInfo: SignerInfo, fee?: FeeRateType, staticExtendedUtxo?: ExtendedUtxo[], fullAmount?: boolean): Promise<{
9
+ txRequest: TxRequest;
10
+ unsignedTx: ExtendedUnsignedTransaction;
11
+ }>;
12
+ step2WaitForUnsignedTxApproval(unsignedTx: ExtendedUnsignedTransaction, txRequest: TxRequest, feeRateDiffPercentage?: number): Promise<{
13
+ unsignedTx: ExtendedUnsignedTransaction;
14
+ txRequest: TxRequest;
15
+ }>;
16
+ step3SignTxAndWaitForBroadcast(unsignedTx: ExtendedUnsignedTransaction, txRequest: TxRequest): Promise<TxRequest>;
17
+ sendBTCMultipleAddress(receivers: TargetAddress[], fee?: FeeRateType, staticExtendedUtxo?: ExtendedUtxo[], fullAmount?: boolean): Promise<TxRequest>;
18
+ sendBTC(receiverAddress: string, amountInSatoshi: number | "all", fee?: FeeRateType, staticExtendedUtxo?: ExtendedUtxo[]): Promise<TxRequest>;
19
+ }
20
+ //# sourceMappingURL=multisig-wallet.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"multisig-wallet.d.ts","sourceRoot":"","sources":["../src/multisig-wallet.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,8BAA8B,EAAE,SAAS,EAAE,MAAM,wBAAwB,CAAA;AAElF,OAAO,EAAE,iBAAiB,EAAE,WAAW,EAAE,MAAM,uBAAuB,CAAA;AACtE,OAAO,EACL,2BAA2B,EAC3B,YAAY,EACZ,UAAU,EACV,aAAa,EACd,MAAM,uBAAuB,CAAA;AAE9B,qBAAa,oBAAoB;IAC/B,UAAU,EAAE,iBAAiB,CAAA;IAC7B,WAAW,EAAE,8BAA8B,CAAA;gBAC/B,UAAU,EAAE,iBAAiB,EAAE,iBAAiB,EAAE,MAAM,EAAE,cAAc,EAAE,MAAM;IAKtF,qCAAqC,CACzC,SAAS,EAAE,aAAa,EAAE,EAC1B,UAAU,EAAE,UAAU,EACtB,GAAG,GAAE,WAAsB,EAC3B,kBAAkB,CAAC,EAAE,YAAY,EAAE,EACnC,UAAU,UAAQ;;;;IA2Bd,8BAA8B,CAClC,UAAU,EAAE,2BAA2B,EACvC,SAAS,EAAE,SAAS,EACpB,qBAAqB,SAAK;;;;IA4DtB,8BAA8B,CAClC,UAAU,EAAE,2BAA2B,EACvC,SAAS,EAAE,SAAS;IAoBhB,sBAAsB,CAC1B,SAAS,EAAE,aAAa,EAAE,EAC1B,GAAG,GAAE,WAAsB,EAC3B,kBAAkB,CAAC,EAAE,YAAY,EAAE,EACnC,UAAU,UAAQ;IAwBd,OAAO,CACX,eAAe,EAAE,MAAM,EACvB,eAAe,EAAE,MAAM,GAAG,KAAK,EAC/B,GAAG,GAAE,WAAsB,EAC3B,kBAAkB,CAAC,EAAE,YAAY,EAAE;CAUtC"}
@@ -0,0 +1,119 @@
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.MultisigWalletHelper = void 0;
16
+ const providers_1 = require("@teleportdao/providers");
17
+ const bignumber_js_1 = __importDefault(require("bignumber.js"));
18
+ class MultisigWalletHelper {
19
+ constructor(baseWallet, coordinatorApiKey, coordinatorUrl) {
20
+ this.baseWallet = baseWallet;
21
+ this.coordinator = new providers_1.TeleportdaoMultisigCoordinator(coordinatorUrl, coordinatorApiKey);
22
+ }
23
+ step1SendBTCToMultipleAddressUnsigned(receivers, signerInfo, fee = "normal", staticExtendedUtxo, fullAmount = false) {
24
+ return __awaiter(this, void 0, void 0, function* () {
25
+ let unsignedTx = yield this.baseWallet.sendBTCToMultipleAddressUnsignedTx(receivers, signerInfo, fee, staticExtendedUtxo, fullAmount);
26
+ let txRequest = yield this.coordinator.createOrConfirmNewTx({
27
+ inputs: unsignedTx.inputs.map((x) => ({
28
+ hash: x.hash,
29
+ index: x.index,
30
+ value: x.value,
31
+ })),
32
+ outputs: unsignedTx.outputs,
33
+ feeRate: unsignedTx.feeRate,
34
+ unsignedPsbt: unsignedTx.unsignedTransaction,
35
+ });
36
+ return {
37
+ txRequest,
38
+ unsignedTx,
39
+ };
40
+ });
41
+ }
42
+ step2WaitForUnsignedTxApproval(unsignedTx, txRequest, feeRateDiffPercentage = 10) {
43
+ return __awaiter(this, void 0, void 0, function* () {
44
+ let newUnsignedTx = unsignedTx;
45
+ let newTxRequest = txRequest;
46
+ if (newTxRequest.unsignedPsbt !== unsignedTx.unsignedTransaction) {
47
+ const feeDiff = (0, bignumber_js_1.default)(newTxRequest.feeRate)
48
+ .minus(unsignedTx.feeRate)
49
+ .abs()
50
+ .dividedBy(unsignedTx.feeRate);
51
+ if (!feeDiff.isLessThan(feeRateDiffPercentage / 100)) {
52
+ yield this.coordinator.rejectTxRequest(newTxRequest.id);
53
+ throw new Error("Reject because of Invalid FeeRate");
54
+ }
55
+ const { signerInfo } = unsignedTx.inputs[0];
56
+ newUnsignedTx = yield this.baseWallet.sendBTCToMultipleAddressUnsignedTx(unsignedTx.outputs, signerInfo, +newTxRequest.feeRate, newTxRequest.inputs.map((x) => (Object.assign(Object.assign({}, x), { signerInfo }))));
57
+ let updatedTxRequest = yield this.coordinator.confirmOrRejectTxRequest(newTxRequest.id, unsignedTx.unsignedTransaction);
58
+ if (updatedTxRequest.unsignedPsbt !== unsignedTx.unsignedTransaction ||
59
+ updatedTxRequest.status === "Rejected") {
60
+ throw new Error("Reject because of invalid outputs");
61
+ }
62
+ newTxRequest = updatedTxRequest;
63
+ }
64
+ if (newTxRequest.status === "Pending") {
65
+ const updatedTxRequest = yield this.coordinator.waitTxStatusChange(newTxRequest.id);
66
+ if (!updatedTxRequest) {
67
+ yield this.coordinator.rejectTxRequest(newTxRequest.id);
68
+ throw new Error("Tx Timeout");
69
+ }
70
+ newTxRequest = updatedTxRequest;
71
+ }
72
+ if (newTxRequest.status === "Rejected") {
73
+ throw new Error("Tx rejected");
74
+ }
75
+ return {
76
+ unsignedTx: newUnsignedTx,
77
+ txRequest: newTxRequest,
78
+ };
79
+ });
80
+ }
81
+ step3SignTxAndWaitForBroadcast(unsignedTx, txRequest) {
82
+ return __awaiter(this, void 0, void 0, function* () {
83
+ if (!this.baseWallet.privateKey)
84
+ throw new Error("account is not initialized");
85
+ let newTxRequest = txRequest;
86
+ if (newTxRequest.status === "Approved") {
87
+ const signed = yield this.baseWallet.signer.signPsbt(unsignedTx, this.baseWallet.privateKey);
88
+ newTxRequest = yield this.coordinator.submitSignedPsbt(newTxRequest.id, signed);
89
+ }
90
+ if (newTxRequest.status === "Approved") {
91
+ const finalTx = yield this.coordinator.waitTxStatusChange(newTxRequest.id, "Approved");
92
+ if (!finalTx || finalTx.status === "Failed") {
93
+ throw new Error("Tx not broadcasted for long time");
94
+ }
95
+ newTxRequest = finalTx;
96
+ }
97
+ return newTxRequest;
98
+ });
99
+ }
100
+ sendBTCMultipleAddress(receivers, fee = "normal", staticExtendedUtxo, fullAmount = false) {
101
+ return __awaiter(this, void 0, void 0, function* () {
102
+ if (!this.baseWallet.signerInfo || !this.baseWallet.privateKey) {
103
+ throw new Error("account not initialized");
104
+ }
105
+ let unsignedResponse = yield this.step1SendBTCToMultipleAddressUnsigned(receivers, this.baseWallet.signerInfo, fee, staticExtendedUtxo, fullAmount);
106
+ unsignedResponse = yield this.step2WaitForUnsignedTxApproval(unsignedResponse.unsignedTx, unsignedResponse.txRequest);
107
+ const txRequest = yield this.step3SignTxAndWaitForBroadcast(unsignedResponse.unsignedTx, unsignedResponse.txRequest);
108
+ return txRequest;
109
+ });
110
+ }
111
+ sendBTC(receiverAddress, amountInSatoshi, fee = "normal", staticExtendedUtxo) {
112
+ return __awaiter(this, void 0, void 0, function* () {
113
+ const txRequest = yield this.sendBTCMultipleAddress([{ address: receiverAddress, value: amountInSatoshi === "all" ? 0 : amountInSatoshi }], fee, staticExtendedUtxo, amountInSatoshi === "all");
114
+ return txRequest;
115
+ });
116
+ }
117
+ }
118
+ exports.MultisigWalletHelper = MultisigWalletHelper;
119
+ //# sourceMappingURL=multisig-wallet.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"multisig-wallet.js","sourceRoot":"","sources":["../src/multisig-wallet.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;AAAA,sDAAkF;AAClF,gEAAoC;AASpC,MAAa,oBAAoB;IAG/B,YAAY,UAA6B,EAAE,iBAAyB,EAAE,cAAsB;QAC1F,IAAI,CAAC,UAAU,GAAG,UAAU,CAAA;QAC5B,IAAI,CAAC,WAAW,GAAG,IAAI,0CAA8B,CAAC,cAAc,EAAE,iBAAiB,CAAC,CAAA;IAC1F,CAAC;IAEK,qCAAqC,CACzC,SAA0B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B,GAAG,EACH,kBAAkB,EAClB,UAAU,CACX,CAAA;YACD,gBAAgB,GAAG,MAAM,IAAI,CAAC,8BAA8B,CAC1D,gBAAgB,CAAC,UAAU,EAC3B,gBAAgB,CAAC,SAAS,CAC3B,CAAA;YACD,MAAM,SAAS,GAAG,MAAM,IAAI,CAAC,8BAA8B,CACzD,gBAAgB,CAAC,UAAU,EAC3B,gBAAgB,CAAC,SAAS,CAC3B,CAAA;YACD,OAAO,SAAS,CAAA;QAClB,CAAC;KAAA;IAEK,OAAO,CACX,eAAuB,EACvB,eAA+B,EAC/B,MAAmB,QAAQ,EAC3B,kBAAmC;;YAEnC,MAAM,SAAS,GAAG,MAAM,IAAI,CAAC,sBAAsB,CACjD,CAAC,EAAE,OAAO,EAAE,eAAe,EAAE,KAAK,EAAE,eAAe,KAAK,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,eAAe,EAAE,CAAC,EACtF,GAAG,EACH,kBAAkB,EAClB,eAAe,KAAK,KAAK,CAC1B,CAAA;YACD,OAAO,SAAS,CAAA;QAClB,CAAC;KAAA;CACF;AAvKD,oDAuKC"}
@@ -23,12 +23,12 @@ export declare class TeleswapWallet extends BitcoinBaseWallet {
23
23
  outputToken: string;
24
24
  outputAmount: string;
25
25
  bridgePercentageFee?: number;
26
- }, appId?: number, fee?: FeeRateType, thirdPartyId?: number, staticExtendedUtxo?: ExtendedUtxo[], changeAddress?: string, fullAmount?: boolean): Promise<any>;
26
+ }, appId?: number, speed?: boolean, fee?: FeeRateType, thirdPartyId?: number, staticExtendedUtxo?: ExtendedUtxo[], changeAddress?: string, fullAmount?: boolean): Promise<any>;
27
27
  wrapUnsigned(recipientAddress: string, amount: string, networkFee: string, lockerAddress: string, chainId: number, signer: SignerInfo, exchange?: {
28
28
  outputToken: string;
29
29
  outputAmount: string;
30
30
  bridgePercentageFee?: number;
31
- }, appId?: number, fee?: FeeRateType, thirdPartyId?: number, staticExtendedUtxo?: ExtendedUtxo[], changeAddress?: string, fullAmount?: boolean): Promise<{
31
+ }, appId?: number, speed?: boolean, fee?: FeeRateType, thirdPartyId?: number, staticExtendedUtxo?: ExtendedUtxo[], changeAddress?: string, fullAmount?: boolean): Promise<{
32
32
  unsignedTransaction: string;
33
33
  outputs: import("./transaction-builder/transaction-builder").Target[];
34
34
  inputs: {
@@ -1 +1 @@
1
- {"version":3,"file":"teleswap-wallet.d.ts","sourceRoot":"","sources":["../src/teleswap-wallet.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EACV,YAAY,EACZ,UAAU,EAEX,MAAM,2CAA2C,CAAA;AAClD,OAAO,EAAE,iBAAiB,EAAE,WAAW,EAAE,MAAM,uBAAuB,CAAA;AAGtE,MAAM,MAAM,eAAe,GAAG;IAC5B,aAAa,CAAC,EAAE,MAAM,CAAA;IACtB,aAAa,EAAE,MAAM,CAAA;IACrB,MAAM,EAAE,MAAM,CAAA;IACd,UAAU,CAAC,EAAE,OAAO,CAAA;IAEpB,OAAO,EAAE,MAAM,CAAA;IACf,KAAK,EAAE,MAAM,CAAA;IACb,gBAAgB,EAAE,MAAM,CAAA;IACxB,aAAa,EAAE,MAAM,CAAA;IACrB,KAAK,CAAC,EAAE,MAAM,GAAG,OAAO,CAAA;IACxB,UAAU,CAAC,EAAE,OAAO,CAAA;IACpB,oBAAoB,CAAC,EAAE,MAAM,CAAA;IAC7B,YAAY,CAAC,EAAE,MAAM,CAAA;IACrB,QAAQ,CAAC,EAAE,MAAM,CAAA;IACjB,YAAY,CAAC,EAAE,OAAO,CAAA;IACtB,QAAQ,CAAC,EAAE,QAAQ,GAAG,MAAM,GAAG,MAAM,CAAA;IACrC,aAAa,CAAC,EAAE,MAAM,CAAA;CACvB,CAAA;AAED,qBAAa,cAAe,SAAQ,iBAAiB;IAE7C,IAAI,CACR,gBAAgB,EAAE,MAAM,EACxB,MAAM,EAAE,MAAM,EACd,UAAU,EAAE,MAAM,EAClB,aAAa,EAAE,MAAM,EACrB,OAAO,EAAE,MAAM,EACf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AAY,CAAC,EAAE,MAAM,EACrB,kBAAkB,CAAC,EAAE,YAAY,EAAE,EACnC,aAAa,CAAC,EAAE,MAAM,EACtB,UAAU,UAAQ;;;;;;;;;;;;;CAqCrB;AACD,eAAe,cAAc,CAAA"}
@@ -16,26 +16,26 @@ const teleswap_helper_1 = require("./helper/teleswap-helper");
16
16
  class TeleswapWallet extends bitcoin_wallet_base_1.BitcoinBaseWallet {
17
17
  wrap(recipientAddress, amount, networkFee, lockerAddress, chainId, exchange, appId = exchange
18
18
  ? configs_1.teleswap.requestAppId.WrapAndSwap.default
19
- : configs_1.teleswap.requestAppId.Wrap.default, fee = "normal", thirdPartyId, staticExtendedUtxo, changeAddress, fullAmount = false) {
19
+ : configs_1.teleswap.requestAppId.Wrap.default, speed = false, fee = "normal", thirdPartyId, staticExtendedUtxo, changeAddress, fullAmount = false) {
20
20
  return __awaiter(this, void 0, void 0, function* () {
21
21
  if (!this.signerInfo || !this.privateKey) {
22
22
  throw new Error("account not initialized");
23
23
  }
24
- let unsignedTransaction = yield this.wrapUnsigned(recipientAddress, amount, networkFee, lockerAddress, chainId, this.signerInfo, exchange, appId, fee, thirdPartyId, staticExtendedUtxo, changeAddress, fullAmount);
24
+ let unsignedTransaction = yield this.wrapUnsigned(recipientAddress, amount, networkFee, lockerAddress, chainId, this.signerInfo, exchange, appId, speed, fee, thirdPartyId, staticExtendedUtxo, changeAddress, fullAmount);
25
25
  let signedPsbt = yield this.signer.signPsbt(unsignedTransaction, this.privateKey);
26
26
  return this.sendSignedPsbt(signedPsbt);
27
27
  });
28
28
  }
29
29
  wrapUnsigned(recipientAddress, amount, networkFee, lockerAddress, chainId, signer, exchange, appId = exchange
30
30
  ? configs_1.teleswap.requestAppId.WrapAndSwap.default
31
- : configs_1.teleswap.requestAppId.Wrap.default, fee = "normal", thirdPartyId, staticExtendedUtxo, changeAddress, fullAmount = false) {
31
+ : configs_1.teleswap.requestAppId.Wrap.default, speed = false, fee = "normal", thirdPartyId, staticExtendedUtxo, changeAddress, fullAmount = false) {
32
32
  return __awaiter(this, void 0, void 0, function* () {
33
33
  const dataHex = (0, teleswap_helper_1.generateWrapOpReturn)({
34
34
  chainId,
35
35
  appId,
36
36
  recipientAddress,
37
37
  networkFee,
38
- speed: false,
38
+ speed,
39
39
  isExchange: !!exchange,
40
40
  outputAmount: exchange === null || exchange === void 0 ? void 0 : exchange.outputAmount,
41
41
  outputToken: exchange === null || exchange === void 0 ? void 0 : exchange.outputToken,
@@ -1 +1 @@
1
- {"version":3,"file":"teleswap-wallet.js","sourceRoot":"","sources":["../src/teleswap-wallet.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,kDAA0D;AAM1D,+DAAsE;AACtE,8DAA+D;AAsB/D,MAAa,cAAe,SAAQ,uCAAiB;IAE7C,IAAI,CACR,gBAAwB,EACxB,MAAc,EACd,UAAkB,EAClB,aAAqB,EACrB,OAAe,EACf,QAIC,EACD,KAAK,GAAG,QAAQ;QACd,CAAC,CAAC,kBAAQ,CAAC,YAAY,CAAC,WAAW,CAAC,OAAO;QAC3C,CAAC,CAAC,kBAAQ,CAAC,YAAY,CAAC,IAAI,CAAC,OAAO,EACtC,MAAmB,QAAQ,EAC3B,YAAqB,EACrB,kBAAmC,EACnC,aAAsB,EACtB,UAAU,GAAG,KAAK;;YAElB,IAAI,CAAC,IAAI,CAAC,UAAU,IAAI,CAAC,IAAI,CAAC,UAAU,EAAE;gBACxC,MAAM,IAAI,KAAK,CAAC,yBAAyB,CAAC,CAAA;aAC3C;YACD,IAAI,mBAAmB,GAAG,MAAM,IAAI,CAAC,YAAY,CAC/C,gBAAgB,EAChB,MAAM,EACN,UAAU,EACV,aAAa,EACb,OAAO,EACP,IAAI,CAAC,UAAU,EACf,QAAQ,EACR,KAAK,EACL,GAAG,EACH,YAAY,EACZ,kBAAkB,EAClB,aAAa,EACb,UAAU,CACX,CAAA;YACD,IAAI,UAAU,GAAG,MAAM,IAAI,CAAC,MAAM,CAAC,QAAQ,CAAC,mBAAmB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;gBACtD,CAAC,CAAC;oBACE;wBACE,OAAO,EAAE,aAAa;wBACtB,KAAK,EAAE,CAAC,MAAM;qBACf;oBACD,IAAI,CAAC,kBAAkB,CAAC,iBAAiB,CAAC,OAAO,CAAC;iBACnD,CAAA;YAEL,MAAM,UAAU,GAAG,IAAI,CAAC,kBAAkB,CAAC,0BAA0B,CAAC;gBACpE,YAAY;gBACZ,OAAO;gBACP,OAAO;gBACP,aAAa,EAAE,UAAU,CAAC,CAAC,CAAC,aAAa,CAAC,CAAC,CAAC,aAAa,IAAI,MAAM,CAAC,OAAO;gBAC3E,UAAU;aACX,CAAC,CAAA;YAEF,OAAO,UAAU,CAAA;QACnB,CAAC;KAAA;CACF;AAzGD,wCAyGC;AACD,kBAAe,cAAc,CAAA"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@teleportdao/bitcoin",
3
- "version": "2.2.5",
3
+ "version": "2.2.7-beta.0",
4
4
  "description": "teleswap bitcoin package",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",
@@ -31,5 +31,5 @@
31
31
  "publishConfig": {
32
32
  "access": "public"
33
33
  },
34
- "gitHead": "274d6e364343325dfc3797b8bdc139e27be460ba"
34
+ "gitHead": "54d8c10d282fc9589867f40a9a299c07678ed65b"
35
35
  }
@@ -43,6 +43,7 @@ export class TeleswapWallet extends BitcoinBaseWallet {
43
43
  appId = exchange
44
44
  ? teleswap.requestAppId.WrapAndSwap.default
45
45
  : teleswap.requestAppId.Wrap.default,
46
+ speed = false,
46
47
  fee: FeeRateType = "normal",
47
48
  thirdPartyId?: number,
48
49
  staticExtendedUtxo?: ExtendedUtxo[],
@@ -61,6 +62,7 @@ export class TeleswapWallet extends BitcoinBaseWallet {
61
62
  this.signerInfo,
62
63
  exchange,
63
64
  appId,
65
+ speed,
64
66
  fee,
65
67
  thirdPartyId,
66
68
  staticExtendedUtxo,
@@ -88,6 +90,7 @@ export class TeleswapWallet extends BitcoinBaseWallet {
88
90
  appId = exchange
89
91
  ? teleswap.requestAppId.WrapAndSwap.default
90
92
  : teleswap.requestAppId.Wrap.default,
93
+ speed = false,
91
94
  fee: FeeRateType = "normal",
92
95
  thirdPartyId?: number,
93
96
  staticExtendedUtxo?: ExtendedUtxo[],
@@ -99,7 +102,7 @@ export class TeleswapWallet extends BitcoinBaseWallet {
99
102
  appId,
100
103
  recipientAddress,
101
104
  networkFee,
102
- speed: false,
105
+ speed,
103
106
  isExchange: !!exchange,
104
107
  outputAmount: exchange?.outputAmount,
105
108
  outputToken: exchange?.outputToken,