@teleportdao/bitcoin 2.0.5 → 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 (76) 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.js +176 -176
  5. package/dist/bitcoin-interface-utils.d.ts +20 -20
  6. package/dist/bitcoin-interface-utils.js +45 -45
  7. package/dist/bitcoin-interface-wallet.d.ts +28 -28
  8. package/dist/bitcoin-interface-wallet.js +125 -125
  9. package/dist/bitcoin-interface.d.ts +66 -66
  10. package/dist/bitcoin-interface.js +119 -119
  11. package/dist/bitcoin-utils.d.ts +96 -96
  12. package/dist/bitcoin-utils.js +514 -514
  13. package/dist/bitcoin-wallet-base.d.ts +111 -111
  14. package/dist/bitcoin-wallet-base.js +258 -258
  15. package/dist/helper/brc20-helper.d.ts +42 -42
  16. package/dist/helper/brc20-helper.js +127 -127
  17. package/dist/helper/index.d.ts +3 -3
  18. package/dist/helper/index.js +29 -29
  19. package/dist/helper/ordinal-helper.d.ts +12 -12
  20. package/dist/helper/ordinal-helper.js +129 -129
  21. package/dist/helper/teleswap-helper.d.ts +95 -95
  22. package/dist/helper/teleswap-helper.js +186 -186
  23. package/dist/index.d.ts +12 -12
  24. package/dist/index.js +41 -41
  25. package/dist/ordinal-wallet.d.ts +495 -495
  26. package/dist/ordinal-wallet.js +386 -386
  27. package/dist/sign/index.d.ts +1 -1
  28. package/dist/sign/index.js +8 -8
  29. package/dist/sign/sign-transaction.d.ts +12 -12
  30. package/dist/sign/sign-transaction.js +82 -82
  31. package/dist/teleswap-wallet.d.ts +45 -45
  32. package/dist/teleswap-wallet.js +68 -68
  33. package/dist/transaction-builder/bitcoin-transaction-builder.d.ts +9 -9
  34. package/dist/transaction-builder/bitcoin-transaction-builder.js +54 -54
  35. package/dist/transaction-builder/index.d.ts +3 -3
  36. package/dist/transaction-builder/index.js +19 -19
  37. package/dist/transaction-builder/ordinal-transaction-builder.d.ts +63 -63
  38. package/dist/transaction-builder/ordinal-transaction-builder.js +125 -125
  39. package/dist/transaction-builder/transaction-builder.d.ts +223 -223
  40. package/dist/transaction-builder/transaction-builder.js +447 -447
  41. package/dist/type.d.ts +61 -61
  42. package/dist/type.js +2 -2
  43. package/dist/utils/networks.d.ts +5 -5
  44. package/dist/utils/networks.js +53 -53
  45. package/dist/utils/tools.d.ts +18 -18
  46. package/dist/utils/tools.js +74 -74
  47. package/package.json +4 -4
  48. package/src/bitcoin-interface-ordinal.ts +185 -185
  49. package/src/bitcoin-interface-teleswap.ts +251 -251
  50. package/src/bitcoin-interface-utils.ts +60 -60
  51. package/src/bitcoin-interface-wallet.ts +114 -114
  52. package/src/bitcoin-interface.ts +156 -156
  53. package/src/bitcoin-utils.ts +591 -591
  54. package/src/bitcoin-wallet-base.ts +344 -344
  55. package/src/helper/brc20-helper.ts +179 -179
  56. package/src/helper/ordinal-helper.ts +118 -118
  57. package/src/index.ts +15 -15
  58. package/src/ordinal-wallet.ts +659 -659
  59. package/src/sign/index.ts +1 -1
  60. package/src/sign/sign-transaction.ts +108 -108
  61. package/src/teleswap-wallet.ts +133 -133
  62. package/src/transaction-builder/bitcoin-transaction-builder.ts +26 -26
  63. package/src/transaction-builder/index.ts +3 -3
  64. package/src/transaction-builder/ordinal-transaction-builder.ts +139 -139
  65. package/src/transaction-builder/transaction-builder.ts +690 -690
  66. package/src/type.ts +74 -74
  67. package/src/utils/networks.ts +33 -33
  68. package/src/utils/tools.ts +92 -92
  69. package/tsconfig.json +9 -9
  70. package/webpack.config.js +16 -16
  71. package/.tmp/block-parser.ts +0 -58
  72. package/.tmp/check.ts +0 -101
  73. package/.tmp/ordinal-helper.ts +0 -133
  74. package/.tmp/ordinal.ts +0 -25
  75. package/.tmp/psbt/sign-transaction.ts +0 -121
  76. package/.tmp/rbf.ts +0 -45
