@btc-vision/transaction 1.8.8 → 1.8.9

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/browser/index.js CHANGED
@@ -1,6 +1,6 @@
1
1
  import { a as ae, r as Ai } from "./rolldown-runtime.js";
2
2
  import { a as bi, c as ce, d as xt, i as Le, l as ot, n as Ei, o as Ii, r as Pi, s as vt, t as vi, u as Re } from "./vendors.js";
3
- import { A as Oi, B as D, C as E, D as _i, E as b, F as ht, I as Ie, L as qt, M as Ui, N as Bi, O as ki, P as Li, R as f, S as Rt, T as Ce, V as d, _ as Pe, a as Ke, b as y, c as Ri, d as C, f as Ci, g as Gt, h as Ki, i as H, j as Xt, k as g, l as Di, m as Mi, n as U, o as Ni, p as xi, r as Fi, s as it, t as N, u as Wi, v as Hi, w as L, x as Vi, y as O, z as zi } from "./btc-vision-bitcoin.js";
3
+ import { A as Oi, B as D, C as E, D as _i, E as b, F as ht, I as Ie, L as qt, M as Ui, N as Bi, O as ki, P as Li, R as f, S as Rt, T as Ce, V as d, _ as Pe, a as Ke, b as y, c as Ri, d as C, f as Ci, g as Gt, h as Ki, i as H, j as Xt, k as g, l as Di, m as Ni, n as U, o as Mi, p as xi, r as Fi, s as it, t as M, u as Wi, v as Hi, w as L, x as Vi, y as O, z as zi } from "./btc-vision-bitcoin.js";
4
4
  import { D as qi, T as Ft, a as zt, i as Gi, n as Xi, r as $i, t as Yi, w as ue } from "./noble-curves.js";
5
5
  var Ct = Symbol;
6
6
  typeof Ct.dispose != "symbol" && (Ct.dispose = /* @__PURE__ */ Symbol.for("Symbol.dispose"));
@@ -251,12 +251,12 @@ function jt(e) {
251
251
  }
252
252
  sr(!1, "invalid hashing algorithm name", "algorithm", e);
253
253
  }
