@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.
Files changed (78) hide show
  1. package/dist/bitcoin-interface-ordinal.d.ts +108 -108
  2. package/dist/bitcoin-interface-ordinal.js +140 -140
  3. package/dist/bitcoin-interface-teleswap.d.ts +101 -101
  4. package/dist/bitcoin-interface-teleswap.d.ts.map +1 -1
  5. package/dist/bitcoin-interface-teleswap.js +176 -165
  6. package/dist/bitcoin-interface-teleswap.js.map +1 -1
  7. package/dist/bitcoin-interface-utils.d.ts +20 -20
  8. package/dist/bitcoin-interface-utils.js +45 -45
  9. package/dist/bitcoin-interface-wallet.d.ts +28 -28
  10. package/dist/bitcoin-interface-wallet.js +125 -125
  11. package/dist/bitcoin-interface.d.ts +66 -66
  12. package/dist/bitcoin-interface.js +119 -119
  13. package/dist/bitcoin-utils.d.ts +96 -96
  14. package/dist/bitcoin-utils.js +514 -514
  15. package/dist/bitcoin-wallet-base.d.ts +111 -111
  16. package/dist/bitcoin-wallet-base.js +258 -258
  17. package/dist/helper/brc20-helper.d.ts +42 -42
  18. package/dist/helper/brc20-helper.js +127 -127
  19. package/dist/helper/index.d.ts +3 -3
  20. package/dist/helper/index.js +29 -29
  21. package/dist/helper/ordinal-helper.d.ts +12 -12
  22. package/dist/helper/ordinal-helper.js +129 -129
  23. package/dist/helper/teleswap-helper.d.ts +95 -95
  24. package/dist/helper/teleswap-helper.js +186 -186
  25. package/dist/index.d.ts +12 -12
  26. package/dist/index.js +41 -41
  27. package/dist/ordinal-wallet.d.ts +495 -495
  28. package/dist/ordinal-wallet.js +386 -386
  29. package/dist/sign/index.d.ts +1 -1
  30. package/dist/sign/index.js +8 -8
  31. package/dist/sign/sign-transaction.d.ts +12 -12
  32. package/dist/sign/sign-transaction.js +82 -82
  33. package/dist/teleswap-wallet.d.ts +45 -45
  34. package/dist/teleswap-wallet.js +68 -68
  35. package/dist/transaction-builder/bitcoin-transaction-builder.d.ts +9 -9
  36. package/dist/transaction-builder/bitcoin-transaction-builder.js +54 -54
  37. package/dist/transaction-builder/index.d.ts +3 -3
  38. package/dist/transaction-builder/index.js +19 -19
  39. package/dist/transaction-builder/ordinal-transaction-builder.d.ts +63 -63
  40. package/dist/transaction-builder/ordinal-transaction-builder.js +125 -125
  41. package/dist/transaction-builder/transaction-builder.d.ts +223 -223
  42. package/dist/transaction-builder/transaction-builder.js +447 -447
  43. package/dist/type.d.ts +61 -61
  44. package/dist/type.js +2 -2
  45. package/dist/utils/networks.d.ts +5 -5
  46. package/dist/utils/networks.js +53 -53
  47. package/dist/utils/tools.d.ts +18 -18
  48. package/dist/utils/tools.js +74 -74
  49. package/package.json +4 -4
  50. package/src/bitcoin-interface-ordinal.ts +185 -185
  51. package/src/bitcoin-interface-teleswap.ts +251 -237
  52. package/src/bitcoin-interface-utils.ts +60 -60
  53. package/src/bitcoin-interface-wallet.ts +114 -114
  54. package/src/bitcoin-interface.ts +156 -156
  55. package/src/bitcoin-utils.ts +591 -591
  56. package/src/bitcoin-wallet-base.ts +344 -344
  57. package/src/helper/brc20-helper.ts +179 -179
  58. package/src/helper/ordinal-helper.ts +118 -118
  59. package/src/index.ts +15 -15
  60. package/src/ordinal-wallet.ts +659 -659
  61. package/src/sign/index.ts +1 -1
  62. package/src/sign/sign-transaction.ts +108 -108
  63. package/src/teleswap-wallet.ts +133 -133
  64. package/src/transaction-builder/bitcoin-transaction-builder.ts +26 -26
  65. package/src/transaction-builder/index.ts +3 -3
  66. package/src/transaction-builder/ordinal-transaction-builder.ts +139 -139
  67. package/src/transaction-builder/transaction-builder.ts +690 -690
  68. package/src/type.ts +74 -74
  69. package/src/utils/networks.ts +33 -33
  70. package/src/utils/tools.ts +92 -92
  71. package/tsconfig.json +9 -9
  72. package/webpack.config.js +16 -16
  73. package/.tmp/block-parser.ts +0 -58
  74. package/.tmp/check.ts +0 -101
  75. package/.tmp/ordinal-helper.ts +0 -133
  76. package/.tmp/ordinal.ts +0 -25
  77. package/.tmp/psbt/sign-transaction.ts +0 -121
  78. package/.tmp/rbf.ts +0 -45