@@ -1,64 +1,64 @@
1
- /// <reference types="node" />
2
- import { BitcoinTransactionBuilder } from "./bitcoin-transaction-builder";
3
- import { ExtendedUtxo, Target } from "./transaction-builder";
4
- export declare class OrdinalTransactionBuilder extends BitcoinTransactionBuilder {
5
- createNftPsbt({ extendedUtxo, nftExtendedUtxo, receiverAddress, feeRate, changeAddress, otherTargets, }: {
6
- nftExtendedUtxo: ExtendedUtxo;
7
- extendedUtxo: ExtendedUtxo[];
8
- feeRate: number;
9
- changeAddress: string;
10
- receiverAddress: string;
11
- otherTargets?: Target[];
12
- }): Promise<{
13
- unsignedTransaction: string;
14
- outputs: Target[];
15
- inputs: {
16
- hash: string;
17
- value: number;
18
- index: number;
19
- signerInfo: import("./transaction-builder").SignerInfo;
20
- }[];
21
- fee: number;
22
- change: import("./transaction-builder").ChangeTarget | undefined;
23
- possibleTxId: string | undefined;
24
- }>;
25
- createOrdinalAddress(file: {
26
- buffer: Buffer;
27
- type: string;
28
- }, publicKey: Buffer): {
29
- ordinalAddress: string;
30
- ordinalScript: Buffer;
31
- redeem: {
32
- output: Buffer;
33
- redeemVersion: number;
34
- };
35
- controlBlock: Buffer;
36
- };
37
- createInscribeUnsignedTx(ordinalSpendDetails: {
38
- ordinalAddress: string;
39
- ordinalScript: Buffer;
40
- redeem: {
41
- output: Buffer;
42
- redeemVersion: number;
43
- };
44
- controlBlock: Buffer;
45
- }, inscribeDeposit: {
46
- hash: string;
47
- index: number;
48
- value: number;
49
- }, receiverAddress: string, ordinalAmount?: number): {
50
- unsignedTransaction: string;
51
- inputs: {
52
- hash: string;
53
- index: number;
54
- value: number;
55
- }[];
56
- outputs: {
57
- value: number;
58
- address: string;
59
- }[];
60
- fee: number;
61
- possibleTxId: string;
62
- };
63
- }
1
+ /// <reference types="node" />
2
+ import { BitcoinTransactionBuilder } from "./bitcoin-transaction-builder";
3
+ import { ExtendedUtxo, Target } from "./transaction-builder";
4
+ export declare class OrdinalTransactionBuilder extends BitcoinTransactionBuilder {
5
+ createNftPsbt({ extendedUtxo, nftExtendedUtxo, receiverAddress, feeRate, changeAddress, otherTargets, }: {
6
+ nftExtendedUtxo: ExtendedUtxo;
7
+ extendedUtxo: ExtendedUtxo[];
8
+ feeRate: number;
9
+ changeAddress: string;
10
+ receiverAddress: string;
11
+ otherTargets?: Target[];
12
+ }): Promise<{
13
+ unsignedTransaction: string;
14
+ outputs: Target[];
15
+ inputs: {
16
+ hash: string;
17
+ value: number;
18
+ index: number;
19
+ signerInfo: import("./transaction-builder").SignerInfo;
20
+ }[];
21
+ fee: number;
22
+ change: import("./transaction-builder").ChangeTarget | undefined;
23
+ possibleTxId: string | undefined;
24
+ }>;
25
+ createOrdinalAddress(file: {
26
+ buffer: Buffer;
27
+ type: string;
28
+ }, publicKey: Buffer): {
29
+ ordinalAddress: string;
30
+ ordinalScript: Buffer;
31
+ redeem: {
32
+ output: Buffer;
33
+ redeemVersion: number;
34
+ };
35
+ controlBlock: Buffer;
36
+ };
37
+ createInscribeUnsignedTx(ordinalSpendDetails: {
38
+ ordinalAddress: string;
39
+ ordinalScript: Buffer;
40
+ redeem: {
41
+ output: Buffer;
42
+ redeemVersion: number;
43
+ };
44
+ controlBlock: Buffer;
45
+ }, inscribeDeposit: {
46
+ hash: string;
47
+ index: number;
48
+ value: number;
49
+ }, receiverAddress: string, ordinalAmount?: number): {
50
+ unsignedTransaction: string;
51
+ inputs: {
52
+ hash: string;
53
+ index: number;
54
+ value: number;
55
+ }[];
56
+ outputs: {
57
+ value: number;
58
+ address: string;
59
+ }[];
60
+ fee: number;
61
+ possibleTxId: string;
62
+ };
63
+ }
64
64
  //# sourceMappingURL=ordinal-transaction-builder.d.ts.map
