@btc-vision/transaction 1.7.19 → 1.7.23

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 (139) hide show
  1. package/.babelrc +10 -1
  2. package/LICENSE +190 -21
  3. package/README.md +1 -1
  4. package/browser/_version.d.ts +1 -1
  5. package/browser/bip39.js +204 -0
  6. package/browser/bitcoin-utils.js +3172 -0
  7. package/browser/btc-vision-bip32.js +805 -0
  8. package/browser/btc-vision-bitcoin.js +4179 -0
  9. package/browser/btc-vision-logger.js +273 -0
  10. package/browser/btc-vision-post-quantum.js +542 -0
  11. package/browser/chain/ChainData.d.ts +1 -1
  12. package/browser/crypto/crypto.d.ts +1 -1
  13. package/browser/generators/AddressGenerator.d.ts +1 -1
  14. package/browser/generators/Generator.d.ts +1 -1
  15. package/browser/generators/MLDSAData.d.ts +1 -1
  16. package/browser/generators/builders/CalldataGenerator.d.ts +1 -1
  17. package/browser/generators/builders/CustomGenerator.d.ts +1 -1
  18. package/browser/generators/builders/DeploymentGenerator.d.ts +1 -1
  19. package/browser/generators/builders/HashCommitmentGenerator.d.ts +49 -0
  20. package/browser/generators/builders/LegacyCalldataGenerator.d.ts +1 -1
  21. package/browser/generators/builders/P2WDAGenerator.d.ts +1 -1
  22. package/browser/index.js +10775 -2
  23. package/browser/keypair/Address.d.ts +5 -3
  24. package/browser/keypair/AddressVerificator.d.ts +2 -2
  25. package/browser/keypair/EcKeyPair.d.ts +2 -2
  26. package/browser/keypair/MessageSigner.d.ts +2 -2
  27. package/browser/keypair/Wallet.d.ts +2 -2
  28. package/browser/metadata/ContractBaseMetadata.d.ts +1 -1
  29. package/browser/mnemonic/Mnemonic.d.ts +2 -2
  30. package/browser/noble-curves.js +3316 -0
  31. package/browser/noble-hashes.js +1608 -0
  32. package/browser/opnet.d.ts +15 -2
  33. package/browser/p2wda/P2WDADetector.d.ts +2 -2
  34. package/browser/polyfills.js +4590 -0
  35. package/browser/scure-base.js +410 -0
  36. package/browser/signer/AddressRotation.d.ts +12 -0
  37. package/browser/signer/SignerUtils.d.ts +1 -1
  38. package/browser/signer/TweakedSigner.d.ts +1 -1
  39. package/browser/transaction/TransactionFactory.d.ts +15 -1
  40. package/browser/transaction/browser/BrowserSignerBase.d.ts +1 -1
  41. package/browser/transaction/browser/Web3Provider.d.ts +1 -1
  42. package/browser/transaction/browser/extensions/UnisatSigner.d.ts +1 -1
  43. package/browser/transaction/browser/extensions/XverseSigner.d.ts +1 -1
  44. package/browser/transaction/builders/CancelTransaction.d.ts +1 -1
  45. package/browser/transaction/builders/ConsolidatedInteractionTransaction.d.ts +44 -0
  46. package/browser/transaction/builders/CustomScriptTransaction.d.ts +1 -1
  47. package/browser/transaction/builders/DeploymentTransaction.d.ts +1 -1
  48. package/browser/transaction/builders/FundingTransaction.d.ts +1 -1
  49. package/browser/transaction/builders/InteractionTransaction.d.ts +1 -1
  50. package/browser/transaction/builders/InteractionTransactionP2WDA.d.ts +2 -2
  51. package/browser/transaction/builders/MultiSignTransaction.d.ts +1 -1
  52. package/browser/transaction/builders/SharedInteractionTransaction.d.ts +1 -1
  53. package/browser/transaction/builders/TransactionBuilder.d.ts +1 -1
  54. package/browser/transaction/enums/TransactionType.d.ts +3 -1
  55. package/browser/transaction/interfaces/IConsolidatedTransactionParameters.d.ts +31 -0
  56. package/browser/transaction/interfaces/ITransactionParameters.d.ts +3 -1
  57. package/browser/transaction/interfaces/Tap.d.ts +1 -1
  58. package/browser/transaction/mineable/TimelockGenerator.d.ts +1 -1
  59. package/browser/transaction/offline/OfflineTransactionManager.d.ts +69 -0
  60. package/browser/transaction/offline/TransactionReconstructor.d.ts +28 -0
  61. package/browser/transaction/offline/TransactionSerializer.d.ts +50 -0
  62. package/browser/transaction/offline/TransactionStateCapture.d.ts +52 -0
  63. package/browser/transaction/offline/interfaces/ISerializableState.d.ts +62 -0
  64. package/browser/transaction/offline/interfaces/ITypeSpecificData.d.ts +62 -0
  65. package/browser/transaction/processor/PsbtTransaction.d.ts +1 -1
  66. package/browser/transaction/shared/P2TR_MS.d.ts +1 -1
  67. package/browser/transaction/shared/TweakedTransaction.d.ts +15 -4
  68. package/browser/utxo/OPNetLimitedProvider.d.ts +1 -1
  69. package/browser/utxo/interfaces/IUTXO.d.ts +2 -0
  70. package/browser/valibot.js +4948 -0
  71. package/browser/vendors.js +12913 -0
  72. package/browser/verification/TapscriptVerificator.d.ts +1 -1
  73. package/build/_version.d.ts +1 -1
  74. package/build/_version.js +1 -1
  75. package/build/generators/builders/HashCommitmentGenerator.d.ts +49 -0
  76. package/build/generators/builders/HashCommitmentGenerator.js +229 -0
  77. package/build/keypair/Address.d.ts +3 -1
  78. package/build/keypair/Address.js +87 -54
  79. package/build/opnet.d.ts +14 -1
  80. package/build/opnet.js +11 -1
  81. package/build/signer/AddressRotation.d.ts +12 -0
  82. package/build/signer/AddressRotation.js +16 -0
  83. package/build/transaction/TransactionFactory.d.ts +14 -0
  84. package/build/transaction/TransactionFactory.js +36 -0
  85. package/build/transaction/builders/ConsolidatedInteractionTransaction.d.ts +44 -0
  86. package/build/transaction/builders/ConsolidatedInteractionTransaction.js +259 -0
  87. package/build/transaction/builders/TransactionBuilder.js +2 -0
  88. package/build/transaction/enums/TransactionType.d.ts +3 -1
  89. package/build/transaction/enums/TransactionType.js +2 -0
  90. package/build/transaction/interfaces/IConsolidatedTransactionParameters.d.ts +31 -0
  91. package/build/transaction/interfaces/IConsolidatedTransactionParameters.js +1 -0
  92. package/build/transaction/interfaces/ITransactionParameters.d.ts +2 -0
  93. package/build/transaction/offline/OfflineTransactionManager.d.ts +69 -0
  94. package/build/transaction/offline/OfflineTransactionManager.js +255 -0
  95. package/build/transaction/offline/TransactionReconstructor.d.ts +28 -0
  96. package/build/transaction/offline/TransactionReconstructor.js +243 -0
  97. package/build/transaction/offline/TransactionSerializer.d.ts +50 -0
  98. package/build/transaction/offline/TransactionSerializer.js +700 -0
  99. package/build/transaction/offline/TransactionStateCapture.d.ts +52 -0
  100. package/build/transaction/offline/TransactionStateCapture.js +275 -0
  101. package/build/transaction/offline/interfaces/ISerializableState.d.ts +62 -0
  102. package/build/transaction/offline/interfaces/ISerializableState.js +2 -0
  103. package/build/transaction/offline/interfaces/ITypeSpecificData.d.ts +62 -0
  104. package/build/transaction/offline/interfaces/ITypeSpecificData.js +19 -0
  105. package/build/transaction/shared/TweakedTransaction.d.ts +12 -1
  106. package/build/transaction/shared/TweakedTransaction.js +75 -8
  107. package/build/utxo/interfaces/IUTXO.d.ts +2 -0
  108. package/documentation/README.md +5 -0
  109. package/documentation/offline-transaction-signing.md +650 -0
  110. package/documentation/transaction-building.md +603 -0
  111. package/package.json +62 -4
  112. package/src/_version.ts +1 -1
  113. package/src/generators/builders/HashCommitmentGenerator.ts +495 -0
  114. package/src/keypair/Address.ts +123 -70
  115. package/src/opnet.ts +16 -1
  116. package/src/signer/AddressRotation.ts +72 -0
  117. package/src/transaction/TransactionFactory.ts +87 -0
  118. package/src/transaction/builders/CancelTransaction.ts +4 -2
  119. package/src/transaction/builders/ConsolidatedInteractionTransaction.ts +561 -0
  120. package/src/transaction/builders/CustomScriptTransaction.ts +4 -2
  121. package/src/transaction/builders/MultiSignTransaction.ts +4 -2
  122. package/src/transaction/builders/TransactionBuilder.ts +8 -2
  123. package/src/transaction/enums/TransactionType.ts +2 -0
  124. package/src/transaction/interfaces/IConsolidatedTransactionParameters.ts +78 -0
  125. package/src/transaction/interfaces/ITransactionParameters.ts +8 -0
  126. package/src/transaction/offline/OfflineTransactionManager.ts +630 -0
  127. package/src/transaction/offline/TransactionReconstructor.ts +402 -0
  128. package/src/transaction/offline/TransactionSerializer.ts +920 -0
  129. package/src/transaction/offline/TransactionStateCapture.ts +469 -0
  130. package/src/transaction/offline/interfaces/ISerializableState.ts +141 -0
  131. package/src/transaction/offline/interfaces/ITypeSpecificData.ts +172 -0
  132. package/src/transaction/shared/TweakedTransaction.ts +156 -9
  133. package/src/utxo/interfaces/IUTXO.ts +8 -0
  134. package/test/address-rotation.test.ts +553 -0
  135. package/test/offline-transaction.test.ts +2065 -0
  136. package/vite.config.browser.ts +92 -0
  137. package/webpack.config.js +143 -2
  138. package/browser/crypto/crypto-browser.d.ts +0 -11
  139. package/browser/index.js.LICENSE.txt +0 -29