@@ -1,2 +1,2 @@
1
- export { default as BaseBitcoinSigner } from "./sign-transaction";
1
+ export { default as BaseBitcoinSigner } from "./sign-transaction";
2
2
  //# sourceMappingURL=index.d.ts.map
@@ -1,9 +1,9 @@
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.BaseBitcoinSigner = void 0;
7
- var sign_transaction_1 = require("./sign-transaction");
8
- Object.defineProperty(exports, "BaseBitcoinSigner", { enumerable: true, get: function () { return __importDefault(sign_transaction_1).default; } });
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.BaseBitcoinSigner = void 0;
7
+ var sign_transaction_1 = require("./sign-transaction");
8
+ Object.defineProperty(exports, "BaseBitcoinSigner", { enumerable: true, get: function () { return __importDefault(sign_transaction_1).default; } });
9
9
  //# sourceMappingURL=index.js.map
@@ -1,13 +1,13 @@
1
- /// <reference types="node" />
2
- import { Network } from "bitcoinjs-lib";
3
- declare class BitcoinLikeSignTransaction {
4
- network: Network;
5
- constructor(network: Network);
6
- signPsbt(unsignedPsbt: {
7
- unsignedTransaction: string;
8
- inputsToSign?: number[];
9
- }, privateKey: Buffer, sighashTypes?: any[], usingTweakSignerIfNeeded?: boolean): Promise<string>;
10
- finalizePsbts(psbtsBase64?: string[]): string;
11
- }
12
- export default BitcoinLikeSignTransaction;
1
+ /// <reference types="node" />
2
+ import { Network } from "bitcoinjs-lib";
3
+ declare class BitcoinLikeSignTransaction {
4
+ network: Network;
5
+ constructor(network: Network);
6
+ signPsbt(unsignedPsbt: {
7
+ unsignedTransaction: string;
8
+ inputsToSign?: number[];
9
+ }, privateKey: Buffer, sighashTypes?: any[], usingTweakSignerIfNeeded?: boolean): Promise<string>;
10
+ finalizePsbts(psbtsBase64?: string[]): string;
11
+ }
12
+ export default BitcoinLikeSignTransaction;
13
13
  //# sourceMappingURL=sign-transaction.d.ts.map