@@ -1,126 +1,126 @@
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.OrdinalTransactionBuilder = void 0;
36
- const bitcoin = __importStar(require("bitcoinjs-lib"));
37
- const bip341_1 = require("bitcoinjs-lib/src/payments/bip341");
38
- const bitcoin_transaction_builder_1 = require("./bitcoin-transaction-builder");
39
- const ordinal_helper_1 = require("../helper/ordinal-helper");
40
- class OrdinalTransactionBuilder extends bitcoin_transaction_builder_1.BitcoinTransactionBuilder {
41
- createNftPsbt({ extendedUtxo, nftExtendedUtxo, receiverAddress, feeRate, changeAddress, otherTargets, }) {
42
- return __awaiter(this, void 0, void 0, function* () {
43
- let targets = [
44
- {
45
- address: receiverAddress,
46
- value: nftExtendedUtxo.value,
47
- },
48
- ];
49
- if (otherTargets)
50
- targets.push(...otherTargets);
51
- if (!changeAddress && targets.length === 0)
52
- throw new Error("no target");
53
- let changeObject = {
54
- address: changeAddress,
55
- };
56
- let { inputs, outputs, change, fee } = yield this.filterAndConvertTxDataToStandardFormat({
57
- extendedUtxo: [nftExtendedUtxo, ...extendedUtxo],
58
- targets,
59
- changeObject,
60
- feeRate,
61
- selectType: "inOrder",
62
- });
63
- let unsignedTx = this.createUnsignedTransaction({
64
- inputs,
65
- outputs,
66
- change,
67
- fee,
68
- feeRate,
69
- });
70
- return unsignedTx;
71
- });
72
- }
73
- createOrdinalAddress(file, publicKey) {
74
- const internalPublicKey = (0, ordinal_helper_1.toXOnly)(publicKey).toString("hex");
75
- let leafScript = (0, ordinal_helper_1.getOrdinalScript)(file, internalPublicKey);
76
- const scriptTree = {
77
- output: leafScript,
78
- };
79
- const redeem = {
80
- output: leafScript,
81
- redeemVersion: bip341_1.LEAF_VERSION_TAPSCRIPT,
82
- };
83
- const p2trTapOrdinalScript = bitcoin.payments.p2tr({
84
- internalPubkey: Buffer.from(internalPublicKey, "hex"),
85
- scriptTree,
86
- network: this.network,
87
- redeem,
88
- });
89
- let ordinalAddress = p2trTapOrdinalScript.address;
90
- const controlBlock = p2trTapOrdinalScript.witness[p2trTapOrdinalScript.witness.length - 1];
91
- return {
92
- ordinalAddress,
93
- ordinalScript: p2trTapOrdinalScript.output,
94
- redeem,
95
- controlBlock,
96
- };
97
- }
98
- createInscribeUnsignedTx(ordinalSpendDetails, inscribeDeposit, receiverAddress, ordinalAmount = 600) {
99
- const psbt = new bitcoin.Psbt({ network: this.network })
100
- .addInput(Object.assign(Object.assign({}, inscribeDeposit), { witnessUtxo: { value: inscribeDeposit.value, script: ordinalSpendDetails.ordinalScript }, tapLeafScript: [
101
- {
102
- leafVersion: ordinalSpendDetails.redeem.redeemVersion,
103
- script: ordinalSpendDetails.redeem.output,
104
- controlBlock: ordinalSpendDetails.controlBlock,
105
- },
106
- ] }))
107
- .addOutput({
108
- value: ordinalAmount,
109
- address: receiverAddress,
110
- });
111
- return {
112
- unsignedTransaction: psbt.toBase64(),
113
- inputs: [inscribeDeposit],
114
- outputs: [
115
- {
116
- value: ordinalAmount,
117
- address: receiverAddress,
118
- },
119
- ],
120
- fee: inscribeDeposit.value - ordinalAmount,
121
- possibleTxId: this.getUnsignedPsbtTxId(psbt.toBase64()),
122
- };
123
- }
124
- }
125
- exports.OrdinalTransactionBuilder = OrdinalTransactionBuilder;
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.OrdinalTransactionBuilder = void 0;
36
+ const bitcoin = __importStar(require("bitcoinjs-lib"));
37
+ const bip341_1 = require("bitcoinjs-lib/src/payments/bip341");
38
+ const bitcoin_transaction_builder_1 = require("./bitcoin-transaction-builder");
39
+ const ordinal_helper_1 = require("../helper/ordinal-helper");
40
+ class OrdinalTransactionBuilder extends bitcoin_transaction_builder_1.BitcoinTransactionBuilder {
41
+ createNftPsbt({ extendedUtxo, nftExtendedUtxo, receiverAddress, feeRate, changeAddress, otherTargets, }) {
42
+ return __awaiter(this, void 0, void 0, function* () {
43
+ let targets = [
44
+ {
45
+ address: receiverAddress,
46
+ value: nftExtendedUtxo.value,
47
+ },
48
+ ];
49
+ if (otherTargets)
50
+ targets.push(...otherTargets);
51
+ if (!changeAddress && targets.length === 0)
52
+ throw new Error("no target");
53
+ let changeObject = {
54
+ address: changeAddress,
55
+ };
56
+ let { inputs, outputs, change, fee } = yield this.filterAndConvertTxDataToStandardFormat({
57
+ extendedUtxo: [nftExtendedUtxo, ...extendedUtxo],
58
+ targets,
59
+ changeObject,
60
+ feeRate,
61
+ selectType: "inOrder",
62
+ });
63
+ let unsignedTx = this.createUnsignedTransaction({
64
+ inputs,
65
+ outputs,
66
+ change,
67
+ fee,
68
+ feeRate,
69
+ });
70
+ return unsignedTx;
71
+ });
72
+ }
73
+ createOrdinalAddress(file, publicKey) {
74
+ const internalPublicKey = (0, ordinal_helper_1.toXOnly)(publicKey).toString("hex");
75
+ let leafScript = (0, ordinal_helper_1.getOrdinalScript)(file, internalPublicKey);
76
+ const scriptTree = {
77
+ output: leafScript,
78
+ };
79
+ const redeem = {
80
+ output: leafScript,
81
+ redeemVersion: bip341_1.LEAF_VERSION_TAPSCRIPT,
82
+ };
83
+ const p2trTapOrdinalScript = bitcoin.payments.p2tr({
84
+ internalPubkey: Buffer.from(internalPublicKey, "hex"),
85
+ scriptTree,
86
+ network: this.network,
87
+ redeem,
88
+ });
89
+ let ordinalAddress = p2trTapOrdinalScript.address;
90
+ const controlBlock = p2trTapOrdinalScript.witness[p2trTapOrdinalScript.witness.length - 1];
91
+ return {
92
+ ordinalAddress,
93
+ ordinalScript: p2trTapOrdinalScript.output,
94
+ redeem,
95
+ controlBlock,
96
+ };
97
+ }
98
+ createInscribeUnsignedTx(ordinalSpendDetails, inscribeDeposit, receiverAddress, ordinalAmount = 600) {
99
+ const psbt = new bitcoin.Psbt({ network: this.network })
100
+ .addInput(Object.assign(Object.assign({}, inscribeDeposit), { witnessUtxo: { value: inscribeDeposit.value, script: ordinalSpendDetails.ordinalScript }, tapLeafScript: [
101
+ {
102
+ leafVersion: ordinalSpendDetails.redeem.redeemVersion,
103
+ script: ordinalSpendDetails.redeem.output,
104
+ controlBlock: ordinalSpendDetails.controlBlock,
105
+ },
106
+ ] }))
107
+ .addOutput({
108
+ value: ordinalAmount,
109
+ address: receiverAddress,
110
+ });
111
+ return {
112
+ unsignedTransaction: psbt.toBase64(),
113
+ inputs: [inscribeDeposit],
114
+ outputs: [
115
+ {
116
+ value: ordinalAmount,
117
+ address: receiverAddress,
118
+ },
119
+ ],
120
+ fee: inscribeDeposit.value - ordinalAmount,
121
+ possibleTxId: this.getUnsignedPsbtTxId(psbt.toBase64()),
122
+ };
123
+ }
124
+ }
125
+ exports.OrdinalTransactionBuilder = OrdinalTransactionBuilder;
126
126
  //# sourceMappingURL=ordinal-transaction-builder.js.map