@@ -0,0 +1,410 @@
1
+ import { a as ue } from "./bip39.js";
2
+ function A(e) {
3
+ return e instanceof Uint8Array || ArrayBuffer.isView(e) && e.constructor.name === "Uint8Array";
4
+ }
5
+ function H(e) {
6
+ if (!A(e))
7
+ throw new Error("Uint8Array expected");
8
+ }
9
+ function K(e, r) {
10
+ return Array.isArray(r) ? r.length === 0 ? !0 : e ? r.every((n) => typeof n == "string") : r.every((n) => Number.isSafeInteger(n)) : !1;
11
+ }
12
+ function D(e) {
13
+ if (typeof e != "function")
14
+ throw new Error("function expected");
15
+ return !0;
16
+ }
17
+ function b(e, r) {
18
+ if (typeof r != "string")
19
+ throw new Error(`${e}: string expected`);
20
+ return !0;
21
+ }
22
+ function m(e) {
23
+ if (!Number.isSafeInteger(e))
24
+ throw new Error(`invalid integer: ${e}`);
25
+ }
26
+ function k(e) {
27
+ if (!Array.isArray(e))
28
+ throw new Error("array expected");
29
+ }
30
+ function R(e, r) {
31
+ if (!K(!0, r))
32
+ throw new Error(`${e}: array of strings expected`);
33
+ }
34
+ function M(e, r) {
35
+ if (!K(!1, r))
36
+ throw new Error(`${e}: array of numbers expected`);
37
+ }
38
+ // @__NO_SIDE_EFFECTS__
39
+ function f(...e) {
40
+ const r = (o) => o, n = (o, s) => (i) => o(s(i)), c = e.map((o) => o.encode).reduceRight(n, r), t = e.map((o) => o.decode).reduce(n, r);
41
+ return { encode: c, decode: t };
42
+ }
43
+ // @__NO_SIDE_EFFECTS__
44
+ function u(e) {
45
+ const r = typeof e == "string" ? e.split("") : e, n = r.length;
46
+ R("alphabet", r);
47
+ const c = new Map(r.map((t, o) => [t, o]));
48
+ return {
49
+ encode: (t) => (k(t), t.map((o) => {
50
+ if (!Number.isSafeInteger(o) || o < 0 || o >= n)
51
+ throw new Error(`alphabet.encode: digit index outside alphabet "${o}". Allowed: ${e}`);
52
+ return r[o];
53
+ })),
54
+ decode: (t) => (k(t), t.map((o) => {
55
+ b("alphabet.decode", o);
56
+ const s = c.get(o);
57
+ if (s === void 0)
58
+ throw new Error(`Unknown letter: "${o}". Allowed: ${e}`);
59
+ return s;
60
+ }))
61
+ };
62
+ }
63
+ // @__NO_SIDE_EFFECTS__
64
+ function l(e = "") {
65
+ return b("join", e), {
66
+ encode: (r) => (R("join.decode", r), r.join(e)),
67
+ decode: (r) => (b("join.decode", r), r.split(e))
68
+ };
69
+ }
70
+ // @__NO_SIDE_EFFECTS__
71
+ function T(e, r = "=") {
72
+ return m(e), b("padding", r), {
73
+ encode(n) {
74
+ for (R("padding.encode", n); n.length * e % 8; )
75
+ n.push(r);
76
+ return n;
77
+ },
78
+ decode(n) {
79
+ R("padding.decode", n);
80
+ let c = n.length;
81
+ if (c * e % 8)
82
+ throw new Error("padding: invalid, string should have whole number of bytes");
83
+ for (; c > 0 && n[c - 1] === r; c--)
84
+ if ((c - 1) * e % 8 === 0)
85
+ throw new Error("padding: invalid, string has too much padding");
86
+ return n.slice(0, c);
87
+ }
88
+ };
89
+ }
90
+ // @__NO_SIDE_EFFECTS__
91
+ function V(e) {
92
+ return D(e), { encode: (r) => r, decode: (r) => e(r) };
93
+ }
94
+ function O(e, r, n) {
95
+ if (r < 2)
96
+ throw new Error(`convertRadix: invalid from=${r}, base cannot be less than 2`);
97
+ if (n < 2)
98
+ throw new Error(`convertRadix: invalid to=${n}, base cannot be less than 2`);
99
+ if (k(e), !e.length)
100
+ return [];
101
+ let c = 0;
102
+ const t = [], o = Array.from(e, (i) => {
103
+ if (m(i), i < 0 || i >= r)
104
+ throw new Error(`invalid integer: ${i}`);
105
+ return i;
106
+ }), s = o.length;
107
+ for (; ; ) {
108
+ let i = 0, g = !0;
109
+ for (let p = c; p < s; p++) {
110
+ const x = o[p], d = r * i, a = d + x;
111
+ if (!Number.isSafeInteger(a) || d / r !== i || a - x !== d)
112
+ throw new Error("convertRadix: carry overflow");
113
+ const y = a / n;
114
+ i = a % n;
115
+ const h = Math.floor(y);
116
+ if (o[p] = h, !Number.isSafeInteger(h) || h * n + i !== a)
117
+ throw new Error("convertRadix: carry overflow");
118
+ if (g)
119
+ h ? g = !1 : c = p;
120
+ else continue;
121
+ }
122
+ if (t.push(i), g)
123
+ break;
124
+ }
125
+ for (let i = 0; i < e.length - 1 && e[i] === 0; i++)
126
+ t.push(0);
127
+ return t.reverse();
128
+ }
129
+ const J = (e, r) => r === 0 ? e : J(r, e % r), S = /* @__NO_SIDE_EFFECTS__ */ (e, r) => e + (r - J(e, r)), C = /* @__PURE__ */ (() => {
130
+ let e = [];
131
+ for (let r = 0; r < 40; r++)
132
+ e.push(2 ** r);
133
+ return e;
134
+ })();
135
+ function N(e, r, n, c) {
136
+ if (k(e), r <= 0 || r > 32)
137
+ throw new Error(`convertRadix2: wrong from=${r}`);
138
+ if (n <= 0 || n > 32)
139
+ throw new Error(`convertRadix2: wrong to=${n}`);
140
+ if (/* @__PURE__ */ S(r, n) > 32)
141
+ throw new Error(`convertRadix2: carry overflow from=${r} to=${n} carryBits=${/* @__PURE__ */ S(r, n)}`);
142
+ let t = 0, o = 0;
143
+ const s = C[r], i = C[n] - 1, g = [];
144
+ for (const p of e) {
145
+ if (m(p), p >= s)
146
+ throw new Error(`convertRadix2: invalid data word=${p} from=${r}`);
147
+ if (t = t << r | p, o + r > 32)
148
+ throw new Error(`convertRadix2: carry overflow pos=${o} from=${r}`);
149
+ for (o += r; o >= n; o -= n)
150
+ g.push((t >> o - n & i) >>> 0);
151
+ const x = C[o];
152
+ if (x === void 0)
153
+ throw new Error("invalid carry");
154
+ t &= x - 1;
155
+ }
156
+ if (t = t << n - o & i, !c && o >= r)
157
+ throw new Error("Excess padding");
158
+ if (!c && t > 0)
159
+ throw new Error(`Non-zero padding: ${t}`);
160
+ return c && o > 0 && g.push(t >>> 0), g;
161
+ }
162
+ // @__NO_SIDE_EFFECTS__
163
+ function Q(e) {
164
+ m(e);
165
+ const r = 2 ** 8;
166
+ return {
167
+ encode: (n) => {
168
+ if (!A(n))
169
+ throw new Error("radix.encode input should be Uint8Array");
170
+ return O(Array.from(n), r, e);
171
+ },
172
+ decode: (n) => (M("radix.decode", n), Uint8Array.from(O(n, e, r)))
173
+ };
174
+ }
175
+ // @__NO_SIDE_EFFECTS__
176
+ function w(e, r = !1) {
177
+ if (m(e), e <= 0 || e > 32)
178
+ throw new Error("radix2: bits should be in (0..32]");
179
+ if (/* @__PURE__ */ S(8, e) > 32 || /* @__PURE__ */ S(e, 8) > 32)
180
+ throw new Error("radix2: carry overflow");
181
+ return {
182
+ encode: (n) => {
183
+ if (!A(n))
184
+ throw new Error("radix2.encode input should be Uint8Array");
185
+ return N(Array.from(n), 8, e, !r);
186
+ },
187
+ decode: (n) => (M("radix2.decode", n), Uint8Array.from(N(n, e, 8, r)))
188
+ };
189
+ }
190
+ function F(e) {
191
+ return D(e), function(...r) {
192
+ try {
193
+ return e.apply(null, r);
194
+ } catch {
195
+ }
196
+ };
197
+ }
198
+ function Z(e, r) {
199
+ return m(e), D(r), {
200
+ encode(n) {
201
+ if (!A(n))
202
+ throw new Error("checksum.encode: input should be Uint8Array");
203
+ const c = r(n).slice(0, e), t = new Uint8Array(n.length + e);
204
+ return t.set(n), t.set(c, n.length), t;
205
+ },
206
+ decode(n) {
207
+ if (!A(n))
208
+ throw new Error("checksum.decode: input should be Uint8Array");
209
+ const c = n.slice(0, -e), t = n.slice(-e), o = r(c).slice(0, e);
210
+ for (let s = 0; s < e; s++)
211
+ if (o[s] !== t[s])
212
+ throw new Error("Invalid checksum");
213
+ return c;
214
+ }
215
+ };
216
+ }
217
+ const le = {
218
+ alphabet: u,
219
+ chain: f,
220
+ checksum: Z,
221
+ convertRadix: O,
222
+ convertRadix2: N,
223
+ radix: Q,
224
+ radix2: w,
225
+ join: l,
226
+ padding: T
227
+ }, X = /* @__PURE__ */ f(/* @__PURE__ */ w(4), /* @__PURE__ */ u("0123456789ABCDEF"), /* @__PURE__ */ l("")), Y = /* @__PURE__ */ f(/* @__PURE__ */ w(5), /* @__PURE__ */ u("ABCDEFGHIJKLMNOPQRSTUVWXYZ234567"), /* @__PURE__ */ T(5), /* @__PURE__ */ l("")), he = /* @__PURE__ */ f(/* @__PURE__ */ w(5), /* @__PURE__ */ u("ABCDEFGHIJKLMNOPQRSTUVWXYZ234567"), /* @__PURE__ */ l("")), we = /* @__PURE__ */ f(/* @__PURE__ */ w(5), /* @__PURE__ */ u("0123456789ABCDEFGHIJKLMNOPQRSTUV"), /* @__PURE__ */ T(5), /* @__PURE__ */ l("")), pe = /* @__PURE__ */ f(/* @__PURE__ */ w(5), /* @__PURE__ */ u("0123456789ABCDEFGHIJKLMNOPQRSTUV"), /* @__PURE__ */ l("")), ye = /* @__PURE__ */ f(/* @__PURE__ */ w(5), /* @__PURE__ */ u("0123456789ABCDEFGHJKMNPQRSTVWXYZ"), /* @__PURE__ */ l(""), /* @__PURE__ */ V((e) => e.toUpperCase().replace(/O/g, "0").replace(/[IL]/g, "1"))), q = typeof Uint8Array.from([]).toBase64 == "function" && typeof Uint8Array.fromBase64 == "function", ee = (e, r) => {
228
+ b("base64", e);
229
+ const n = r ? /^[A-Za-z0-9=_-]+$/ : /^[A-Za-z0-9=+/]+$/, c = r ? "base64url" : "base64";
230
+ if (e.length > 0 && !n.test(e))
231
+ throw new Error("invalid base64");
232
+ return Uint8Array.fromBase64(e, { alphabet: c, lastChunkHandling: "strict" });
233
+ }, re = q ? {
234
+ encode(e) {
235
+ return H(e), e.toBase64();
236
+ },
237
+ decode(e) {
238
+ return ee(e, !1);
239
+ }
240
+ } : /* @__PURE__ */ f(/* @__PURE__ */ w(6), /* @__PURE__ */ u("ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/"), /* @__PURE__ */ T(6), /* @__PURE__ */ l("")), ge = /* @__PURE__ */ f(/* @__PURE__ */ w(6), /* @__PURE__ */ u("ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/"), /* @__PURE__ */ l("")), ne = q ? {
241
+ encode(e) {
242
+ return H(e), e.toBase64({ alphabet: "base64url" });
243
+ },
244
+ decode(e) {
245
+ return ee(e, !0);
246
+ }
247
+ } : /* @__PURE__ */ f(/* @__PURE__ */ w(6), /* @__PURE__ */ u("ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_"), /* @__PURE__ */ T(6), /* @__PURE__ */ l("")), be = /* @__PURE__ */ f(/* @__PURE__ */ w(6), /* @__PURE__ */ u("ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_"), /* @__PURE__ */ l("")), P = /* @__NO_SIDE_EFFECTS__ */ (e) => /* @__PURE__ */ f(/* @__PURE__ */ Q(58), /* @__PURE__ */ u(e), /* @__PURE__ */ l("")), U = /* @__PURE__ */ P("123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz"), xe = /* @__PURE__ */ P("123456789abcdefghijkmnopqrstuvwxyzABCDEFGHJKLMNPQRSTUVWXYZ"), Ee = /* @__PURE__ */ P("rpshnaf39wBUDNEGHJKLM4PQRST7VWXYZ2bcdeCg65jkm8oFqi1tuvAxyz"), G = [0, 2, 3, 5, 6, 7, 9, 10, 11], oe = {
248
+ encode(e) {
249
+ let r = "";
250
+ for (let n = 0; n < e.length; n += 8) {
251
+ const c = e.subarray(n, n + 8);
252
+ r += U.encode(c).padStart(G[c.length], "1");
253
+ }
254
+ return r;
255
+ },
256
+ decode(e) {
257
+ let r = [];
258
+ for (let n = 0; n < e.length; n += 11) {
259
+ const c = e.slice(n, n + 11), t = G.indexOf(c.length), o = U.decode(c);
260
+ for (let s = 0; s < o.length - t; s++)
261
+ if (o[s] !== 0)
262
+ throw new Error("base58xmr: wrong padding");
263
+ r = r.concat(Array.from(o.slice(o.length - t)));
264
+ }
265
+ return Uint8Array.from(r);
266
+ }
267
+ }, te = (e) => /* @__PURE__ */ f(Z(4, (r) => e(e(r))), U), Ae = te, I = /* @__PURE__ */ f(/* @__PURE__ */ u("qpzry9x8gf2tvdw0s3jn54khce6mua7l"), /* @__PURE__ */ l("")), _ = [996825010, 642813549, 513874426, 1027748829, 705979059];
268
+ function B(e) {
269
+ const r = e >> 25;
270
+ let n = (e & 33554431) << 5;
271
+ for (let c = 0; c < _.length; c++)
272
+ (r >> c & 1) === 1 && (n ^= _[c]);
273
+ return n;
274
+ }
275
+ function z(e, r, n = 1) {
276
+ const c = e.length;
277
+ let t = 1;
278
+ for (let o = 0; o < c; o++) {
279
+ const s = e.charCodeAt(o);
280
+ if (s < 33 || s > 126)
281
+ throw new Error(`Invalid prefix (${e})`);
282
+ t = B(t) ^ s >> 5;
283
+ }
284
+ t = B(t);
285
+ for (let o = 0; o < c; o++)
286
+ t = B(t) ^ e.charCodeAt(o) & 31;
287
+ for (let o of r)
288
+ t = B(t) ^ o;
289
+ for (let o = 0; o < 6; o++)
290
+ t = B(t);
291
+ return t ^= n, I.encode(N([t % C[30]], 30, 5, !1));
292
+ }
293
+ // @__NO_SIDE_EFFECTS__
294
+ function ce(e) {
295
+ const r = e === "bech32" ? 1 : 734539939, n = /* @__PURE__ */ w(5), c = n.decode, t = n.encode, o = F(c);
296
+ function s(d, a, y = 90) {
297
+ b("bech32.encode prefix", d), A(a) && (a = Array.from(a)), M("bech32.encode", a);
298
+ const h = d.length;
299
+ if (h === 0)
300
+ throw new TypeError(`Invalid prefix length ${h}`);
301
+ const E = h + 7 + a.length;
302
+ if (y !== !1 && E > y)
303
+ throw new TypeError(`Length ${E} exceeds limit ${y}`);
304
+ const v = d.toLowerCase(), $ = z(v, a, r);
305
+ return `${v}1${I.encode(a)}${$}`;
306
+ }
307
+ function i(d, a = 90) {
308
+ b("bech32.decode input", d);
309
+ const y = d.length;
310
+ if (y < 8 || a !== !1 && y > a)
311
+ throw new TypeError(`invalid string length: ${y} (${d}). Expected (8..${a})`);
312
+ const h = d.toLowerCase();
313
+ if (d !== h && d !== d.toUpperCase())
314
+ throw new Error("String must be lowercase or uppercase");
315
+ const E = h.lastIndexOf("1");
316
+ if (E === 0 || E === -1)
317
+ throw new Error('Letter "1" must be present between prefix and data only');
318
+ const v = h.slice(0, E), $ = h.slice(E + 1);
319
+ if ($.length < 6)
320
+ throw new Error("Data must be at least 6 characters long");
321
+ const j = I.decode($).slice(0, -6), W = z(v, j, r);
322
+ if (!$.endsWith(W))
323
+ throw new Error(`Invalid checksum in ${d}: expected "${W}"`);
324
+ return { prefix: v, words: j };
325
+ }
326
+ const g = F(i);
327
+ function p(d) {
328
+ const { prefix: a, words: y } = i(d, !1);
329
+ return { prefix: a, words: y, bytes: c(y) };
330
+ }
331
+ function x(d, a) {
332
+ return s(d, t(a));
333
+ }
334
+ return {
335
+ encode: s,
336
+ decode: i,
337
+ encodeFromBytes: x,
338
+ decodeToBytes: p,
339
+ decodeUnsafe: g,
340
+ fromWords: c,
341
+ fromWordsUnsafe: o,
342
+ toWords: t
343
+ };
344
+ }
345
+ const me = /* @__PURE__ */ ce("bech32"), ve = /* @__PURE__ */ ce("bech32m"), se = {
346
+ encode: (e) => new TextDecoder().decode(e),
347
+ decode: (e) => new TextEncoder().encode(e)
348
+ }, $e = typeof Uint8Array.from([]).toHex == "function" && typeof Uint8Array.fromHex == "function", Be = {
349
+ encode(e) {
350
+ return H(e), e.toHex();
351
+ },
352
+ decode(e) {
353
+ return b("hex", e), Uint8Array.fromHex(e);
354
+ }
355
+ }, ie = $e ? Be : /* @__PURE__ */ f(/* @__PURE__ */ w(4), /* @__PURE__ */ u("0123456789abcdef"), /* @__PURE__ */ l(""), /* @__PURE__ */ V((e) => {
356
+ if (typeof e != "string" || e.length % 2 !== 0)
357
+ throw new TypeError(`hex.decode: expected string, got ${typeof e} with length ${e.length}`);
358
+ return e.toLowerCase();
359
+ })), L = {
360
+ utf8: se,
361
+ hex: ie,
362
+ base16: X,
363
+ base32: Y,
364
+ base64: re,
365
+ base64url: ne,
366
+ base58: U,
367
+ base58xmr: oe
368
+ }, ae = "Invalid encoding type. Available types: utf8, hex, base16, base32, base64, base64url, base58, base58xmr", de = (e, r) => {
369
+ if (typeof e != "string" || !L.hasOwnProperty(e))
370
+ throw new TypeError(ae);
371
+ if (!A(r))
372
+ throw new TypeError("bytesToString() expects Uint8Array");
373
+ return L[e].encode(r);
374
+ }, Ue = de, fe = (e, r) => {
375
+ if (!L.hasOwnProperty(e))
376
+ throw new TypeError(ae);
377
+ if (typeof r != "string")
378
+ throw new TypeError("stringToBytes() expects string");
379
+ return L[e].decode(r);
380
+ }, Te = fe, Ce = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
381
+ __proto__: null,
382
+ base16: X,
383
+ base32: Y,
384
+ base32crockford: ye,
385
+ base32hex: we,
386
+ base32hexnopad: pe,
387
+ base32nopad: he,
388
+ base58: U,
389
+ base58check: Ae,
390
+ base58flickr: xe,
391
+ base58xmr: oe,
392
+ base58xrp: Ee,
393
+ base64: re,
394
+ base64nopad: ge,
395
+ base64url: ne,
396
+ base64urlnopad: be,
397
+ bech32: me,
398
+ bech32m: ve,
399
+ bytes: Te,
400
+ bytesToString: de,
401
+ createBase58check: te,
402
+ hex: ie,
403
+ str: Ue,
404
+ stringToBytes: fe,
405
+ utf8: se,
406
+ utils: le
407
+ }, Symbol.toStringTag, { value: "Module" })), Re = /* @__PURE__ */ ue(Ce);
408
+ export {
409
+ Re as r
410
+ };
@@ -0,0 +1,12 @@
1
+ import { Signer } from '../../node_modules/@btc-vision/bitcoin/build/index.js';
2
+ import { ECPairInterface } from 'ecpair';
3
+ import { UnisatSigner } from '../transaction/browser/extensions/UnisatSigner.js';
4
+ export type RotationSigner = Signer | ECPairInterface | UnisatSigner;
5
+ export type SignerMap = Map<string, RotationSigner>;
6
+ export interface AddressRotationConfig {
7
+ readonly enabled: boolean;
8
+ readonly signerMap: SignerMap;
9
+ }
10
+ export declare function createSignerMap(pairs: ReadonlyArray<readonly [string, RotationSigner]>): SignerMap;
11
+ export declare function createAddressRotation(signers: SignerMap | ReadonlyArray<readonly [string, RotationSigner]>): AddressRotationConfig;
12
+ export declare function disabledAddressRotation(): AddressRotationConfig;
@@ -1,4 +1,4 @@
1
- import { PsbtInput } from '@btc-vision/bitcoin';
1
+ import { PsbtInput } from '../../node_modules/@btc-vision/bitcoin/build/index.js';
2
2
  export declare function isTaprootInput(input: PsbtInput): boolean;