254
- var or = /^[0-9a-fA-F]+$/, W = class Me {
254
+ var or = /^[0-9a-fA-F]+$/, W = class Ne {
255
255
  static btcToSatoshi(t) {
256
256
  return BigInt(t * 1e8);
257
257
  }
258
258
  static rndBytes() {
259
- return Me.getSafeRandomValues(64);
259
+ return Ne.getSafeRandomValues(64);
260
260
  }
261
261
  static getSafeRandomValues(t) {
262
262
  if (typeof globalThis.window < "u" && globalThis.window.crypto && typeof globalThis.window.crypto.getRandomValues == "function") {
@@ -508,7 +508,7 @@ var or = /^[0-9a-fA-F]+$/, W = class Me {
508
508
  };
509
509
  }
510
510
  }
511
- }, at = 115792089237316195423570985008687907853269984665640564039457584007908834671663n, Ne = class {
511
+ }, at = 115792089237316195423570985008687907853269984665640564039457584007908834671663n, Me = class {
512
512
  maxTries;
513
513
  constructor(e = 1e4) {
514
514
  this.maxTries = e;
@@ -560,7 +560,7 @@ var or = /^[0-9a-fA-F]+$/, W = class Me {
560
560
  return t;
561
561
  }
562
562
  }, ar = class {
563
- deriver = new Ne();
563
+ deriver = new Me();
564
564
  generateHybridKeyFromHash(e) {
565
565
  const t = this.deriver.findOrDeriveValidPoint(new Uint8Array(e), !1), i = this.deriver.getCanonicalY(t.y1, t.y2);
566
566
  return new Uint8Array(this.deriver.getHybridPublicKey(t.x, i));
@@ -1934,7 +1934,7 @@ var cr = [
1934
1934
  if (t.length < i) throw new Error("The amount of public keys is lower than the minimum required");
1935
1935
  if (i > Zt.MAXIMUM_SUPPORTED_SIGNATURE) throw new Error(`The maximum amount of signatures is ${Zt.MAXIMUM_SUPPORTED_SIGNATURE}`);
1936
1936
  const s = qt(1);
1937
- s[0] = i, t = t.filter((u, l, h) => l === h.findIndex((p) => C(u, p))), t = t.sort((u, l) => Mi(u, l));
1937
+ s[0] = i, t = t.filter((u, l, h) => l === h.findIndex((p) => C(u, p))), t = t.sort((u, l) => Ni(u, l));
1938
1938
  let n = !1;
1939
1939
  const o = t.map((u) => {
1940
1940
  const l = O(u);
@@ -2807,7 +2807,7 @@ var Tr = class extends we {
2807
2807
  toSignInputs: a
2808
2808
  });
2809
2809
  }
2810
- const r = await this.unisat.signPsbt(t[0], i[0]), s = N.fromHex(r);
2810
+ const r = await this.unisat.signPsbt(t[0], i[0]), s = M.fromHex(r);
2811
2811
  e[0].combine(s);
2812
2812
  }
2813
2813
  hasAlreadySignedTapScriptSig(e) {
@@ -2844,7 +2844,7 @@ var Tr = class extends we {
2844
2844
  disableTweakSigner: i
2845
2845
  }]).flat()
2846
2846
  }, n = e.toHex(), o = await this.unisat.signPsbt(n, s);
2847
- return N.fromHex(o);
2847
+ return M.fromHex(o);
2848
2848
  }
2849
2849
  getNonDuplicateScriptSig(e, t) {
2850
2850
  const i = [];
@@ -3678,7 +3678,7 @@ var ke = new Uint8Array([
3678
3678
  optionalOutputsAdded = !1;
3679
3679
  constructor(t) {
3680
3680
  if (super(t), t.estimatedFees && (this.estimatedFees = t.estimatedFees), this.signer = t.signer, this.network = t.network, this.feeRate = t.feeRate, this.priorityFee = t.priorityFee ?? 0n, this.gasSatFee = t.gasSatFee ?? 0n, this.utxos = t.utxos, this.optionalInputs = t.optionalInputs || [], this.to = t.to || void 0, this.debugFees = t.debugFees || !1, this.LOCK_LEAF_SCRIPT = this.defineLockScript(), t.note && (typeof t.note == "string" ? this.note = new TextEncoder().encode(t.note) : this.note = t.note), this.anchor = t.anchor ?? !1, this.isPubKeyDestination = this.to ? Et.isValidPublicKey(this.to, this.network) : !1, this.optionalOutputs = t.optionalOutputs, this.from = R.getFrom(t.from, this.signer, this.network), this.totalInputAmount = this.calculateTotalUTXOAmount(), this.calculateTotalVOutAmount() < this.totalInputAmount) throw new Error("Vout value is less than the value to send");
3681
- this.transaction = new N({
3681
+ this.transaction = new M({
3682
3682
  network: this.network,
3683
3683
  version: this.txVersion
3684
3684
  });
@@ -3777,7 +3777,7 @@ var ke = new Uint8Array([
3777
3777
  }
3778
3778
  async estimateTransactionFees() {
3779
3779
  await Promise.resolve();
3780
- const t = new N({ network: this.network }), i = this.getInputs(), r = this.getOutputs();
3780
+ const t = new M({ network: this.network }), i = this.getInputs(), r = this.getOutputs();
3781
3781
  t.addInputs(i), t.addOutputs(r);
3782
3782
  const s = /* @__PURE__ */ new Uint8Array(64), n = /* @__PURE__ */ new Uint8Array(72), o = (/* @__PURE__ */ new Uint8Array(33)).fill(2), a = (h, p) => {
3783
3783
  if (p.isPayToAnchor || this.anchorInputIndices.has(h)) return {
@@ -3865,7 +3865,7 @@ var ke = new Uint8Array([
3865
3865
  return this.debugFees && this.log(`Estimating fees: feeRate=${this.feeRate}, accurate_vSize=${c}, fee=${l}n`), l;
3866
3866
  }
3867
3867
  async rebuildFromBase64(t) {
3868
- return this.transaction = N.fromBase64(t, {
3868
+ return this.transaction = M.fromBase64(t, {
3869
3869
  network: this.network,
3870
3870
  version: this.txVersion
3871
3871
  }), this.signed = !1, this.sighashTypes = [Xt.SIGHASH_ANYONECANPAY, Xt.SIGHASH_ALL], await this.signPSBT();
@@ -3945,22 +3945,22 @@ var ke = new Uint8Array([
3945
3945
  return new Uint8Array(a.signature);
3946
3946
  }
3947
3947
  generateMLDSALinkRequest(t, i) {
3948
- const r = this.mldsaSigner, s = this.generateLegacySignature();
3949
- let n = null;
3950
- t.revealMLDSAPublicKey && (n = this.generateMLDSASignature());
3951
- const o = {
3948
+ const r = this.mldsaSigner, s = this.generateLegacySignature(), n = t.revealMLDSAPublicKey ?? !0;
3949
+ let o = null;
3950
+ n && (o = this.generateMLDSASignature());
3951
+ const a = {
3952
3952
  priority: J.MLDSA_LINK_PUBKEY,
3953
3953
  opcode: q.MLDSA_LINK_PUBKEY,
3954
3954
  data: {
3955
- verifyRequest: !!t.revealMLDSAPublicKey,
3955
+ verifyRequest: n,
3956
3956
  publicKey: r.publicKey,
3957
3957
  hashedPublicKey: this.hashedPublicKey,
3958
3958
  level: ie(r.publicKey.length),
3959
3959
  legacySignature: s,
3960
- mldsaSignature: n
3960
+ mldsaSignature: o
3961
3961
  }
3962
3962
  };
3963
- i.push(o);
3963
+ i.push(a);
3964
3964
  }
3965
3965
  getTransactionOPNetFee() {
3966
3966
  const t = this.priorityFee + this.gasSatFee;
@@ -4561,7 +4561,7 @@ var ke = new Uint8Array([
4561
4561
  version: 192
4562
4562
  }];
4563
4563
  }
4564
- }, Mt = class extends B {
4564
+ }, Nt = class extends B {
4565
4565
  type = m.FUNDING;
4566
4566
  amount;
4567
4567
  splitInputsInto;
@@ -4624,7 +4624,7 @@ var ke = new Uint8Array([
4624
4624
  getSignerKey() {
4625
4625
  return this.signer;
4626
4626
  }
4627
- }, Nt = class extends ye {
4627
+ }, Mt = class extends ye {
4628
4628
  type = m.INTERACTION;
4629
4629
  compiledTargetScript;
4630
4630
  scriptTree;
@@ -4938,7 +4938,7 @@ var ke = new Uint8Array([
4938
4938
  };
4939
4939
  }
4940
4940
  buildRevealTransaction(e) {
4941
- const t = new N({ network: this.network }), i = this.calculateValuePerOutput();
4941
+ const t = new M({ network: this.network }), i = this.calculateValuePerOutput();
4942
4942
  for (let h = 0; h < this.commitmentOutputs.length; h++) {
4943
4943
  const p = this.commitmentOutputs[h];
4944
4944
  t.addInput({
@@ -5120,7 +5120,7 @@ var ke = new Uint8Array([
5120
5120
  const i = this.parseOptionalInputs(e.optionalInputs), { finalTransaction: r, estimatedAmount: s, challenge: n } = await this.iterateFundingAmount({
5121
5121
  ...e,
5122
5122
  optionalInputs: i
5123
- }, Nt, async (p) => {
5123
+ }, Mt, async (p) => {
5124
5124
  const w = await p.estimateTransactionFees() + p.getTotalOutputValue();
5125
5125
  if (e.subtractExtraUTXOFromAmountRequired && e.optionalInputs && e.optionalInputs.length > 0) {
5126
5126
  const T = e.optionalInputs.reduce((k, x) => k + x.value, 0n), A = w > T ? w - T : 0n;
@@ -5144,7 +5144,7 @@ var ke = new Uint8Array([
5144
5144
  optionalInputs: []
5145
5145
  });
5146
5146
  if (!c) throw new Error("Could not sign funding transaction.");
5147
- const u = this.getUTXOAsTransaction(c.tx, r.getScriptAddress(), 0), l = new Nt({
5147
+ const u = this.getUTXOAsTransaction(c.tx, r.getScriptAddress(), 0), l = new Mt({
5148
5148
  ...e,
5149
5149
  utxos: u,
5150
5150
  randomBytes: r.getRndBytes(),
@@ -5210,7 +5210,7 @@ var ke = new Uint8Array([
5210
5210
  });
5211
5211
  if (!a) throw new Error("Could not sign funding transaction.");
5212
5212
  o.estimatedFees = a.estimatedFees;
5213
- const c = await new Mt({
5213
+ const c = await new Nt({
5214
5214
  ...o,
5215
5215
  optionalInputs: [],
5216
5216
  optionalOutputs: []
@@ -5343,7 +5343,7 @@ var ke = new Uint8Array([
5343
5343
  }
5344
5344
  async createFundTransaction(e) {
5345
5345
  if (!e.to) throw new Error('Field "to" not provided.');
5346
- const t = new Mt(e), i = await t.signTransaction();
5346
+ const t = new Nt(e), i = await t.signTransaction();
5347
5347
  if (!i) throw new Error("Could not sign funding transaction.");
5348
5348
  return {
5349
5349
  tx: i,
@@ -5474,7 +5474,7 @@ var ke = new Uint8Array([
5474
5474
  t.psbt && (this.log("Using provided PSBT."), this.transaction = t.psbt, this.originalInputCount = this.transaction.data.inputs.length), this.refundVault = t.refundVault, this.requestedAmount = t.requestedAmount, this.receiver = t.receiver, this.publicKeys = t.pubkeys, this.minimumSignatures = t.minimumSignatures, this.compiledTargetScript = Ge.compile(t.pubkeys, this.minimumSignatures), this.scriptTree = this.getScriptTree(), this.internalInit();
5475
5475
  }
5476
5476
  static fromBase64(t) {
5477
- const i = N.fromBase64(t.psbt, { network: t.network });
5477
+ const i = M.fromBase64(t.psbt, { network: t.network });
5478
5478
  return new F({
5479
5479
  ...t,
5480
5480
  psbt: i
@@ -6363,7 +6363,7 @@ var P = class {
6363
6363
  return Qe.Bitcoin;
6364
6364
  }
6365
6365
  };
6366
- function M(e) {
6366
+ function N(e) {
6367
6367
  return g(e.startsWith("0x") ? e.slice(2) : e);
6368
6368
  }
6369
6369
  var wt = class {
@@ -6410,14 +6410,14 @@ var wt = class {
6410
6410
  }
6411
6411
  static validateEpochWinner(e, t = !1) {
6412
6412
  try {
6413
- const i = BigInt(e.epochNumber), r = z.fromString(e.mldsaPublicKey, e.legacyPublicKey), s = M(e.solution), n = M(e.salt), o = e.difficulty, a = {
6414
- epochHash: M(e.verification.epochHash),
6415
- epochRoot: M(e.verification.epochRoot),
6416
- targetHash: M(e.verification.targetHash),
6417
- targetChecksum: M(e.verification.targetChecksum),
6413
+ const i = BigInt(e.epochNumber), r = z.fromString(e.mldsaPublicKey, e.legacyPublicKey), s = N(e.solution), n = N(e.salt), o = e.difficulty, a = {
6414
+ epochHash: N(e.verification.epochHash),
6415
+ epochRoot: N(e.verification.epochRoot),
6416
+ targetHash: N(e.verification.targetHash),
6417
+ targetChecksum: N(e.verification.targetChecksum),
6418
6418
  startBlock: BigInt(e.verification.startBlock),
6419
6419
  endBlock: BigInt(e.verification.endBlock),
6420
- proofs: Object.freeze(e.verification.proofs.map((p) => M(p)))
6420
+ proofs: Object.freeze(e.verification.proofs.map((p) => N(p)))
6421
6421
  }, c = this.calculatePreimage(a.targetChecksum, r.toBuffer(), n, t), u = this.sha1(c);
6422
6422
  if (!C(u, s) || this.countMatchingBits(u, a.targetHash) !== o) return !1;
6423
6423
  const l = i * this.BLOCKS_PER_EPOCH, h = l + this.BLOCKS_PER_EPOCH - 1n;
@@ -6449,7 +6449,7 @@ var wt = class {
6449
6449
  endBlock;
6450
6450
  proofs;
6451
6451
  constructor(e) {
6452
- this.epochHash = M(e.epochHash), this.epochRoot = M(e.epochRoot), this.targetHash = M(e.targetHash), this.targetChecksum = M(e.targetChecksum), this.startBlock = BigInt(e.startBlock), this.endBlock = BigInt(e.endBlock), this.proofs = Object.freeze(e.proofs.map((t) => M(t)));
6452
+ this.epochHash = N(e.epochHash), this.epochRoot = N(e.epochRoot), this.targetHash = N(e.targetHash), this.targetChecksum = N(e.targetChecksum), this.startBlock = BigInt(e.startBlock), this.endBlock = BigInt(e.endBlock), this.proofs = Object.freeze(e.proofs.map((t) => N(t)));
6453
6453
  }
6454
6454
  }, fi = class {
6455
6455
  epochNumber;
@@ -6458,7 +6458,7 @@ var wt = class {
6458
6458
  graffiti;
6459
6459
  signature;
6460
6460
  constructor(e, t) {
6461
- this.epochNumber = t, this.publicKey = z.fromString(e.mldsaPublicKey, e.legacyPublicKey), this.solution = M(e.solution), this.graffiti = e.graffiti ? M(e.graffiti) : void 0, this.signature = M(e.signature);
6461
+ this.epochNumber = t, this.publicKey = z.fromString(e.mldsaPublicKey, e.legacyPublicKey), this.solution = N(e.solution), this.graffiti = e.graffiti ? N(e.graffiti) : void 0, this.signature = N(e.signature);
6462
6462
  }
6463
6463
  verifySignature() {
6464
6464
  const e = new V();
@@ -6476,7 +6476,7 @@ var wt = class {
6476
6476
  verification;
6477
6477
  submission;
6478
6478
  constructor(e) {
6479
- this.epochNumber = BigInt(e.epochNumber), this.publicKey = z.fromString(e.mldsaPublicKey, e.legacyPublicKey), this.solution = M(e.solution), this.salt = M(e.salt), this.graffiti = M(e.graffiti), this.difficulty = e.difficulty, this.verification = new pi(e.verification), this.submission = e.submission ? new fi(e.submission, this.epochNumber + 2n) : e.submission;
6479
+ this.epochNumber = BigInt(e.epochNumber), this.publicKey = z.fromString(e.mldsaPublicKey, e.legacyPublicKey), this.solution = N(e.solution), this.salt = N(e.salt), this.graffiti = N(e.graffiti), this.difficulty = e.difficulty, this.verification = new pi(e.verification), this.submission = e.submission ? new fi(e.submission, this.epochNumber + 2n) : e.submission;
6480
6480
  }
6481
6481
  static validateRaw(e) {
6482
6482
  return wt.validateEpochWinner(e);
@@ -6561,7 +6561,7 @@ var wt = class {
6561
6561
  throw new Error(`Unsupported transaction type: ${e.header.transactionType}`);
6562
6562
  }
6563
6563
  static reconstructFunding(e, t) {
6564
- return new Mt({
6564
+ return new Nt({
6565
6565
  ...e,
6566
6566
  amount: BigInt(t.amount),
6567
6567
  splitInputsInto: t.splitInputsInto
@@ -6582,7 +6582,7 @@ var wt = class {
6582
6582
  static reconstructInteraction(e, t, i) {
6583
6583
  const r = new ne(t.challenge);
6584
6584
  if (!e.to) throw new Error('InteractionTransaction requires a "to" address');
6585
- return new Nt({
6585
+ return new Mt({
6586
6586
  ...e,
6587
6587
  to: e.to,
6588
6588
  calldata: g(t.calldata),
@@ -6804,7 +6804,7 @@ var wt = class {
6804
6804
  const r = i.typeSpecificData, s = r.pubkeys.map((p) => g(p));
6805
6805
  let n;
6806
6806
  const o = j.nameToNetwork(i.baseParams.networkName);
6807
- r.existingPsbtBase64 ? n = N.fromBase64(r.existingPsbtBase64, { network: o }) : n = await this.importForSigning(e, { signer: t }).signPSBT();
6807
+ r.existingPsbtBase64 ? n = M.fromBase64(r.existingPsbtBase64, { network: o }) : n = await this.importForSigning(e, { signer: t }).signPSBT();
6808
6808
  const a = [];
6809
6809
  for (let p = r.originalInputCount; p < n.data.inputs.length; p++) a.push(r.minimumSignatures);
6810
6810
  const c = Q.signPartial(n, t, r.originalInputCount, a), u = [];
@@ -6829,7 +6829,7 @@ var wt = class {
6829
6829
  if (!et(i.typeSpecificData)) throw new Error("State is not a multisig transaction");
6830
6830
  const r = i.typeSpecificData;
6831
6831
  if (!r.existingPsbtBase64) return !1;
6832
- const s = j.nameToNetwork(i.baseParams.networkName), n = N.fromBase64(r.existingPsbtBase64, { network: s }), o = t instanceof Uint8Array ? t : g(t);
6832
+ const s = j.nameToNetwork(i.baseParams.networkName), n = M.fromBase64(r.existingPsbtBase64, { network: s }), o = t instanceof Uint8Array ? t : g(t);
6833
6833
  return Q.verifyIfSigned(n, o);
6834
6834
  }
6835
6835
  static multiSigGetSignatureStatus(e) {
@@ -6842,7 +6842,7 @@ var wt = class {
6842
6842
  isComplete: !1,
6843
6843
  signers: []
6844
6844
  };
6845
- const s = j.nameToNetwork(t.baseParams.networkName), n = N.fromBase64(i.existingPsbtBase64, { network: s }), o = /* @__PURE__ */ new Set();
6845
+ const s = j.nameToNetwork(t.baseParams.networkName), n = M.fromBase64(i.existingPsbtBase64, { network: s }), o = /* @__PURE__ */ new Set();
6846
6846
  for (let c = i.originalInputCount; c < n.data.inputs.length; c++) {
6847
6847
  const u = n.data.inputs[c];
6848
6848
  if (u.tapScriptSig) for (const l of u.tapScriptSig) o.add(f(l.pubkey));
@@ -6867,7 +6867,7 @@ var wt = class {
6867
6867
  if (!et(t.typeSpecificData)) throw new Error("State is not a multisig transaction");
6868
6868
  const i = t.typeSpecificData;
6869
6869
  if (!i.existingPsbtBase64) throw new Error("No PSBT found in state - transaction has not been signed");
6870
- const r = j.nameToNetwork(t.baseParams.networkName), s = N.fromBase64(i.existingPsbtBase64, { network: r }), n = i.pubkeys.map((a) => g(a)), o = [];
6870
+ const r = j.nameToNetwork(t.baseParams.networkName), s = M.fromBase64(i.existingPsbtBase64, { network: r }), n = i.pubkeys.map((a) => g(a)), o = [];
6871
6871
  for (let a = i.originalInputCount; a < s.data.inputs.length; a++) o.push(n);
6872
6872
  if (!Q.attemptFinalizeInputs(s, i.originalInputCount, o, !0)) throw new Error("Failed to finalize multisig transaction - not enough signatures");
6873
6873
  return s.extractTransaction(!0, !0).toHex();
@@ -6892,13 +6892,13 @@ var wt = class {
6892
6892
  static csvMultisigGetStatus(e) {
6893
6893
  const t = P.fromBase64(e);
6894
6894
  if (!t.partialPsbtBase64) return [];
6895
- const i = j.nameToNetwork(t.baseParams.networkName), r = N.fromBase64(t.partialPsbtBase64, { network: i });
6895
+ const i = j.nameToNetwork(t.baseParams.networkName), r = M.fromBase64(t.partialPsbtBase64, { network: i });
6896
6896
  return this.computeCSVMultisigStatus(t, r, i);
6897
6897
  }
6898
6898
  static async addCSVMultisigSignature(e, t) {
6899
6899
  const i = P.fromBase64(e), r = j.nameToNetwork(i.baseParams.networkName);
6900
6900
  let s;
6901
- i.partialPsbtBase64 ? (s = N.fromBase64(i.partialPsbtBase64, { network: r }), this.addSignerToCSVInputs(s, t, r)) : (s = await this.importForSigning(e, { signer: t }).signPSBT(), this.addSignerToCSVInputs(s, t, r));
6901
+ i.partialPsbtBase64 ? (s = M.fromBase64(i.partialPsbtBase64, { network: r }), this.addSignerToCSVInputs(s, t, r)) : (s = await this.importForSigning(e, { signer: t }).signPSBT(), this.addSignerToCSVInputs(s, t, r));
6902
6902
  const n = this.computeCSVMultisigStatus(i, s, r), o = n.length > 0 && n.every((c) => c.collected >= c.required), a = {
6903
6903
  ...i,
6904
6904
  partialPsbtBase64: s.toBase64()
@@ -6912,7 +6912,7 @@ var wt = class {
6912
6912
  static csvMultisigFinalize(e) {
6913
6913
  const t = P.fromBase64(e);
6914
6914
  if (!t.partialPsbtBase64) throw new Error("No partial PSBT in state — call addCSVMultisigSignature first");
6915
- const i = j.nameToNetwork(t.baseParams.networkName), r = N.fromBase64(t.partialPsbtBase64, { network: i });
6915
+ const i = j.nameToNetwork(t.baseParams.networkName), r = M.fromBase64(t.partialPsbtBase64, { network: i });
6916
6916
  for (let s = 0; s < r.data.inputs.length; s++) {
6917
6917
  const n = r.data.inputs[s];
6918
6918
  if (!n.tapLeafScript || n.tapLeafScript.length === 0) continue;
@@ -6993,7 +6993,7 @@ var wt = class {
6993
6993
  const k = n[A];
6994
6994
  if (!k) throw new Error(`Invalid raw index ${A} - not found in raw transactions array`);
6995
6995
  let x = p.get(A);
6996
- if (x === void 0 && (x = Ni(k), p.set(A, x)), l += T, u.push({
6996
+ if (x === void 0 && (x = Mi(k), p.set(A, x)), l += T, u.push({
6997
6997
  transactionId: w.transactionId,
6998
6998
  outputIndex: w.outputIndex,
6999
6999
  value: T,
@@ -7197,7 +7197,7 @@ function Lt(e) {
7197
7197
  const t = e[0];
7198
7198
  return e.length === 1 && t !== void 0 ? `${Lt(t)}[]` : `tuple(${e.map((i) => Lt(i)).join(",")})[]`;
7199
7199
  }
7200
- var Mr = class {
7200
+ var Nr = class {
7201
7201
  decodeData(e, t) {
7202
7202
  const i = new Ht(e), r = [];
7203
7203
  for (const s of t) r.push(this.decodeSingleValue(i, s));
@@ -7307,7 +7307,7 @@ var Mr = class {
7307
7307
  sha256(e) {
7308
7308
  return new Uint8Array(new Kr.default.sha256().update(e).digest());
7309
7309
  }
7310
- }, Nr = class yi {
7310
+ }, Mr = class yi {
7311
7311
  items;
7312
7312
  keys;
7313
7313
  constructor(t = []) {
@@ -7599,7 +7599,7 @@ var zr = class extends we {
7599
7599
  signInputs: r
7600
7600
  });
7601
7601
  if ("error" in s) throw new Error(s.error.message);
7602
- const n = N.fromBase64(s.result.psbt);
7602
+ const n = M.fromBase64(s.result.psbt);
7603
7603
  e[0].combine(n);
7604
7604
  }
7605
7605
  hasAlreadySignedTapScriptSig(e) {
@@ -7640,7 +7640,7 @@ var zr = class extends we {
7640
7640
  signInputs: o
7641
7641
  });
7642
7642
  if ("error" in a) throw new Error(a.error.message);
7643
- return N.fromBase64(a.result.psbt);
7643
+ return M.fromBase64(a.result.psbt);
7644
7644
  }
7645
7645
  getNonDuplicateScriptSig(e, t) {
7646
7646
  const i = [];
@@ -7796,7 +7796,7 @@ var zr = class extends we {
7796
7796
  for (let r = 0; r < t.length; r++) t[r] !== void 0 && !this.deleted[r] && this.set(t[r], i[r]);
7797
7797
  }
7798
7798
  }, ms = /* @__PURE__ */ Ai({
7799
- ABICoder: () => Mr,
7799
+ ABICoder: () => Nr,
7800
7800
  ABIDataTypes: () => S,
7801
7801
  ADDRESS_BYTE_LENGTH: () => 32,
7802
7802
  ANCHOR_SCRIPT: () => se,
@@ -7804,7 +7804,7 @@ var zr = class extends we {
7804
7804
  Address: () => z,
7805
7805
  AddressGenerator: () => de,
7806
7806
  AddressMap: () => Fe,
7807
- AddressSet: () => Nr,
7807
+ AddressSet: () => Mr,
7808
7808
  AddressTypes: () => ct,
7809
7809
  AddressVerificator: () => Et,
7810
7810
  BIPStandard: () => kt,
@@ -7841,7 +7841,7 @@ var zr = class extends we {
7841
7841
  FastMap: () => Wt,
7842
7842
  FeaturePriority: () => J,
7843
7843
  Features: () => q,
7844
- FundingTransaction: () => Mt,
7844
+ FundingTransaction: () => Nt,
7845
7845
  Generator: () => tt,
7846
7846
  HashCommitmentGenerator: () => St,
7847
7847
  I128_BYTE_LENGTH: () => 16,
@@ -7850,7 +7850,7 @@ var zr = class extends we {
7850
7850
  I32_BYTE_LENGTH: () => 4,
7851
7851
  I64_BYTE_LENGTH: () => 8,
7852
7852
  I8_BYTE_LENGTH: () => 1,
7853
- InteractionTransaction: () => Nt,
7853
+ InteractionTransaction: () => Mt,
7854
7854
  InteractionTransactionP2WDA: () => ri,
7855
7855
  LEAF_VERSION_TAPSCRIPT: () => 192,
7856
7856
  LegacyCalldataGenerator: () => ur,
@@ -7882,7 +7882,7 @@ var zr = class extends we {
7882
7882
  SELECTOR_BYTE_LENGTH: () => 4,
7883
7883
  SERIALIZATION_FORMAT_VERSION: () => 2,
7884
7884
  SERIALIZATION_MAGIC_BYTE: () => 66,
7885
- Secp256k1PointDeriver: () => Ne,
7885
+ Secp256k1PointDeriver: () => Me,
7886
7886
  SharedInteractionTransaction: () => ye,
7887
7887
  SignatureType: () => te,
7888
7888
  SigningProtocol: () => Vr,
@@ -7937,7 +7937,7 @@ var zr = class extends we {
7937
7937
  versionBuffer: () => qe
7938
7938
  }), Ts = v.MLDSASecurityLevel, As = v.QuantumBIP32Factory, bs = v.QuantumDerivationPath;
7939
7939
  export {
7940
- Mr as ABICoder,
7940
+ Nr as ABICoder,
7941
7941
  S as ABIDataTypes,
7942
7942
  jr as ADDRESS_BYTE_LENGTH,
7943
7943
  se as ANCHOR_SCRIPT,
@@ -7945,7 +7945,7 @@ export {
7945
7945
  z as Address,
7946
7946
  de as AddressGenerator,
7947
7947
  Fe as AddressMap,
7948
- Nr as AddressSet,
7948
+ Mr as AddressSet,
7949
7949
  ct as AddressTypes,
7950
7950
  Et as AddressVerificator,
7951
7951
  kt as BIPStandard,
@@ -7982,7 +7982,7 @@ export {
7982
7982
  Wt as FastMap,
7983
7983
  J as FeaturePriority,
7984
7984
  q as Features,
7985
- Mt as FundingTransaction,
7985
+ Nt as FundingTransaction,
7986
7986
  tt as Generator,
7987
7987
  St as HashCommitmentGenerator,
7988
7988
  as as I128_BYTE_LENGTH,
@@ -7991,7 +7991,7 @@ export {
7991
7991
  us as I32_BYTE_LENGTH,
7992
7992
  cs as I64_BYTE_LENGTH,
7993
7993
  hs as I8_BYTE_LENGTH,
7994
- Nt as InteractionTransaction,
7994
+ Mt as InteractionTransaction,
7995
7995
  ri as InteractionTransactionP2WDA,
7996
7996
  gs as LEAF_VERSION_TAPSCRIPT,
7997
7997
  ur as LegacyCalldataGenerator,
@@ -8023,7 +8023,7 @@ export {
8023
8023
  Jr as SELECTOR_BYTE_LENGTH,
8024
8024
  ws as SERIALIZATION_FORMAT_VERSION,
8025
8025
  ys as SERIALIZATION_MAGIC_BYTE,
8026
- Ne as Secp256k1PointDeriver,
8026
+ Me as Secp256k1PointDeriver,
8027
8027
  ye as SharedInteractionTransaction,
8028
8028
  te as SignatureType,
8029
8029
  Vr as SigningProtocol,
@@ -38,7 +38,7 @@ export declare class EpochValidator {
38
38
  /**
39
39
  * Verify an epoch solution using IPreimage
40
40
  */
41
- static verifySolution(challenge: IChallengeSolution, log?: boolean, useHashedPreimage?: boolean): boolean;
41
+ static verifySolution(challenge: IChallengeSolution, log?: boolean, useConcatenatedPreimage?: boolean): boolean;
42
42
  /**
43
43
  * Get the mining target block for an epoch
44
44
  */
@@ -46,11 +46,11 @@ export declare class EpochValidator {
46
46
  /**
47
47
  * Validate epoch winner from raw data
48
48
  */
49
- static validateEpochWinner(epochData: RawChallenge, useHashedPreimage?: boolean): boolean;
49
+ static validateEpochWinner(epochData: RawChallenge, useConcatenatedPreimage?: boolean): boolean;
50
50
  /**
51
51
  * Validate epoch winner from Preimage instance
52
52
  */
53
- static validateChallengeSolution(challenge: IChallengeSolution, useHashedPreimage?: boolean): boolean;
53
+ static validateChallengeSolution(challenge: IChallengeSolution, useConcatenatedPreimage?: boolean): boolean;
54
54
  /**
55
55
  * Calculate solution hash from preimage components
56
56
  * @param targetChecksum The target checksum (32 bytes)
@@ -58,7 +58,7 @@ export declare class EpochValidator {
58
58
  * @param salt The salt buffer (32 bytes)
59
59
  * @returns The SHA-1 hash of the preimage
60
60
  */
61
- static calculateSolution(targetChecksum: Uint8Array, publicKey: Uint8Array, salt: Uint8Array, useHashedPreimage?: boolean): Uint8Array;
61
+ static calculateSolution(targetChecksum: Uint8Array, publicKey: Uint8Array, salt: Uint8Array, useConcatenatedPreimage?: boolean): Uint8Array;
62
62
  /**
63
63
  * Check if a solution meets the minimum difficulty requirement
64
64
  */
@@ -38,7 +38,7 @@ export declare class EpochValidator {
38
38
  /**
39
39
  * Verify an epoch solution using IPreimage
40
40
  */
41
- static verifySolution(challenge: IChallengeSolution, log?: boolean, useHashedPreimage?: boolean): boolean;
41
+ static verifySolution(challenge: IChallengeSolution, log?: boolean, useConcatenatedPreimage?: boolean): boolean;
42
42
  /**
43
43
  * Get the mining target block for an epoch
44
44
  */
@@ -46,11 +46,11 @@ export declare class EpochValidator {
46
46
  /**
47
47
  * Validate epoch winner from raw data
48
48
  */
49
- static validateEpochWinner(epochData: RawChallenge, useHashedPreimage?: boolean): boolean;
49
+ static validateEpochWinner(epochData: RawChallenge, useConcatenatedPreimage?: boolean): boolean;
50
50
  /**
51
51
  * Validate epoch winner from Preimage instance
52
52
  */
53
- static validateChallengeSolution(challenge: IChallengeSolution, useHashedPreimage?: boolean): boolean;
53
+ static validateChallengeSolution(challenge: IChallengeSolution, useConcatenatedPreimage?: boolean): boolean;
54
54
  /**
55
55
  * Calculate solution hash from preimage components
56
56
  * @param targetChecksum The target checksum (32 bytes)
@@ -58,7 +58,7 @@ export declare class EpochValidator {
58
58
  * @param salt The salt buffer (32 bytes)
59
59
  * @returns The SHA-1 hash of the preimage
60
60
  */
61
- static calculateSolution(targetChecksum: Uint8Array, publicKey: Uint8Array, salt: Uint8Array, useHashedPreimage?: boolean): Uint8Array;
61
+ static calculateSolution(targetChecksum: Uint8Array, publicKey: Uint8Array, salt: Uint8Array, useConcatenatedPreimage?: boolean): Uint8Array;
62
62
  /**
63
63
  * Check if a solution meets the minimum difficulty requirement
64
64
  */
@@ -90,10 +90,10 @@ export class EpochValidator {
90
90
  /**
91
91
  * Verify an epoch solution using IPreimage
92
92
  */
93
- static verifySolution(challenge, log = false, useHashedPreimage = false) {
93
+ static verifySolution(challenge, log = false, useConcatenatedPreimage = false) {
94
94
  try {
95
95
  const verification = challenge.verification;
96
- const calculatedPreimage = this.calculatePreimage(verification.targetChecksum, challenge.publicKey.toBuffer(), challenge.salt, useHashedPreimage);
96
+ const calculatedPreimage = this.calculatePreimage(verification.targetChecksum, challenge.publicKey.toBuffer(), challenge.salt, useConcatenatedPreimage);
97
97
  const computedSolution = this.sha1(calculatedPreimage);
98
98
  if (!equals(computedSolution, challenge.solution)) {
99
99
  return false;
@@ -126,7 +126,7 @@ export class EpochValidator {
126
126
  /**
127
127
  * Validate epoch winner from raw data
128
128
  */
129
- static validateEpochWinner(epochData, useHashedPreimage = false) {
129
+ static validateEpochWinner(epochData, useConcatenatedPreimage = false) {
130
130
  try {
131
131
  const epochNumber = BigInt(epochData.epochNumber);
132
132
  const publicKey = Address.fromString(epochData.mldsaPublicKey, epochData.legacyPublicKey);
@@ -142,7 +142,7 @@ export class EpochValidator {
142
142
  endBlock: BigInt(epochData.verification.endBlock),
143
143
  proofs: Object.freeze(epochData.verification.proofs.map((p) => stringToBuffer(p))),
144
144
  };
145
- const calculatedPreimage = this.calculatePreimage(verification.targetChecksum, publicKey.toBuffer(), salt, useHashedPreimage);
145
+ const calculatedPreimage = this.calculatePreimage(verification.targetChecksum, publicKey.toBuffer(), salt, useConcatenatedPreimage);
146
146
  const computedSolution = this.sha1(calculatedPreimage);
147
147
  if (!equals(computedSolution, solution)) {
148
148
  return false;
@@ -163,8 +163,8 @@ export class EpochValidator {
163
163
  /**
164
164
  * Validate epoch winner from Preimage instance
165
165
  */
166
- static validateChallengeSolution(challenge, useHashedPreimage = false) {
167
- return this.verifySolution(challenge, false, useHashedPreimage);
166
+ static validateChallengeSolution(challenge, useConcatenatedPreimage = false) {
167
+ return this.verifySolution(challenge, false, useConcatenatedPreimage);
168
168
  }
169
169
  /**
170
170
  * Calculate solution hash from preimage components
@@ -173,8 +173,8 @@ export class EpochValidator {
173
173
  * @param salt The salt buffer (32 bytes)
174
174
  * @returns The SHA-1 hash of the preimage
175
175
  */
176
- static calculateSolution(targetChecksum, publicKey, salt, useHashedPreimage = false) {
177
- const preimage = this.calculatePreimage(targetChecksum, publicKey, salt, useHashedPreimage);
176
+ static calculateSolution(targetChecksum, publicKey, salt, useConcatenatedPreimage = false) {
177
+ const preimage = this.calculatePreimage(targetChecksum, publicKey, salt, useConcatenatedPreimage);
178
178
  return this.sha1(preimage);
179
179
  }
180
180
  /**
@@ -744,15 +744,31 @@ export class TransactionBuilder extends TweakedTransaction {
744
744
  generateMLDSALinkRequest(parameters, features) {
745
745
  const mldsaSigner = this.mldsaSigner;
746
746
  const legacySignature = this.generateLegacySignature();
747
+ // Reveal by default. The legacy Schnorr signature only proves ownership of
748
+ // the Bitcoin key being linked; it says nothing about the claimed
749
+ // hashedPublicKey. Without the ML-DSA public key and a signature over it,
750
+ // a link request carries no proof that the sender knows a preimage for
751
+ // that hash, so a node cannot safely create a NEW identity from it.
752
+ //
753
+ // Defaulting to false made every caller responsible for remembering, and
754
+ // callers do forget: opwallet never set this anywhere, and its deployment
755
+ // screen calls signDeployment() directly, bypassing any controller-level
756
+ // fix. Revealing when it was not needed only costs bytes (ML-DSA-44:
757
+ // 1312-byte key + 2420-byte signature); not revealing when it was needed
758
+ // gets the transaction rejected.
759
+ //
760
+ // Callers that KNOW the key is already linked on-chain should pass false
761
+ // explicitly to avoid paying for the reveal on every interaction.
762
+ const shouldReveal = parameters.revealMLDSAPublicKey ?? true;
747
763
  let mldsaSignature = null;
748
- if (parameters.revealMLDSAPublicKey) {
764
+ if (shouldReveal) {
749
765
  mldsaSignature = this.generateMLDSASignature();
750
766
  }
751
767
  const mldsaRequest = {
752
768
  priority: FeaturePriority.MLDSA_LINK_PUBKEY,
753
769
  opcode: Features.MLDSA_LINK_PUBKEY,
754
770
  data: {
755
- verifyRequest: !!parameters.revealMLDSAPublicKey,
771
+ verifyRequest: shouldReveal,
756
772
  publicKey: mldsaSigner.publicKey,
757
773
  hashedPublicKey: this.hashedPublicKey,
758
774
  level: getLevelFromPublicKeyLength(mldsaSigner.publicKey.length),
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@btc-vision/transaction",
3
3
  "type": "module",
4
- "version": "1.8.8",
4
+ "version": "1.8.9",
5
5
  "author": "BlobMaster41",
6
6
  "description": "OPNet transaction library allows you to create and sign transactions for the OPNet network.",
7
7
  "engines": {