@@ -1,83 +1,83 @@
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
- const bitcoinjs_lib_1 = require("bitcoinjs-lib");
16
- const secp256k1_1 = __importDefault(require("@bitcoinerlab/secp256k1"));
17
- const ecpair_1 = __importDefault(require("ecpair"));
18
- const ECPair = (0, ecpair_1.default)(secp256k1_1.default);
19
- function tapTweakHash(pubKey, h) {
20
- return bitcoinjs_lib_1.crypto.taggedHash("TapTweak", Buffer.concat(h ? [pubKey, h] : [pubKey]));
21
- }
22
- function tweakSigner(privateKey, network, opts = {}) {
23
- let newPrv = privateKey;
24
- let keyPair = ECPair.fromPrivateKey(privateKey, {
25
- network,
26
- compressed: true,
27
- });
28
- if (!keyPair.privateKey)
29
- throw new Error("private key not exist");
30
- if (keyPair.publicKey.toString("hex").startsWith("03")) {
31
- newPrv = secp256k1_1.default.privateNegate(keyPair.privateKey);
32
- }
33
- const tweakedPrivateKey = secp256k1_1.default.privateAdd(newPrv, tapTweakHash(Buffer.from(keyPair.publicKey.toString("hex").slice(2), "hex"), opts === null || opts === void 0 ? void 0 : opts.tweakHash));
34
- if (!tweakedPrivateKey) {
35
- throw new Error("Invalid tweaked private key!");
36
- }
37
- return ECPair.fromPrivateKey(Buffer.from(tweakedPrivateKey), {
38
- network,
39
- });
40
- }
41
- class BitcoinLikeSignTransaction {
42
- constructor(network) {
43
- this.network = network;
44
- }
45
- signPsbt(unsignedPsbt, privateKey, sighashTypes, usingTweakSignerIfNeeded = true) {
46
- return __awaiter(this, void 0, void 0, function* () {
47
- const { network } = this;
48
- const keyPair = ECPair.fromPrivateKey(privateKey, {
49
- network,
50
- compressed: true,
51
- });
52
- const psbt = bitcoinjs_lib_1.Psbt.fromBase64(unsignedPsbt.unsignedTransaction, {
53
- network,
54
- });
55
- let numberOfInputs = psbt.inputCount;
56
- for (let i = 0; i < numberOfInputs; i += 1) {
57
- if (unsignedPsbt.inputsToSign && !unsignedPsbt.inputsToSign.includes(i)) {
58
- continue;
59
- }
60
- let type = psbt.getInputType(i);
61
- if (usingTweakSignerIfNeeded && type === "nonstandard") {
62
- console.log("using tweak signer");
63
- let a = tweakSigner(privateKey, this.network);
64
- yield psbt.signInputAsync(i, a, sighashTypes);
65
- }
66
- else {
67
- yield psbt.signInputAsync(i, keyPair, sighashTypes);
68
- }
69
- }
70
- const partialSigendPsbt = psbt.toBase64();
71
- return partialSigendPsbt;
72
- });
73
- }
74
- finalizePsbts(psbtsBase64 = []) {
75
- const finals = psbtsBase64.map((psbtBase64) => bitcoinjs_lib_1.Psbt.fromBase64(psbtBase64, { network: this.network }));
76
- const psbt = finals.length === 1 ? finals[0] : new bitcoinjs_lib_1.Psbt({ network: this.network }).combine(...finals);
77
- psbt.finalizeAllInputs();
78
- let finalizeTx = psbt.extractTransaction();
79
- return finalizeTx.toHex();
80
- }
81
- }
82
- exports.default = BitcoinLikeSignTransaction;
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
+ const bitcoinjs_lib_1 = require("bitcoinjs-lib");
16
+ const secp256k1_1 = __importDefault(require("@bitcoinerlab/secp256k1"));
17
+ const ecpair_1 = __importDefault(require("ecpair"));
18
+ const ECPair = (0, ecpair_1.default)(secp256k1_1.default);
19
+ function tapTweakHash(pubKey, h) {
20
+ return bitcoinjs_lib_1.crypto.taggedHash("TapTweak", Buffer.concat(h ? [pubKey, h] : [pubKey]));
21
+ }
22
+ function tweakSigner(privateKey, network, opts = {}) {
23
+ let newPrv = privateKey;
24
+ let keyPair = ECPair.fromPrivateKey(privateKey, {
25
+ network,
26
+ compressed: true,
27
+ });
28
+ if (!keyPair.privateKey)
29
+ throw new Error("private key not exist");
30
+ if (keyPair.publicKey.toString("hex").startsWith("03")) {
31
+ newPrv = secp256k1_1.default.privateNegate(keyPair.privateKey);
32
+ }
33
+ const tweakedPrivateKey = secp256k1_1.default.privateAdd(newPrv, tapTweakHash(Buffer.from(keyPair.publicKey.toString("hex").slice(2), "hex"), opts === null || opts === void 0 ? void 0 : opts.tweakHash));
34
+ if (!tweakedPrivateKey) {
35
+ throw new Error("Invalid tweaked private key!");
36
+ }
37
+ return ECPair.fromPrivateKey(Buffer.from(tweakedPrivateKey), {
38
+ network,
39
+ });
40
+ }
41
+ class BitcoinLikeSignTransaction {
42
+ constructor(network) {
43
+ this.network = network;
44
+ }
45
+ signPsbt(unsignedPsbt, privateKey, sighashTypes, usingTweakSignerIfNeeded = true) {
46
+ return __awaiter(this, void 0, void 0, function* () {
47
+ const { network } = this;
48
+ const keyPair = ECPair.fromPrivateKey(privateKey, {
49
+ network,
50
+ compressed: true,
51
+ });
52
+ const psbt = bitcoinjs_lib_1.Psbt.fromBase64(unsignedPsbt.unsignedTransaction, {
53
+ network,
54
+ });
55
+ let numberOfInputs = psbt.inputCount;
56
+ for (let i = 0; i < numberOfInputs; i += 1) {
57
+ if (unsignedPsbt.inputsToSign && !unsignedPsbt.inputsToSign.includes(i)) {
58
+ continue;
59
+ }
60
+ let type = psbt.getInputType(i);
61
+ if (usingTweakSignerIfNeeded && type === "nonstandard") {
62
+ console.log("using tweak signer");
63
+ let a = tweakSigner(privateKey, this.network);
64
+ yield psbt.signInputAsync(i, a, sighashTypes);
65
+ }
66
+ else {
67
+ yield psbt.signInputAsync(i, keyPair, sighashTypes);
68
+ }
69
+ }
70
+ const partialSigendPsbt = psbt.toBase64();
71
+ return partialSigendPsbt;
72
+ });
73
+ }
74
+ finalizePsbts(psbtsBase64 = []) {
75
+ const finals = psbtsBase64.map((psbtBase64) => bitcoinjs_lib_1.Psbt.fromBase64(psbtBase64, { network: this.network }));
76
+ const psbt = finals.length === 1 ? finals[0] : new bitcoinjs_lib_1.Psbt({ network: this.network }).combine(...finals);
77
+ psbt.finalizeAllInputs();
78
+ let finalizeTx = psbt.extractTransaction();
79
+ return finalizeTx.toHex();
80
+ }
81
+ }
82
+ exports.default = BitcoinLikeSignTransaction;
83
83
  //# sourceMappingURL=sign-transaction.js.map