3
3
  export declare function getInputRelevantScript(input: PsbtInput): Buffer | null;
4
4
  export declare function canSignNonTaprootInput(input: PsbtInput, publicKey: Buffer): boolean;
@@ -1,4 +1,4 @@
1
- import { Network } from '@btc-vision/bitcoin';
1
+ import { Network } from '../../node_modules/@btc-vision/bitcoin/build/index.js';
2
2
  import { ECPairInterface } from 'ecpair';
3
3
  export interface TweakSettings {
4
4
  readonly network?: Network;
@@ -1,4 +1,4 @@
1
- import { Transaction } from '@btc-vision/bitcoin';
1
+ import { Transaction } from '../../node_modules/@btc-vision/bitcoin/build/index.js';
2
2
  import { UTXO } from '../utxo/interfaces/IUTXO.js';
3
3
  import { ICustomTransactionParameters } from './builders/CustomScriptTransaction.js';
4
4
  import { FundingTransaction } from './builders/FundingTransaction.js';
@@ -8,6 +8,7 @@ import { IDeploymentParameters, IFundingTransactionParameters, IInteractionParam
8
8
  import { ICancelTransactionParametersWithoutSigner, ICustomTransactionWithoutSigner, InteractionParametersWithoutSigner } from './browser/Web3Provider.js';
9
9
  import { RawChallenge } from '../epoch/interfaces/IChallengeSolution.js';
10
10
  import { ICancelTransactionParameters } from './builders/CancelTransaction.js';
11
+ import { IConsolidatedInteractionParameters } from './interfaces/IConsolidatedTransactionParameters.js';
11
12
  export interface DeploymentResult {
12
13
  readonly transaction: [string, string];
13
14
  readonly contractAddress: string;
@@ -48,6 +49,18 @@ export interface CancelledTransaction {
48
49
  readonly nextUTXOs: UTXO[];
49
50
  readonly inputUtxos: UTXO[];
50
51
  }
52
+ export interface ConsolidatedInteractionResponse {
53
+ readonly setupTransaction: string;
54
+ readonly revealTransaction: string;
55
+ readonly setupTxId: string;
56
+ readonly revealTxId: string;
57
+ readonly totalFees: bigint;
58
+ readonly chunkCount: number;
59
+ readonly dataSize: number;
60
+ readonly challenge: RawChallenge;
61
+ readonly inputUtxos: UTXO[];
62
+ readonly compiledTargetScript: string;
63
+ }
51
64
  export declare class TransactionFactory {
52
65
  debug: boolean;
53
66
  private readonly DUMMY_PUBKEY;
@@ -57,6 +70,7 @@ export declare class TransactionFactory {
57
70
  createCancellableTransaction(params: ICancelTransactionParameters | ICancelTransactionParametersWithoutSigner): Promise<CancelledTransaction>;
58
71
  createCustomScriptTransaction(interactionParameters: ICustomTransactionParameters | ICustomTransactionWithoutSigner): Promise<[string, string, UTXO[], UTXO[]]>;
59
72
  signInteraction(interactionParameters: IInteractionParameters | InteractionParametersWithoutSigner): Promise<InteractionResponse>;
73
+ signConsolidatedInteraction(interactionParameters: IConsolidatedInteractionParameters): Promise<ConsolidatedInteractionResponse>;
60
74
  signDeployment(deploymentParameters: IDeploymentParameters): Promise<DeploymentResult>;
61
75
  createBTCTransfer(parameters: IFundingTransactionParameters): Promise<BitcoinTransferResponse>;
62
76
  getAllNewUTXOs(original: TransactionBuilder<TransactionType>, tx: Transaction, to: string): UTXO[];
@@ -1,4 +1,4 @@
1
- import { Network, Psbt, Signer } from '@btc-vision/bitcoin';
1
+ import { Network, Psbt, Signer } from '../../../node_modules/@btc-vision/bitcoin/build/index.js';
2
2
  export declare abstract class CustomKeypair implements Signer {
3
3
  abstract network: Network;
4
4
  abstract publicKey: Buffer;
@@ -3,7 +3,7 @@ import { UTXO } from '../../utxo/interfaces/IUTXO.js';
3
3
  import { CancelledTransaction, DeploymentResult, InteractionResponse } from '../TransactionFactory';
4
4
  import { ICustomTransactionParameters } from '../builders/CustomScriptTransaction.js';
5
5
  import { ICancelTransactionParameters } from '../builders/CancelTransaction.js';
6
- import { MLDSASecurityLevel } from '@btc-vision/bip32';
6
+ import { MLDSASecurityLevel } from '../../../node_modules/@btc-vision/bip32/src/cjs/index.cjs';
7
7
  export type InteractionParametersWithoutSigner = Omit<IInteractionParameters, 'signer' | 'challenge' | 'mldsaSigner'>;
8
8
  export type IDeploymentParametersWithoutSigner = Omit<IDeploymentParameters, 'signer' | 'network' | 'challenge' | 'mldsaSigner'>;
9
9
  export type ICustomTransactionWithoutSigner = Omit<ICustomTransactionParameters, 'signer' | 'challenge' | 'mldsaSigner'>;
@@ -1,4 +1,4 @@
1
- import { Network, Psbt } from '@btc-vision/bitcoin';
1
+ import { Network, Psbt } from '../../../../node_modules/@btc-vision/bitcoin/build/index.js';
2
2
  import { CustomKeypair } from '../BrowserSignerBase.js';
3
3
  import { SignatureType, Unisat } from '../types/Unisat.js';
4
4
  export interface WindowWithWallets {
@@ -1,4 +1,4 @@
1
- import { Network, Psbt } from '@btc-vision/bitcoin';
1
+ import { Network, Psbt } from '../../../../node_modules/@btc-vision/bitcoin/build/index.js';
2
2
  import { CustomKeypair } from '../BrowserSignerBase.js';
3
3
  import { SigningProtocol, Xverse } from '../types/Xverse.js';
4
4
  declare global {
@@ -1,5 +1,5 @@
1
1
  import { TransactionType } from '../enums/TransactionType.js';
2
- import { P2TRPayment, Psbt, PsbtInput, Taptree } from '@btc-vision/bitcoin';
2
+ import { P2TRPayment, Psbt, PsbtInput, Taptree } from '../../../node_modules/@btc-vision/bitcoin/build/index.js';
3
3
  import { TransactionBuilder } from './TransactionBuilder.js';
4
4
  import { TapLeafScript } from '../interfaces/Tap.js';
5
5
  import { ITransactionParameters } from '../interfaces/ITransactionParameters.js';
@@ -0,0 +1,44 @@
1
+ import { Buffer } from '../../../buffer';
2
+ import { ECPairInterface } from 'ecpair';
3
+ import { TransactionType } from '../enums/TransactionType.js';
4
+ import { TransactionBuilder } from './TransactionBuilder.js';
5
+ import { HashCommitmentGenerator } from '../../generators/builders/HashCommitmentGenerator.js';
6
+ import { CalldataGenerator } from '../../generators/builders/CalldataGenerator.js';
7
+ import { IConsolidatedInteractionParameters, IConsolidatedInteractionResult, IHashCommittedP2WSH, IRevealTransactionResult } from '../interfaces/IConsolidatedTransactionParameters.js';
8
+ import { IP2WSHAddress } from '../mineable/IP2WSHAddress.js';
9
+ import { ChallengeSolution } from '../../epoch/ChallengeSolution.js';
10
+ export declare class ConsolidatedInteractionTransaction extends TransactionBuilder<TransactionType.INTERACTION> {
11
+ readonly type: TransactionType.INTERACTION;
12
+ readonly randomBytes: Buffer;
13
+ protected readonly contractAddress: string;
14
+ protected readonly contractSecret: Buffer;
15
+ protected readonly calldata: Buffer;
16
+ protected readonly challenge: ChallengeSolution;
17
+ protected readonly epochChallenge: IP2WSHAddress;
18
+ protected readonly scriptSigner: ECPairInterface;
19
+ protected readonly calldataGenerator: CalldataGenerator;
20
+ protected readonly hashCommitmentGenerator: HashCommitmentGenerator;
21
+ protected readonly compiledTargetScript: Buffer;
22
+ protected readonly commitmentOutputs: IHashCommittedP2WSH[];
23
+ protected readonly disableAutoRefund: boolean;
24
+ protected readonly maxChunkSize: number;
25
+ private cachedValuePerOutput;
26
+ constructor(parameters: IConsolidatedInteractionParameters);
27
+ exportCompiledTargetScript(): Buffer;
28
+ getContractSecret(): Buffer;
29
+ getRndBytes(): Buffer;
30
+ getChallenge(): ChallengeSolution;
31
+ getCommitmentOutputs(): IHashCommittedP2WSH[];
32
+ getOutputCount(): number;
33
+ getTotalChunkCount(): number;
34
+ build(): Promise<IConsolidatedInteractionResult>;
35
+ buildRevealTransaction(setupTxId: string): IRevealTransactionResult;
36
+ getValuePerOutput(): bigint;
37
+ protected buildTransaction(): Promise<void>;
38
+ private finalizeCommitmentInput;
39
+ private estimateRevealVBytes;
40
+ private calculateValuePerOutput;
41
+ private getRefundAddress;
42
+ private generateFeatures;
43
+ private validateOutputCount;
44
+ }
@@ -1,4 +1,4 @@
1
- import { P2TRPayment, Psbt, PsbtInput, Stack } from '@btc-vision/bitcoin';
1
+ import { P2TRPayment, Psbt, PsbtInput, Stack } from '../../../node_modules/@btc-vision/bitcoin/build/index.js';
2
2
  import { TransactionType } from '../enums/TransactionType.js';
3
3
  import { TapLeafScript } from '../interfaces/Tap.js';
4
4
  import { SharedInteractionParameters } from '../interfaces/ITransactionParameters.js';
@@ -1,6 +1,6 @@
1
1
  import { TransactionType } from '../enums/TransactionType.js';
2
2
  import { IDeploymentParameters } from '../interfaces/ITransactionParameters.js';
3
- import { P2TRPayment, Psbt } from '@btc-vision/bitcoin';
3
+ import { P2TRPayment, Psbt } from '../../../node_modules/@btc-vision/bitcoin/build/index.js';
4
4
  import { TransactionBuilder } from './TransactionBuilder.js';
5
5
  import { TapLeafScript } from '../interfaces/Tap.js';
6
6
  import { Address } from '../../keypair/Address.js';
@@ -1,6 +1,6 @@
1
1
  import { TransactionType } from '../enums/TransactionType.js';
2
2
  import { IFundingTransactionParameters } from '../interfaces/ITransactionParameters.js';
3
- import { Signer } from '@btc-vision/bitcoin';
3
+ import { Signer } from '../../../node_modules/@btc-vision/bitcoin/build/index.js';
4
4
  import { TransactionBuilder } from './TransactionBuilder.js';
5
5
  import { ECPairInterface } from 'ecpair';
6
6
  export declare class FundingTransaction extends TransactionBuilder<TransactionType.FUNDING> {
@@ -1,4 +1,4 @@
1
- import { Taptree } from '@btc-vision/bitcoin';
1
+ import { Taptree } from '../../../node_modules/@btc-vision/bitcoin/build/index.js';
2
2
  import { TransactionType } from '../enums/TransactionType.js';
3
3
  import { TapLeafScript } from '../interfaces/Tap.js';
4
4
  import { IInteractionParameters } from '../interfaces/ITransactionParameters.js';
@@ -1,5 +1,5 @@
1
- import { Buffer } from 'buffer';
2
- import { Psbt } from '@btc-vision/bitcoin';
1
+ import { Buffer } from '../../../buffer';
2
+ import { Psbt } from '../../../node_modules/@btc-vision/bitcoin/build/index.js';
3
3
  import { TransactionType } from '../enums/TransactionType.js';
4
4
  import { IInteractionParameters } from '../interfaces/ITransactionParameters.js';
5
5
  import { TransactionBuilder } from './TransactionBuilder.js';
@@ -1,4 +1,4 @@
1
- import { P2TRPayment, Psbt, PsbtInput, Signer, TapScriptSig, Taptree } from '@btc-vision/bitcoin';
1
+ import { P2TRPayment, Psbt, PsbtInput, Signer, TapScriptSig, Taptree } from '../../../node_modules/@btc-vision/bitcoin/build/index.js';
2
2
  import { TransactionBuilder } from './TransactionBuilder.js';
3
3
  import { TransactionType } from '../enums/TransactionType.js';
4
4
  import { ITransactionParameters } from '../interfaces/ITransactionParameters.js';
@@ -1,4 +1,4 @@
1
- import { P2TRPayment, Psbt, PsbtInput, Signer, Taptree } from '@btc-vision/bitcoin';
1
+ import { P2TRPayment, Psbt, PsbtInput, Signer, Taptree } from '../../../node_modules/@btc-vision/bitcoin/build/index.js';
2
2
  import { ECPairInterface } from 'ecpair';
3
3
  import { TransactionBuilder } from './TransactionBuilder.js';
4
4
  import { TransactionType } from '../enums/TransactionType.js';
@@ -1,4 +1,4 @@
1
- import { Network, Psbt, PsbtInputExtended, PsbtOutputExtended, Signer, Transaction } from '@btc-vision/bitcoin';
1
+ import { Network, Psbt, PsbtInputExtended, PsbtOutputExtended, Signer, Transaction } from '../../../node_modules/@btc-vision/bitcoin/build/index.js';
2
2
  import { UpdateInput } from '../interfaces/Tap.js';
3
3
  import { TransactionType } from '../enums/TransactionType.js';
4
4
  import { IFundingTransactionParameters, ITransactionParameters } from '../interfaces/ITransactionParameters.js';
@@ -5,5 +5,7 @@ export declare enum TransactionType {
5
5
  INTERACTION = 3,
6
6
  MULTI_SIG = 4,
7
7
  CUSTOM_CODE = 5,
8
- CANCEL = 6
8
+ CANCEL = 6,
9
+ CONSOLIDATED_SETUP = 7,
10
+ CONSOLIDATED_REVEAL = 8
9
11
  }