@@ -1,46 +1,46 @@
1
- import type { ExtendedUtxo, SignerInfo } from "./transaction-builder/transaction-builder";
2
- import { BitcoinBaseWallet, FeeRateType } from "./bitcoin-wallet-base";
3
- export type TransferRequest = {
4
- changeAddress?: string;
5
- lockerAddress: string;
6
- amount: number;
7
- fullAmount?: boolean;
8
- chainId: number;
9
- appId: number;
10
- recipientAddress: string;
11
- percentageFee: number;
12
- speed?: number | boolean;
13
- isExchange?: boolean;
14
- exchangeTokenAddress?: string;
15
- outputAmount?: number;
16
- deadline?: number;
17
- isFixedToken?: boolean;
18
- feeSpeed?: "normal" | "fast" | "slow";
19
- staticFeeRate?: number;
20
- };
21
- export declare class TeleswapWallet extends BitcoinBaseWallet {
22
- wrap(recipientAddress: string, amount: string, networkFee: string, lockerAddress: string, chainId: number, exchange?: {
23
- outputToken: string;
24
- outputAmount: string;
25
- bridgePercentageFee?: number;
26
- }, appId?: number, fee?: FeeRateType, thirdPartyId?: number, staticExtendedUtxo?: ExtendedUtxo[], changeAddress?: string, fullAmount?: boolean): Promise<string>;
27
- wrapUnsigned(recipientAddress: string, amount: string, networkFee: string, lockerAddress: string, chainId: number, signer: SignerInfo, exchange?: {
28
- outputToken: string;
29
- outputAmount: string;
30
- bridgePercentageFee?: number;
31
- }, appId?: number, fee?: FeeRateType, thirdPartyId?: number, staticExtendedUtxo?: ExtendedUtxo[], changeAddress?: string, fullAmount?: boolean): Promise<{
32
- unsignedTransaction: string;
33
- outputs: import("./transaction-builder/transaction-builder").Target[];
34
- inputs: {
35
- hash: string;
36
- value: number;
37
- index: number;
38
- signerInfo: SignerInfo;
39
- }[];
40
- fee: number;
41
- change: import("./transaction-builder/transaction-builder").ChangeTarget | undefined;
42
- possibleTxId: string | undefined;
43
- }>;
44
- }
45
- export default TeleswapWallet;
1
+ import type { ExtendedUtxo, SignerInfo } from "./transaction-builder/transaction-builder";
2
+ import { BitcoinBaseWallet, FeeRateType } from "./bitcoin-wallet-base";
3
+ export type TransferRequest = {
4
+ changeAddress?: string;
5
+ lockerAddress: string;
6
+ amount: number;
7
+ fullAmount?: boolean;
8
+ chainId: number;
9
+ appId: number;
10
+ recipientAddress: string;
11
+ percentageFee: number;
12
+ speed?: number | boolean;
13
+ isExchange?: boolean;
14
+ exchangeTokenAddress?: string;
15
+ outputAmount?: number;
16
+ deadline?: number;
17
+ isFixedToken?: boolean;
18
+ feeSpeed?: "normal" | "fast" | "slow";
19
+ staticFeeRate?: number;
20
+ };
21
+ export declare class TeleswapWallet extends BitcoinBaseWallet {
22
+ wrap(recipientAddress: string, amount: string, networkFee: string, lockerAddress: string, chainId: number, exchange?: {
23
+ outputToken: string;
24
+ outputAmount: string;
25
+ bridgePercentageFee?: number;
26
+ }, appId?: number, fee?: FeeRateType, thirdPartyId?: number, staticExtendedUtxo?: ExtendedUtxo[], changeAddress?: string, fullAmount?: boolean): Promise<string>;
27
+ wrapUnsigned(recipientAddress: string, amount: string, networkFee: string, lockerAddress: string, chainId: number, signer: SignerInfo, exchange?: {
28
+ outputToken: string;
29
+ outputAmount: string;
30
+ bridgePercentageFee?: number;
31
+ }, appId?: number, fee?: FeeRateType, thirdPartyId?: number, staticExtendedUtxo?: ExtendedUtxo[], changeAddress?: string, fullAmount?: boolean): Promise<{
32
+ unsignedTransaction: string;
33
+ outputs: import("./transaction-builder/transaction-builder").Target[];
34
+ inputs: {
35
+ hash: string;
36
+ value: number;
37
+ index: number;
38
+ signerInfo: SignerInfo;
39
+ }[];
40
+ fee: number;
41
+ change: import("./transaction-builder/transaction-builder").ChangeTarget | undefined;
42
+ possibleTxId: string | undefined;
43
+ }>;
44
+ }
45
+ export default TeleswapWallet;
46
46
  //# sourceMappingURL=teleswap-wallet.d.ts.map
@@ -1,69 +1,69 @@
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
- Object.defineProperty(exports, "__esModule", { value: true });
12
- exports.TeleswapWallet = void 0;
13
- const configs_1 = require("@teleportdao/configs");
14
- const bitcoin_wallet_base_1 = require("./bitcoin-wallet-base");
15
- const teleswap_helper_1 = require("./helper/teleswap-helper");
16
- class TeleswapWallet extends bitcoin_wallet_base_1.BitcoinBaseWallet {
17
- wrap(recipientAddress, amount, networkFee, lockerAddress, chainId, exchange, appId = exchange
18
- ? configs_1.teleswap.requestAppId.WrapAndSwap.default
19
- : configs_1.teleswap.requestAppId.Wrap.default, fee = "normal", thirdPartyId, staticExtendedUtxo, changeAddress, fullAmount = false) {
20
- return __awaiter(this, void 0, void 0, function* () {
21
- if (!this.signerInfo || !this.privateKey) {
22
- throw new Error("account not initialized");
23
- }
24
- let unsignedTransaction = yield this.wrapUnsigned(recipientAddress, amount, networkFee, lockerAddress, chainId, this.signerInfo, exchange, appId, fee, thirdPartyId, staticExtendedUtxo, changeAddress, fullAmount);
25
- let signedPsbt = yield this.signer.signPsbt(unsignedTransaction, this.privateKey);
26
- return this.sendSignedPsbt(signedPsbt);
27
- });
28
- }
29
- wrapUnsigned(recipientAddress, amount, networkFee, lockerAddress, chainId, signer, exchange, appId = exchange
30
- ? configs_1.teleswap.requestAppId.WrapAndSwap.default
31
- : configs_1.teleswap.requestAppId.Wrap.default, fee = "normal", thirdPartyId, staticExtendedUtxo, changeAddress, fullAmount = false) {
32
- return __awaiter(this, void 0, void 0, function* () {
33
- const dataHex = (0, teleswap_helper_1.generateWrapOpReturn)({
34
- chainId,
35
- appId,
36
- recipientAddress,
37
- networkFee,
38
- speed: false,
39
- isExchange: !!exchange,
40
- outputAmount: exchange === null || exchange === void 0 ? void 0 : exchange.outputAmount,
41
- outputToken: exchange === null || exchange === void 0 ? void 0 : exchange.outputToken,
42
- bridgePercentageFee: exchange === null || exchange === void 0 ? void 0 : exchange.bridgePercentageFee,
43
- thirdPartyId,
44
- });
45
- let extendedUtxo = staticExtendedUtxo || (yield this.getExtendedUtxo(signer));
46
- let feeRate = yield this.getFeeRate(fee);
47
- const targets = fullAmount
48
- ? [this.transactionBuilder.getOpReturnTarget(dataHex)]
49
- : [
50
- {
51
- address: lockerAddress,
52
- value: +amount,
53
- },
54
- this.transactionBuilder.getOpReturnTarget(dataHex),
55
- ];
56
- const unsignedTx = this.transactionBuilder.processUnsignedTransaction({
57
- extendedUtxo,
58
- feeRate,
59
- targets,
60
- changeAddress: changeAddress || signer.address,
61
- fullAmount,
62
- });
63
- return unsignedTx;
64
- });
65
- }
66
- }
67
- exports.TeleswapWallet = TeleswapWallet;
68
- exports.default = TeleswapWallet;
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
+ Object.defineProperty(exports, "__esModule", { value: true });
12
+ exports.TeleswapWallet = void 0;
13
+ const configs_1 = require("@teleportdao/configs");
14
+ const bitcoin_wallet_base_1 = require("./bitcoin-wallet-base");
15
+ const teleswap_helper_1 = require("./helper/teleswap-helper");
16
+ class TeleswapWallet extends bitcoin_wallet_base_1.BitcoinBaseWallet {
17
+ wrap(recipientAddress, amount, networkFee, lockerAddress, chainId, exchange, appId = exchange
18
+ ? configs_1.teleswap.requestAppId.WrapAndSwap.default
19
+ : configs_1.teleswap.requestAppId.Wrap.default, fee = "normal", thirdPartyId, staticExtendedUtxo, changeAddress, fullAmount = false) {
20
+ return __awaiter(this, void 0, void 0, function* () {
21
+ if (!this.signerInfo || !this.privateKey) {
22
+ throw new Error("account not initialized");
23
+ }
24
+ let unsignedTransaction = yield this.wrapUnsigned(recipientAddress, amount, networkFee, lockerAddress, chainId, this.signerInfo, exchange, appId, fee, thirdPartyId, staticExtendedUtxo, changeAddress, fullAmount);
25
+ let signedPsbt = yield this.signer.signPsbt(unsignedTransaction, this.privateKey);
26
+ return this.sendSignedPsbt(signedPsbt);
27
+ });
28
+ }
29
+ wrapUnsigned(recipientAddress, amount, networkFee, lockerAddress, chainId, signer, exchange, appId = exchange
30
+ ? configs_1.teleswap.requestAppId.WrapAndSwap.default
31
+ : configs_1.teleswap.requestAppId.Wrap.default, fee = "normal", thirdPartyId, staticExtendedUtxo, changeAddress, fullAmount = false) {
32
+ return __awaiter(this, void 0, void 0, function* () {
33
+ const dataHex = (0, teleswap_helper_1.generateWrapOpReturn)({
34
+ chainId,
35
+ appId,
36
+ recipientAddress,
37
+ networkFee,
38
+ speed: false,
39
+ isExchange: !!exchange,
40
+ outputAmount: exchange === null || exchange === void 0 ? void 0 : exchange.outputAmount,
41
+ outputToken: exchange === null || exchange === void 0 ? void 0 : exchange.outputToken,
42
+ bridgePercentageFee: exchange === null || exchange === void 0 ? void 0 : exchange.bridgePercentageFee,
43
+ thirdPartyId,
44
+ });
45
+ let extendedUtxo = staticExtendedUtxo || (yield this.getExtendedUtxo(signer));
46
+ let feeRate = yield this.getFeeRate(fee);
47
+ const targets = fullAmount
48
+ ? [this.transactionBuilder.getOpReturnTarget(dataHex)]
49
+ : [
50
+ {
51
+ address: lockerAddress,
52
+ value: +amount,
53
+ },
54
+ this.transactionBuilder.getOpReturnTarget(dataHex),
55
+ ];
56
+ const unsignedTx = this.transactionBuilder.processUnsignedTransaction({
57
+ extendedUtxo,
58
+ feeRate,
59
+ targets,
60
+ changeAddress: changeAddress || signer.address,
61
+ fullAmount,
62
+ });
63
+ return unsignedTx;
64
+ });
65
+ }
66
+ }
67
+ exports.TeleswapWallet = TeleswapWallet;
68
+ exports.default = TeleswapWallet;
69
69
  //# sourceMappingURL=teleswap-wallet.js.map
@@ -1,10 +1,10 @@
1
- import * as bitcoin from "bitcoinjs-lib";
2
- import { BaseTransactionBuilder } from "./transaction-builder";
3
- import { BitcoinInterfaceWallet } from "../bitcoin-interface-wallet";
4
- import { BitcoinInterfaceConnectionInfo } from "../type";
5
- export declare class BitcoinTransactionBuilder extends BaseTransactionBuilder {
6
- btcInterface: BitcoinInterfaceWallet;
7
- constructor(networkName: string, network?: bitcoin.networks.Network, connectionInfo?: BitcoinInterfaceConnectionInfo);
8
- _getTransactionHex(transactionId: string): Promise<string>;
9
- }
1
+ import * as bitcoin from "bitcoinjs-lib";
2
+ import { BaseTransactionBuilder } from "./transaction-builder";
3
+ import { BitcoinInterfaceWallet } from "../bitcoin-interface-wallet";
4
+ import { BitcoinInterfaceConnectionInfo } from "../type";
5
+ export declare class BitcoinTransactionBuilder extends BaseTransactionBuilder {
6
+ btcInterface: BitcoinInterfaceWallet;
7
+ constructor(networkName: string, network?: bitcoin.networks.Network, connectionInfo?: BitcoinInterfaceConnectionInfo);
8
+ _getTransactionHex(transactionId: string): Promise<string>;
9
+ }
10
10
  //# sourceMappingURL=bitcoin-transaction-builder.d.ts.map
@@ -1,55 +1,55 @@
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
- Object.defineProperty(exports, "__esModule", { value: true });
35
- exports.BitcoinTransactionBuilder = void 0;
36
- const bitcoin = __importStar(require("bitcoinjs-lib"));
37
- const transaction_builder_1 = require("./transaction-builder");
38
- const bitcoin_interface_1 = require("../bitcoin-interface");
39
- class BitcoinTransactionBuilder extends transaction_builder_1.BaseTransactionBuilder {
40
- constructor(networkName, network = bitcoin.networks.bitcoin, connectionInfo) {
41
- super({
42
- network,
43
- testnet: networkName === null || networkName === void 0 ? void 0 : networkName.includes("_testnet"),
44
- dustLimit: 1000,
45
- });
46
- this.btcInterface = new bitcoin_interface_1.BitcoinInterface(networkName, connectionInfo);
47
- }
48
- _getTransactionHex(transactionId) {
49
- return __awaiter(this, void 0, void 0, function* () {
50
- return this.btcInterface.getRawTransaction(transactionId);
51
- });
52
- }
53
- }
54
- exports.BitcoinTransactionBuilder = BitcoinTransactionBuilder;
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
+ Object.defineProperty(exports, "__esModule", { value: true });
35
+ exports.BitcoinTransactionBuilder = void 0;
36
+ const bitcoin = __importStar(require("bitcoinjs-lib"));
37
+ const transaction_builder_1 = require("./transaction-builder");
38
+ const bitcoin_interface_1 = require("../bitcoin-interface");
39
+ class BitcoinTransactionBuilder extends transaction_builder_1.BaseTransactionBuilder {
40
+ constructor(networkName, network = bitcoin.networks.bitcoin, connectionInfo) {
41
+ super({
42
+ network,
43
+ testnet: networkName === null || networkName === void 0 ? void 0 : networkName.includes("_testnet"),
44
+ dustLimit: 1000,
45
+ });
46
+ this.btcInterface = new bitcoin_interface_1.BitcoinInterface(networkName, connectionInfo);
47
+ }
48
+ _getTransactionHex(transactionId) {
49
+ return __awaiter(this, void 0, void 0, function* () {
50
+ return this.btcInterface.getRawTransaction(transactionId);
51
+ });
52
+ }
53
+ }
54
+ exports.BitcoinTransactionBuilder = BitcoinTransactionBuilder;
55
55
  //# sourceMappingURL=bitcoin-transaction-builder.js.map
@@ -1,4 +1,4 @@
1
- export * from "./bitcoin-transaction-builder";
2
- export * from "./ordinal-transaction-builder";
3
- export * from "./transaction-builder";
1
+ export * from "./bitcoin-transaction-builder";
2
+ export * from "./ordinal-transaction-builder";
3
+ export * from "./transaction-builder";
4
4
  //# sourceMappingURL=index.d.ts.map
@@ -1,20 +1,20 @@
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 __exportStar = (this && this.__exportStar) || function(m, exports) {
14
- for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
15
- };
16
- Object.defineProperty(exports, "__esModule", { value: true });
17
- __exportStar(require("./bitcoin-transaction-builder"), exports);
18
- __exportStar(require("./ordinal-transaction-builder"), exports);
19
- __exportStar(require("./transaction-builder"), exports);
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 __exportStar = (this && this.__exportStar) || function(m, exports) {
14
+ for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
15
+ };
16
+ Object.defineProperty(exports, "__esModule", { value: true });
17
+ __exportStar(require("./bitcoin-transaction-builder"), exports);
18
+ __exportStar(require("./ordinal-transaction-builder"), exports);
19
+ __exportStar(require("./transaction-builder"), exports);
20
20
  //# sourceMappingURL=index.js.map