@chainvue/verus-sdk 0.5.1 → 0.6.1

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/dist/bundle.js CHANGED
@@ -9233,7 +9233,7 @@ var require_ecpair = __commonJS({
9233
9233
  var curve = ecurve.getCurveByName("secp256k1");
9234
9234
  var secp256k1Ecurve = ecdsa.__curve;
9235
9235
  var fastcurve = require_fastcurve();
9236
- function ECPair3(d, Q, options) {
9236
+ function ECPair4(d, Q, options) {
9237
9237
  if (options) {
9238
9238
  typeforce({
9239
9239
  compressed: types.maybe(types.Boolean),
@@ -9256,7 +9256,7 @@ var require_ecpair = __commonJS({
9256
9256
  this.compressed = options.compressed === void 0 ? true : options.compressed;
9257
9257
  this.network = options.network || NETWORKS.bitcoin;
9258
9258
  }
9259
- Object.defineProperty(ECPair3.prototype, "Q", {
9259
+ Object.defineProperty(ECPair4.prototype, "Q", {
9260
9260
  get: function() {
9261
9261
  if (!this.__Q && this.d) {
9262
9262
  var qBuf = fastcurve.publicKeyCreate(this.d.toBuffer(32), false);
@@ -9270,22 +9270,22 @@ var require_ecpair = __commonJS({
9270
9270
  return this.__Q;
9271
9271
  }
9272
9272
  });
9273
- ECPair3.recoverFromSignature = function(hashBuffer, compactSigBuffer, network) {
9273
+ ECPair4.recoverFromSignature = function(hashBuffer, compactSigBuffer, network) {
9274
9274
  var compactParsed = sig.parseCompact(compactSigBuffer);
9275
9275
  var der = compactParsed.signature.toDER();
9276
9276
  var recovery = compactParsed.i & 3;
9277
9277
  var nobleSig = secp256k1.Signature.fromDER(der).addRecoveryBit(recovery);
9278
9278
  var pubBytes = nobleSig.recoverPublicKey(hashBuffer).toRawBytes(true);
9279
- return ECPair3.fromPublicKeyBuffer(Buffer.from(pubBytes), network);
9279
+ return ECPair4.fromPublicKeyBuffer(Buffer.from(pubBytes), network);
9280
9280
  };
9281
- ECPair3.fromPublicKeyBuffer = function(buffer, network) {
9281
+ ECPair4.fromPublicKeyBuffer = function(buffer, network) {
9282
9282
  var Q = ecurve.Point.decodeFrom(secp256k1Ecurve, buffer);
9283
- return new ECPair3(null, Q, {
9283
+ return new ECPair4(null, Q, {
9284
9284
  compressed: Q.compressed,
9285
9285
  network
9286
9286
  });
9287
9287
  };
9288
- ECPair3.fromWIF = function(string, network, skipVersionCheck) {
9288
+ ECPair4.fromWIF = function(string, network, skipVersionCheck) {
9289
9289
  if (skipVersionCheck === void 0) {
9290
9290
  skipVersionCheck = false;
9291
9291
  }
@@ -9303,12 +9303,12 @@ var require_ecpair = __commonJS({
9303
9303
  throw new Error("Invalid network version");
9304
9304
  }
9305
9305
  var d = BigInteger.fromBuffer(decoded.privateKey);
9306
- return new ECPair3(d, null, {
9306
+ return new ECPair4(d, null, {
9307
9307
  compressed: decoded.compressed,
9308
9308
  network
9309
9309
  });
9310
9310
  };
9311
- ECPair3.makeRandom = function(options) {
9311
+ ECPair4.makeRandom = function(options) {
9312
9312
  options = options || {};
9313
9313
  var rng = options.rng || randomBytes3;
9314
9314
  var d;
@@ -9317,18 +9317,18 @@ var require_ecpair = __commonJS({
9317
9317
  typeforce(types.Buffer256bit, buffer);
9318
9318
  d = BigInteger.fromBuffer(buffer);
9319
9319
  } while (d.signum() <= 0 || d.compareTo(secp256k1Ecurve.n) >= 0);
9320
- return new ECPair3(d, null, options);
9320
+ return new ECPair4(d, null, options);
9321
9321
  };
9322
- ECPair3.prototype.getAddress = function() {
9322
+ ECPair4.prototype.getAddress = function() {
9323
9323
  return baddress.toBase58Check(bcrypto.hash160(this.getPublicKeyBuffer()), this.getNetwork().pubKeyHash);
9324
9324
  };
9325
- ECPair3.prototype.getNetwork = function() {
9325
+ ECPair4.prototype.getNetwork = function() {
9326
9326
  return this.network;
9327
9327
  };
9328
- ECPair3.prototype.getPublicKeyBuffer = function() {
9328
+ ECPair4.prototype.getPublicKeyBuffer = function() {
9329
9329
  return this.Q.getEncoded(this.compressed);
9330
9330
  };
9331
- ECPair3.prototype.sign = function(hash) {
9331
+ ECPair4.prototype.sign = function(hash) {
9332
9332
  if (!this.d)
9333
9333
  throw new Error("Missing private key");
9334
9334
  var sig2 = fastcurve.sign(hash, this.d);
@@ -9336,26 +9336,26 @@ var require_ecpair = __commonJS({
9336
9336
  return sig2;
9337
9337
  return ecdsa.sign(hash, this.d);
9338
9338
  };
9339
- ECPair3.prototype.toWIF = function() {
9339
+ ECPair4.prototype.toWIF = function() {
9340
9340
  if (!this.d)
9341
9341
  throw new Error("Missing private key");
9342
9342
  return wif.encode(this.network.wif, this.d.toBuffer(32), this.compressed);
9343
9343
  };
9344
- ECPair3.prototype.verify = function(hash, signature) {
9344
+ ECPair4.prototype.verify = function(hash, signature) {
9345
9345
  var fastsig = fastcurve.verify(hash, signature, this.getPublicKeyBuffer());
9346
9346
  if (fastsig !== void 0)
9347
9347
  return fastsig;
9348
9348
  return ecdsa.verify(hash, signature, this.Q);
9349
9349
  };
9350
- ECPair3.fromPrivateKeyBuffer = function(buffer, network) {
9350
+ ECPair4.fromPrivateKeyBuffer = function(buffer, network) {
9351
9351
  var keyutil = require_keyutil();
9352
9352
  return keyutil.privateKeyBufferToECPair(buffer, network);
9353
9353
  };
9354
- ECPair3.prototype.getPrivateKeyBuffer = function() {
9354
+ ECPair4.prototype.getPrivateKeyBuffer = function() {
9355
9355
  var keyutil = require_keyutil();
9356
9356
  return keyutil.privateKeyBufferFromECPair(this);
9357
9357
  };
9358
- module2.exports = ECPair3;
9358
+ module2.exports = ECPair4;
9359
9359
  }
9360
9360
  });
9361
9361
 
@@ -9367,16 +9367,16 @@ var require_keyutil = __commonJS({
9367
9367
  exports2.privateKeyBufferToECPair = privateKeyBufferToECPair;
9368
9368
  exports2.privateKeyBufferFromECPair = privateKeyBufferFromECPair;
9369
9369
  var BigInteger = require_lib();
9370
- var ECPair3 = require_ecpair();
9370
+ var ECPair4 = require_ecpair();
9371
9371
  function privateKeyBufferToECPair(buffer, network) {
9372
9372
  if (!Buffer.isBuffer(buffer) || buffer.length !== 32) {
9373
9373
  throw new Error("invalid private key buffer");
9374
9374
  }
9375
9375
  var d = BigInteger.fromBuffer(buffer);
9376
- return new ECPair3(d, null, { network });
9376
+ return new ECPair4(d, null, { network });
9377
9377
  }
9378
9378
  function privateKeyBufferFromECPair(ecPair) {
9379
- if (!(ecPair instanceof ECPair3)) {
9379
+ if (!(ecPair instanceof ECPair4)) {
9380
9380
  throw new TypeError("invalid argument ecpair");
9381
9381
  }
9382
9382
  if (!ecPair.d)
@@ -10983,7 +10983,7 @@ var require_signature = __commonJS({
10983
10983
  var opcodes3 = require_bitcoin_ops();
10984
10984
  var script = require_script();
10985
10985
  var crypto2 = require_crypto();
10986
- var ECPair3 = require_ecpair();
10986
+ var ECPair4 = require_ecpair();
10987
10987
  var Transaction4 = require_transaction();
10988
10988
  var ECSignature = require_ecsignature();
10989
10989
  var networks3 = require_networks();
@@ -11106,7 +11106,7 @@ var require_signature = __commonJS({
11106
11106
  if (matchedPublicKeyIndices[publicKeyIndex]) {
11107
11107
  continue;
11108
11108
  }
11109
- var publicKey = ECPair3.fromPublicKeyBuffer(publicKeyBuffer);
11109
+ var publicKey = ECPair4.fromPublicKeyBuffer(publicKeyBuffer);
11110
11110
  if (publicKey.verify(signatureHash, signature)) {
11111
11111
  isSignatureValid = true;
11112
11112
  matchedPublicKeyIndices[publicKeyIndex] = true;
@@ -11516,35 +11516,41 @@ var require_browser = __commonJS({
11516
11516
  }
11517
11517
  });
11518
11518
 
11519
- // node_modules/.pnpm/has-flag@3.0.0/node_modules/has-flag/index.js
11519
+ // node_modules/.pnpm/has-flag@4.0.0/node_modules/has-flag/index.js
11520
11520
  var require_has_flag = __commonJS({
11521
- "node_modules/.pnpm/has-flag@3.0.0/node_modules/has-flag/index.js"(exports2, module2) {
11521
+ "node_modules/.pnpm/has-flag@4.0.0/node_modules/has-flag/index.js"(exports2, module2) {
11522
11522
  "use strict";
11523
- module2.exports = (flag, argv) => {
11524
- argv = argv || process.argv;
11523
+ module2.exports = (flag, argv = process.argv) => {
11525
11524
  const prefix = flag.startsWith("-") ? "" : flag.length === 1 ? "-" : "--";
11526
- const pos = argv.indexOf(prefix + flag);
11527
- const terminatorPos = argv.indexOf("--");
11528
- return pos !== -1 && (terminatorPos === -1 ? true : pos < terminatorPos);
11525
+ const position = argv.indexOf(prefix + flag);
11526
+ const terminatorPosition = argv.indexOf("--");
11527
+ return position !== -1 && (terminatorPosition === -1 || position < terminatorPosition);
11529
11528
  };
11530
11529
  }
11531
11530
  });
11532
11531
 
11533
- // node_modules/.pnpm/supports-color@5.5.0/node_modules/supports-color/index.js
11532
+ // node_modules/.pnpm/supports-color@7.2.0/node_modules/supports-color/index.js
11534
11533
  var require_supports_color = __commonJS({
11535
- "node_modules/.pnpm/supports-color@5.5.0/node_modules/supports-color/index.js"(exports2, module2) {
11534
+ "node_modules/.pnpm/supports-color@7.2.0/node_modules/supports-color/index.js"(exports2, module2) {
11536
11535
  "use strict";
11537
11536
  var os = require("os");
11537
+ var tty = require("tty");
11538
11538
  var hasFlag = require_has_flag();
11539
- var env = process.env;
11539
+ var { env } = process;
11540
11540
  var forceColor;
11541
- if (hasFlag("no-color") || hasFlag("no-colors") || hasFlag("color=false")) {
11542
- forceColor = false;
11541
+ if (hasFlag("no-color") || hasFlag("no-colors") || hasFlag("color=false") || hasFlag("color=never")) {
11542
+ forceColor = 0;
11543
11543
  } else if (hasFlag("color") || hasFlag("colors") || hasFlag("color=true") || hasFlag("color=always")) {
11544
- forceColor = true;
11544
+ forceColor = 1;
11545
11545
  }
11546
11546
  if ("FORCE_COLOR" in env) {
11547
- forceColor = env.FORCE_COLOR.length === 0 || parseInt(env.FORCE_COLOR, 10) !== 0;
11547
+ if (env.FORCE_COLOR === "true") {
11548
+ forceColor = 1;
11549
+ } else if (env.FORCE_COLOR === "false") {
11550
+ forceColor = 0;
11551
+ } else {
11552
+ forceColor = env.FORCE_COLOR.length === 0 ? 1 : Math.min(parseInt(env.FORCE_COLOR, 10), 3);
11553
+ }
11548
11554
  }
11549
11555
  function translateLevel(level) {
11550
11556
  if (level === 0) {
@@ -11557,8 +11563,8 @@ var require_supports_color = __commonJS({
11557
11563
  has16m: level >= 3
11558
11564
  };
11559
11565
  }
11560
- function supportsColor(stream) {
11561
- if (forceColor === false) {
11566
+ function supportsColor(haveStream, streamIsTTY) {
11567
+ if (forceColor === 0) {
11562
11568
  return 0;
11563
11569
  }
11564
11570
  if (hasFlag("color=16m") || hasFlag("color=full") || hasFlag("color=truecolor")) {
@@ -11567,19 +11573,22 @@ var require_supports_color = __commonJS({
11567
11573
  if (hasFlag("color=256")) {
11568
11574
  return 2;
11569
11575
  }
11570
- if (stream && !stream.isTTY && forceColor !== true) {
11576
+ if (haveStream && !streamIsTTY && forceColor === void 0) {
11571
11577
  return 0;
11572
11578
  }
11573
- const min = forceColor ? 1 : 0;
11579
+ const min = forceColor || 0;
11580
+ if (env.TERM === "dumb") {
11581
+ return min;
11582
+ }
11574
11583
  if (process.platform === "win32") {
11575
11584
  const osRelease = os.release().split(".");
11576
- if (Number(process.versions.node.split(".")[0]) >= 8 && Number(osRelease[0]) >= 10 && Number(osRelease[2]) >= 10586) {
11585
+ if (Number(osRelease[0]) >= 10 && Number(osRelease[2]) >= 10586) {
11577
11586
  return Number(osRelease[2]) >= 14931 ? 3 : 2;
11578
11587
  }
11579
11588
  return 1;
11580
11589
  }
11581
11590
  if ("CI" in env) {
11582
- if (["TRAVIS", "CIRCLECI", "APPVEYOR", "GITLAB_CI"].some((sign) => sign in env) || env.CI_NAME === "codeship") {
11591
+ if (["TRAVIS", "CIRCLECI", "APPVEYOR", "GITLAB_CI", "GITHUB_ACTIONS", "BUILDKITE"].some((sign) => sign in env) || env.CI_NAME === "codeship") {
11583
11592
  return 1;
11584
11593
  }
11585
11594
  return min;
@@ -11608,19 +11617,16 @@ var require_supports_color = __commonJS({
11608
11617
  if ("COLORTERM" in env) {
11609
11618
  return 1;
11610
11619
  }
11611
- if (env.TERM === "dumb") {
11612
- return min;
11613
- }
11614
11620
  return min;
11615
11621
  }
11616
11622
  function getSupportLevel(stream) {
11617
- const level = supportsColor(stream);
11623
+ const level = supportsColor(stream, stream && stream.isTTY);
11618
11624
  return translateLevel(level);
11619
11625
  }
11620
11626
  module2.exports = {
11621
11627
  supportsColor: getSupportLevel,
11622
- stdout: getSupportLevel(process.stdout),
11623
- stderr: getSupportLevel(process.stderr)
11628
+ stdout: translateLevel(supportsColor(true, tty.isatty(1))),
11629
+ stderr: translateLevel(supportsColor(true, tty.isatty(2)))
11624
11630
  };
11625
11631
  }
11626
11632
  });
@@ -11829,7 +11835,7 @@ var require_transaction_builder = __commonJS({
11829
11835
  btemplates.types.SMART_TRANSACTION
11830
11836
  ];
11831
11837
  var P2SH = SIGNABLE.concat([btemplates.types.P2WPKH, btemplates.types.P2WSH]);
11832
- var ECPair3 = require_ecpair();
11838
+ var ECPair4 = require_ecpair();
11833
11839
  var ECSignature = require_ecsignature();
11834
11840
  var Transaction4 = require_transaction();
11835
11841
  var SmartTransactionSignatures = require_smart_transaction_signatures();
@@ -11985,7 +11991,7 @@ var require_transaction_builder = __commonJS({
11985
11991
  network = network || networks3.bitcoin;
11986
11992
  var unmatched = input.signatures.concat();
11987
11993
  input.signatures = input.pubKeys.map(function(pubKey) {
11988
- var keyPair = ECPair3.fromPublicKeyBuffer(pubKey);
11994
+ var keyPair = ECPair4.fromPublicKeyBuffer(pubKey);
11989
11995
  var match;
11990
11996
  unmatched.some(function(signature, i) {
11991
11997
  if (!signature)
@@ -12905,7 +12911,7 @@ var require_hdnode = __commonJS({
12905
12911
  var types = require_types();
12906
12912
  var NETWORKS = require_networks();
12907
12913
  var BigInteger = require_lib();
12908
- var ECPair3 = require_ecpair();
12914
+ var ECPair4 = require_ecpair();
12909
12915
  var ecurve = require_lib2();
12910
12916
  var curve = ecurve.getCurveByName("secp256k1");
12911
12917
  var fastcurve = require_fastcurve();
@@ -12933,7 +12939,7 @@ var require_hdnode = __commonJS({
12933
12939
  var IL = I.slice(0, 32);
12934
12940
  var IR = I.slice(32);
12935
12941
  var pIL = BigInteger.fromBuffer(IL);
12936
- var keyPair = new ECPair3(pIL, null, {
12942
+ var keyPair = new ECPair4(pIL, null, {
12937
12943
  network
12938
12944
  });
12939
12945
  return new HDNode(keyPair, IR);
@@ -12973,11 +12979,11 @@ var require_hdnode = __commonJS({
12973
12979
  if (buffer.readUInt8(45) !== 0)
12974
12980
  throw new Error("Invalid private key");
12975
12981
  var d = BigInteger.fromBuffer(buffer.slice(46, 78));
12976
- keyPair = new ECPair3(d, null, { network });
12982
+ keyPair = new ECPair4(d, null, { network });
12977
12983
  } else {
12978
12984
  var Q = ecurve.Point.decodeFrom(curve, buffer.slice(45, 78));
12979
12985
  curve.validate(Q);
12980
- keyPair = new ECPair3(null, Q, { network });
12986
+ keyPair = new ECPair4(null, Q, { network });
12981
12987
  }
12982
12988
  var hd = new HDNode(keyPair, chainCode);
12983
12989
  hd.depth = depth;
@@ -13001,7 +13007,7 @@ var require_hdnode = __commonJS({
13001
13007
  return this.keyPair.getPublicKeyBuffer();
13002
13008
  };
13003
13009
  HDNode.prototype.neutered = function() {
13004
- var neuteredKeyPair = new ECPair3(null, this.keyPair.Q, {
13010
+ var neuteredKeyPair = new ECPair4(null, this.keyPair.Q, {
13005
13011
  network: this.keyPair.network
13006
13012
  });
13007
13013
  var neutered = new HDNode(neuteredKeyPair, this.chainCode);
@@ -13062,7 +13068,7 @@ var require_hdnode = __commonJS({
13062
13068
  if (ki.signum() === 0) {
13063
13069
  return this.derive(index + 1);
13064
13070
  }
13065
- derivedKeyPair = new ECPair3(ki, null, {
13071
+ derivedKeyPair = new ECPair4(ki, null, {
13066
13072
  network: this.keyPair.network
13067
13073
  });
13068
13074
  } else {
@@ -13071,7 +13077,7 @@ var require_hdnode = __commonJS({
13071
13077
  if (curve.isInfinity(Ki)) {
13072
13078
  return this.derive(index + 1);
13073
13079
  }
13074
- derivedKeyPair = new ECPair3(null, Ki, {
13080
+ derivedKeyPair = new ECPair4(null, Ki, {
13075
13081
  network: this.keyPair.network
13076
13082
  });
13077
13083
  }
@@ -13121,7 +13127,7 @@ var require_hdnode = __commonJS({
13121
13127
  };
13122
13128
  HDNode.prototype.cloneKeypair = function() {
13123
13129
  var k = this.keyPair;
13124
- var result = new ECPair3(k.d, k.d ? null : k.Q, {
13130
+ var result = new ECPair4(k.d, k.d ? null : k.Q, {
13125
13131
  network: k.network,
13126
13132
  compressed: k.compressed
13127
13133
  });
@@ -13148,7 +13154,7 @@ var require_identity_signature = __commonJS({
13148
13154
  var sha256 = require_crypto().sha256;
13149
13155
  var createHash3 = require("create-hash");
13150
13156
  var ECSignature = require_ecsignature();
13151
- var ECPair3 = require_ecpair();
13157
+ var ECPair4 = require_ecpair();
13152
13158
  var VERUS_DATA_SIGNATURE_PREFIX_STRING = "Verus signed data:\n";
13153
13159
  var bufferWriter = new bufferutils.BufferWriter(Buffer2.alloc(VERUS_DATA_SIGNATURE_PREFIX_STRING.length + 1));
13154
13160
  bufferWriter.writeVarSlice(Buffer2.from("Verus signed data:\n", "utf-8"));
@@ -13215,7 +13221,7 @@ var require_identity_signature = __commonJS({
13215
13221
  var compactSig;
13216
13222
  for (recid = 0; recid < 4; recid++) {
13217
13223
  compactSig = signature.toCompact(recid, true);
13218
- var recoveredKeyPair = ECPair3.recoverFromSignature(buffer, compactSig, this.network);
13224
+ var recoveredKeyPair = ECPair4.recoverFromSignature(buffer, compactSig, this.network);
13219
13225
  if (recoveredKeyPair.getAddress() === signingAddress) {
13220
13226
  this.signatures.push(compactSig);
13221
13227
  return compactSig;
@@ -13231,7 +13237,7 @@ var require_identity_signature = __commonJS({
13231
13237
  for (var i = 0; i < this.signatures.length; i++) {
13232
13238
  try {
13233
13239
  var sig = ECSignature.parseCompact(this.signatures[i]);
13234
- var pubKeyPair = ECPair3.recoverFromSignature(hash, sig.signature.toCompact(sig.i, true), this.network);
13240
+ var pubKeyPair = ECPair4.recoverFromSignature(hash, sig.signature.toCompact(sig.i, true), this.network);
13235
13241
  if (pubKeyPair.getAddress() === signingAddress) {
13236
13242
  var verification = pubKeyPair.verify(hash, sig.signature);
13237
13243
  results.push(verification);
@@ -24629,9 +24635,9 @@ var require_DefinedKey = __commonJS({
24629
24635
  }
24630
24636
  });
24631
24637
 
24632
- // node_modules/.pnpm/b4a@1.7.4/node_modules/b4a/index.js
24638
+ // node_modules/.pnpm/b4a@1.8.1/node_modules/b4a/index.js
24633
24639
  var require_b4a = __commonJS({
24634
- "node_modules/.pnpm/b4a@1.7.4/node_modules/b4a/index.js"(exports2, module2) {
24640
+ "node_modules/.pnpm/b4a@1.8.1/node_modules/b4a/index.js"(exports2, module2) {
24635
24641
  "use strict";
24636
24642
  function isBuffer(value) {
24637
24643
  return Buffer.isBuffer(value) || value instanceof Uint8Array;
@@ -32207,6 +32213,7 @@ __export(src_exports, {
32207
32213
  BASE58_RE: () => BASE58_RE,
32208
32214
  CONSENSUS_BRANCH_ID: () => CONSENSUS_BRANCH_ID,
32209
32215
  CURRENCY_TYPE_ORDER: () => CURRENCY_TYPE_ORDER,
32216
+ DEFAULT_EXPIRY_DELTA: () => DEFAULT_EXPIRY_DELTA,
32210
32217
  DEFAULT_FEE_PER_KB: () => DEFAULT_FEE_PER_KB,
32211
32218
  DEFAULT_REFERRAL_LEVELS: () => DEFAULT_REFERRAL_LEVELS,
32212
32219
  DEFAULT_REGISTRATION_FEE: () => DEFAULT_REGISTRATION_FEE,
@@ -32290,6 +32297,7 @@ var DEFAULT_REGISTRATION_FEE = 10000000000n;
32290
32297
  var DEFAULT_REFERRAL_LEVELS = 3;
32291
32298
  var RESERVE_TRANSFER_FEE = 20000n;
32292
32299
  var RESERVE_TRANSFER_EVAL_PKH = "RTqQe58LSj2yr5CrwYFwcsAQ1edQwmrkUU";
32300
+ var DEFAULT_EXPIRY_DELTA = 20;
32293
32301
  var I_ADDR_VERSION = 102;
32294
32302
  var PUBKEY_HASH_PREFIX = 60;
32295
32303
  var SCRIPT_HASH_PREFIX = 85;
@@ -32303,6 +32311,7 @@ var signing_exports = {};
32303
32311
  __export(signing_exports, {
32304
32312
  createTransactionBuilder: () => createTransactionBuilder,
32305
32313
  getNetwork: () => getNetwork,
32314
+ resolveExpiryHeight: () => resolveExpiryHeight,
32306
32315
  signTransactionMultiKey: () => signTransactionMultiKey,
32307
32316
  signTransactionSmart: () => signTransactionSmart,
32308
32317
  validateFundedTransaction: () => validateFundedTransaction
@@ -32519,6 +32528,24 @@ function summarizeSignedTransaction(hex, network) {
32519
32528
 
32520
32529
  // src/signing/index.ts
32521
32530
  var { getFundedTxBuilder, validateFundedCurrencyTransfer } = import_utxo_lib.smarttxs;
32531
+ function resolveExpiryHeight(expiryHeight) {
32532
+ if (expiryHeight === void 0) {
32533
+ throw new TransactionBuildError(
32534
+ "expiryHeight is required: pass currentBlockHeight + DEFAULT_EXPIRY_DELTA to bound the transaction (this SDK is offline and cannot read the chain tip), or expiryHeight: 0 to explicitly never expire."
32535
+ );
32536
+ }
32537
+ if (!Number.isInteger(expiryHeight) || expiryHeight < 0) {
32538
+ throw new TransactionBuildError(
32539
+ `Invalid expiryHeight: must be a non-negative integer (got ${expiryHeight})`
32540
+ );
32541
+ }
32542
+ if (expiryHeight >= 5e8) {
32543
+ throw new TransactionBuildError(
32544
+ `Invalid expiryHeight: must be below 500000000 (got ${expiryHeight}); this looks like a timestamp, not a block height`
32545
+ );
32546
+ }
32547
+ return expiryHeight;
32548
+ }
32522
32549
  function getNetwork(testnet = false) {
32523
32550
  return testnet ? import_utxo_lib.networks.verustest : import_utxo_lib.networks.verus;
32524
32551
  }
@@ -32635,13 +32662,21 @@ function decodeUtxo(utxo, systemId) {
32635
32662
  }
32636
32663
  return { ...utxo, currencyValues };
32637
32664
  }
32638
- function estimateFee(numInputs, numOutputs, feePerKb = DEFAULT_FEE_PER_KB, hasSmartOutputs = false) {
32665
+ function estimateFee(numInputs, numOutputs, feePerKb = DEFAULT_FEE_PER_KB, hasSmartOutputs = false, extraBytes = 0) {
32639
32666
  const outputSize = hasSmartOutputs ? SMART_OUTPUT_SIZE : P2PKH_OUTPUT_SIZE;
32640
- const txSize = TX_OVERHEAD + numInputs * INPUT_SIZE + numOutputs * outputSize;
32667
+ const txSize = TX_OVERHEAD + numInputs * INPUT_SIZE + numOutputs * outputSize + extraBytes;
32641
32668
  const fee = (BigInt(txSize) * feePerKb + 999n) / 1000n;
32642
32669
  return fee > MIN_FEE ? fee : MIN_FEE;
32643
32670
  }
32644
- function selectUtxos(utxos, requiredNative, requiredCurrencies = /* @__PURE__ */ new Map(), numOutputs = 2, systemId = NETWORK_CONFIG.mainnet.chainId, feePerKb = DEFAULT_FEE_PER_KB, hasSmartOutputs = false) {
32671
+ function selectUtxos(utxos, requiredNative, requiredCurrencies = /* @__PURE__ */ new Map(), numOutputs = 2, systemId = NETWORK_CONFIG.mainnet.chainId, feePerKb = DEFAULT_FEE_PER_KB, hasSmartOutputs = false, extraOutputBytes = 0) {
32672
+ const seenOutpoints = /* @__PURE__ */ new Set();
32673
+ for (const u of utxos) {
32674
+ const outpoint = `${u.txid}:${u.outputIndex}`;
32675
+ if (seenOutpoints.has(outpoint)) {
32676
+ throw new TransactionBuildError(`Duplicate UTXO in inputs: ${outpoint} appears more than once`);
32677
+ }
32678
+ seenOutpoints.add(outpoint);
32679
+ }
32645
32680
  const decoded = utxos.map((u) => decodeUtxo(u, systemId));
32646
32681
  const remaining = new Map(requiredCurrencies);
32647
32682
  let remainingNative = requiredNative;
@@ -32682,18 +32717,32 @@ function selectUtxos(utxos, requiredNative, requiredCurrencies = /* @__PURE__ */
32682
32717
  }
32683
32718
  }
32684
32719
  }
32685
- const nativeOnly = decoded.filter((u) => !selected.includes(u)).sort((a, b) => b.satoshis > a.satoshis ? 1 : b.satoshis < a.satoshis ? -1 : 0);
32686
- let changeOutputCount = 0;
32687
- for (const [currency, needed] of remaining) {
32688
- if (currency !== systemId && needed < 0n) {
32689
- changeOutputCount++;
32720
+ const carriesToken = (u) => {
32721
+ for (const [currency, amount] of u.currencyValues) {
32722
+ if (currency !== systemId && amount > 0n) return true;
32690
32723
  }
32691
- }
32724
+ return false;
32725
+ };
32726
+ const nativeOnly = decoded.filter((u) => !selected.includes(u)).sort((a, b) => {
32727
+ const at = carriesToken(a) ? 1 : 0;
32728
+ const bt = carriesToken(b) ? 1 : 0;
32729
+ if (at !== bt) return at - bt;
32730
+ return b.satoshis > a.satoshis ? 1 : b.satoshis < a.satoshis ? -1 : 0;
32731
+ });
32732
+ const countCurrencyChanges = () => {
32733
+ let n = 0;
32734
+ for (const [currency, needed] of remaining) {
32735
+ if (currency !== systemId && needed < 0n) n++;
32736
+ }
32737
+ return n;
32738
+ };
32739
+ let changeOutputCount = countCurrencyChanges();
32692
32740
  let fee = estimateFee(
32693
32741
  selected.length + 1,
32694
32742
  numOutputs + 1 + changeOutputCount,
32695
32743
  feePerKb,
32696
- hasSmartOutputs
32744
+ hasSmartOutputs,
32745
+ extraOutputBytes
32697
32746
  );
32698
32747
  while (remainingNative + fee > 0n) {
32699
32748
  const next = nativeOnly.shift();
@@ -32707,11 +32756,17 @@ function selectUtxos(utxos, requiredNative, requiredCurrencies = /* @__PURE__ */
32707
32756
  }
32708
32757
  selected.push(next);
32709
32758
  remainingNative -= next.satoshis;
32759
+ for (const [currency, amount] of next.currencyValues) {
32760
+ if (currency === systemId || amount <= 0n) continue;
32761
+ remaining.set(currency, (remaining.get(currency) || 0n) - amount);
32762
+ }
32763
+ changeOutputCount = countCurrencyChanges();
32710
32764
  fee = estimateFee(
32711
32765
  selected.length,
32712
32766
  numOutputs + 1 + changeOutputCount,
32713
32767
  feePerKb,
32714
- hasSmartOutputs
32768
+ hasSmartOutputs,
32769
+ extraOutputBytes
32715
32770
  );
32716
32771
  }
32717
32772
  const totalNativeIn = selected.reduce((sum, u) => sum + u.satoshis, 0n);
@@ -32788,7 +32843,7 @@ function validateWif(wif) {
32788
32843
  return { valid: false, error: "Invalid WIF length" };
32789
32844
  }
32790
32845
  const prefix = decoded[0];
32791
- if (prefix !== WIF_PREFIX && prefix !== 128) {
32846
+ if (prefix !== WIF_PREFIX) {
32792
32847
  return { valid: false, error: `Invalid WIF prefix: ${prefix}` };
32793
32848
  }
32794
32849
  return { valid: true };
@@ -32865,6 +32920,38 @@ var HASH160_BYTE_LENGTH = 20;
32865
32920
  var HASH256_BYTE_LENGTH = 32;
32866
32921
  var NULL_ID_HASH = Buffer.alloc(HASH160_BYTE_LENGTH, 0);
32867
32922
  var EVAL_IDENTITY_ADVANCEDRESERVATION = 10;
32923
+ function assertAddressVersion(address, expectedVersion, label) {
32924
+ let version;
32925
+ try {
32926
+ version = (0, import_verus_typescript_primitives4.fromBase58Check)(address).version;
32927
+ } catch {
32928
+ throw new TransactionBuildError(`${label} is not a valid base58check address: ${JSON.stringify(address)}`);
32929
+ }
32930
+ if (version !== expectedVersion) {
32931
+ const want = expectedVersion === I_ADDR_VERSION ? "an identity i-address" : "an R-address";
32932
+ throw new TransactionBuildError(
32933
+ `${label} must be ${want} (version ${expectedVersion}), got version ${version}: ${address}`
32934
+ );
32935
+ }
32936
+ }
32937
+ function validateMinSigs(minSigs, primaryCount) {
32938
+ if (!Number.isInteger(minSigs) || minSigs < 1 || minSigs > primaryCount) {
32939
+ throw new TransactionBuildError(
32940
+ `minSigs must be an integer between 1 and the number of primary addresses (${primaryCount}), got ${minSigs}`
32941
+ );
32942
+ }
32943
+ }
32944
+ function validateUpdateAddressParams(params) {
32945
+ params.primaryAddresses?.forEach(
32946
+ (a, i) => assertAddressVersion(a, PUBKEY_HASH_PREFIX, `primaryAddresses[${i}]`)
32947
+ );
32948
+ if (params.revocationAuthority) {
32949
+ assertAddressVersion(params.revocationAuthority, I_ADDR_VERSION, "revocationAuthority");
32950
+ }
32951
+ if (params.recoveryAuthority) {
32952
+ assertAddressVersion(params.recoveryAuthority, I_ADDR_VERSION, "recoveryAuthority");
32953
+ }
32954
+ }
32868
32955
  function generateSalt() {
32869
32956
  return (0, import_crypto2.randomBytes)(HASH256_BYTE_LENGTH);
32870
32957
  }
@@ -33022,6 +33109,12 @@ function calculateRegistrationFees(hasReferral, totalFee = DEFAULT_REGISTRATION_
33022
33109
  return { issuerFee, referralAmount, totalRequired };
33023
33110
  }
33024
33111
  function createIdentityObject(params) {
33112
+ params.primaryAddresses.forEach(
33113
+ (addr, i) => assertAddressVersion(addr, PUBKEY_HASH_PREFIX, `primaryAddresses[${i}]`)
33114
+ );
33115
+ assertAddressVersion(params.revocationAuthority, I_ADDR_VERSION, "revocationAuthority");
33116
+ assertAddressVersion(params.recoveryAuthority, I_ADDR_VERSION, "recoveryAuthority");
33117
+ validateMinSigs(params.minSigs ?? 1, params.primaryAddresses.length);
33025
33118
  const primaryKeys = params.primaryAddresses.map((addr) => import_verus_typescript_primitives2.KeyID.fromAddress(addr));
33026
33119
  const identity = new import_verus_typescript_primitives2.Identity({
33027
33120
  version: import_verus_typescript_primitives2.Identity.VERSION_CURRENT,
@@ -33079,7 +33172,17 @@ function buildRegistrationFeeOutput(parentCurrencyId, feeAmount, systemId, _cont
33079
33172
  return { script: script.toBuffer(), nativeValue: RESERVE_TRANSFER_FEE };
33080
33173
  }
33081
33174
  function buildTokenChangeOutput(changeAddress, currencyChanges) {
33082
- const destination = new import_verus_typescript_primitives2.TxDestination(import_verus_typescript_primitives2.KeyID.fromAddress(changeAddress));
33175
+ const version = (0, import_verus_typescript_primitives4.fromBase58Check)(changeAddress).version;
33176
+ let destination;
33177
+ if (version === I_ADDR_VERSION) {
33178
+ destination = new import_verus_typescript_primitives2.TxDestination(import_verus_typescript_primitives2.IdentityID.fromAddress(changeAddress));
33179
+ } else if (version === PUBKEY_HASH_PREFIX) {
33180
+ destination = new import_verus_typescript_primitives2.TxDestination(import_verus_typescript_primitives2.KeyID.fromAddress(changeAddress));
33181
+ } else {
33182
+ throw new TransactionBuildError(
33183
+ `token change address must be an R-address or identity i-address, got version ${version}: ${changeAddress}`
33184
+ );
33185
+ }
33083
33186
  const valueMap = /* @__PURE__ */ new Map();
33084
33187
  for (const [currency, amount] of currencyChanges) {
33085
33188
  if (amount > 0n) {
@@ -33155,7 +33258,7 @@ function buildAndSignCommitment(params, network) {
33155
33258
  );
33156
33259
  const txb = new import_utxo_lib3.TransactionBuilder(verusNetwork);
33157
33260
  txb.setVersion(4);
33158
- txb.setExpiryHeight(params.expiryHeight || 0);
33261
+ txb.setExpiryHeight(resolveExpiryHeight(params.expiryHeight));
33159
33262
  txb.setVersionGroupId(VERSION_GROUP_ID);
33160
33263
  for (const utxo of selection.selected) {
33161
33264
  txb.addInput(
@@ -33238,6 +33341,12 @@ function _buildVrscRegistration(params, identityScript, reservationScript, ident
33238
33341
  const referralOutputs = [];
33239
33342
  if (hasReferral) {
33240
33343
  const chain = params.referralChain && params.referralChain.length > 0 ? params.referralChain : commitData.referral ? [commitData.referral] : [];
33344
+ const referralLevels = params.referralLevels ?? DEFAULT_REFERRAL_LEVELS;
33345
+ if (chain.length > referralLevels) {
33346
+ throw new TransactionBuildError(
33347
+ `referralChain has ${chain.length} entries but at most ${referralLevels} referral levels are allowed`
33348
+ );
33349
+ }
33241
33350
  for (const referrerAddr of chain) {
33242
33351
  referralOutputs.push({
33243
33352
  script: buildReferralPaymentScript(referrerAddr),
@@ -33247,7 +33356,7 @@ function _buildVrscRegistration(params, identityScript, reservationScript, ident
33247
33356
  }
33248
33357
  const totalFee = params.registrationFee ?? DEFAULT_REGISTRATION_FEE;
33249
33358
  const totalReferralPayments = referralOutputs.reduce((sum, o) => sum + o.value, 0n);
33250
- const requiredNative = totalFee;
33359
+ const requiredNative = hasReferral ? fees.issuerFee : totalFee;
33251
33360
  const numOutputs = 2 + referralOutputs.length + 1;
33252
33361
  const selection = selectUtxos(
33253
33362
  params.utxos,
@@ -33260,7 +33369,7 @@ function _buildVrscRegistration(params, identityScript, reservationScript, ident
33260
33369
  );
33261
33370
  const txb = new import_utxo_lib3.TransactionBuilder(network);
33262
33371
  txb.setVersion(4);
33263
- txb.setExpiryHeight(params.expiryHeight || 0);
33372
+ txb.setExpiryHeight(resolveExpiryHeight(params.expiryHeight));
33264
33373
  txb.setVersionGroupId(VERSION_GROUP_ID);
33265
33374
  const commitUtxo = params.commitmentUtxo;
33266
33375
  txb.addInput(
@@ -33287,7 +33396,13 @@ function _buildVrscRegistration(params, identityScript, reservationScript, ident
33287
33396
  }
33288
33397
  const unsignedTx = txb.buildIncomplete();
33289
33398
  const allUtxos = [commitUtxo, ...selection.selected];
33290
- const expectedImplicitFee = commitUtxo.satoshis + totalFee - totalReferralPayments + selection.fee;
33399
+ const expectedImplicitFee = commitUtxo.satoshis + requiredNative - totalReferralPayments + selection.fee;
33400
+ const assembledNativeFee = allUtxos.reduce((sum, u) => sum + u.satoshis, 0n) - unsignedTx.outs.reduce((sum, o) => sum + BigInt(o.value), 0n);
33401
+ if (assembledNativeFee !== expectedImplicitFee) {
33402
+ throw new TransactionBuildError(
33403
+ `identity registration value conservation failed: assembled native fee ${assembledNativeFee} sat != intended ${expectedImplicitFee} sat`
33404
+ );
33405
+ }
33291
33406
  const { signedTx, txid } = signTransactionSmart(
33292
33407
  unsignedTx.toHex(),
33293
33408
  params.wif,
@@ -33300,7 +33415,10 @@ function _buildVrscRegistration(params, identityScript, reservationScript, ident
33300
33415
  txid,
33301
33416
  fee: selection.fee,
33302
33417
  identityAddress,
33303
- registrationFee: totalFee - totalReferralPayments,
33418
+ // The registrant's registration outlay: the discounted issuer fee when
33419
+ // referred, the full fee otherwise. (Of this, referralPayments go to the
33420
+ // referrers and the remainder is the implicit miner fee.)
33421
+ registrationFee: requiredNative,
33304
33422
  referralPayments: referralOutputs.length,
33305
33423
  referralAmountEach: fees.referralAmount,
33306
33424
  inputsUsed: allUtxos.length,
@@ -33337,7 +33455,7 @@ function _buildSubIdRegistration(params, identity, identityScript, reservationSc
33337
33455
  );
33338
33456
  const txb = new import_utxo_lib3.TransactionBuilder(network);
33339
33457
  txb.setVersion(4);
33340
- txb.setExpiryHeight(params.expiryHeight || 0);
33458
+ txb.setExpiryHeight(resolveExpiryHeight(params.expiryHeight));
33341
33459
  txb.setVersionGroupId(VERSION_GROUP_ID);
33342
33460
  const commitUtxo = params.commitmentUtxo;
33343
33461
  txb.addInput(
@@ -33402,12 +33520,23 @@ function buildAndSignIdentityUpdate(params, network, operation = "update", lockU
33402
33520
  const systemId = networkConfig.chainId;
33403
33521
  const identity = new import_verus_typescript_primitives2.Identity();
33404
33522
  identity.fromBuffer(Buffer.from(params.identityHex, "hex"));
33523
+ if (operation === "update" || operation === "lock" || operation === "unlock") {
33524
+ const signerAddress = import_utxo_lib3.ECPair.fromWIF(params.wif, verusNetwork).getAddress();
33525
+ const currentPrimaries = (identity.primary_addresses ?? []).map((k) => k.toAddress());
33526
+ if (!currentPrimaries.includes(signerAddress)) {
33527
+ throw new TransactionBuildError(
33528
+ `the provided WIF (${signerAddress}) is not among the identity's primary addresses [${currentPrimaries.join(", ")}]; it cannot authorize a ${operation}.`
33529
+ );
33530
+ }
33531
+ }
33405
33532
  switch (operation) {
33406
33533
  case "update": {
33534
+ validateUpdateAddressParams(params);
33407
33535
  if (params.primaryAddresses) {
33408
33536
  identity.setPrimaryAddresses(params.primaryAddresses);
33409
33537
  }
33410
33538
  if (params.minSigs !== void 0) {
33539
+ validateMinSigs(params.minSigs, identity.primary_addresses?.length ?? 0);
33411
33540
  identity.min_sigs = new import_bn.default(params.minSigs);
33412
33541
  }
33413
33542
  if (params.revocationAuthority) {
@@ -33418,13 +33547,26 @@ function buildAndSignIdentityUpdate(params, network, operation = "update", lockU
33418
33547
  }
33419
33548
  if (params.contentMap) {
33420
33549
  for (const [key, value] of Object.entries(params.contentMap)) {
33550
+ if (!/^[0-9a-fA-F]*$/.test(value) || value.length % 2 !== 0) {
33551
+ throw new TransactionBuildError(
33552
+ `contentMap["${key}"] must be an even-length hex string (got ${JSON.stringify(value)})`
33553
+ );
33554
+ }
33421
33555
  identity.content_map.set(key, Buffer.from(value, "hex"));
33422
33556
  }
33423
33557
  }
33424
33558
  if (params.contentMultimap) {
33425
33559
  const jsonObj = {};
33426
33560
  for (const [key, value] of Object.entries(params.contentMultimap)) {
33427
- jsonObj[key] = Array.isArray(value) ? value : [value];
33561
+ const items = Array.isArray(value) ? value : [value];
33562
+ for (const item of items) {
33563
+ if (!/^[0-9a-fA-F]*$/.test(item) || item.length % 2 !== 0) {
33564
+ throw new TransactionBuildError(
33565
+ `contentMultimap["${key}"] entries must be even-length hex strings (got ${JSON.stringify(item)})`
33566
+ );
33567
+ }
33568
+ }
33569
+ jsonObj[key] = items;
33428
33570
  }
33429
33571
  identity.content_multimap = import_verus_typescript_primitives2.ContentMultiMap.fromJson(jsonObj);
33430
33572
  }
@@ -33436,6 +33578,7 @@ function buildAndSignIdentityUpdate(params, network, operation = "update", lockU
33436
33578
  break;
33437
33579
  }
33438
33580
  case "recover": {
33581
+ validateUpdateAddressParams(params);
33439
33582
  identity.unrevoke();
33440
33583
  identity.clearContentMultiMap();
33441
33584
  if (params.primaryAddresses) {
@@ -33458,7 +33601,13 @@ function buildAndSignIdentityUpdate(params, network, operation = "update", lockU
33458
33601
  break;
33459
33602
  }
33460
33603
  case "unlock": {
33461
- identity.unlock(new import_bn.default(0), new import_bn.default(params.expiryHeight || 0));
33604
+ const unlockExpiry = resolveExpiryHeight(params.expiryHeight);
33605
+ if (unlockExpiry === 0) {
33606
+ throw new TransactionBuildError(
33607
+ "unlock requires a non-zero expiryHeight (currentBlockHeight + DEFAULT_EXPIRY_DELTA): the unlock delay is anchored to it, so 0 would bypass the timelock."
33608
+ );
33609
+ }
33610
+ identity.unlock(new import_bn.default(0), new import_bn.default(unlockExpiry));
33462
33611
  break;
33463
33612
  }
33464
33613
  }
@@ -33466,7 +33615,7 @@ function buildAndSignIdentityUpdate(params, network, operation = "update", lockU
33466
33615
  const unfundedHex = createUnfundedIdentityUpdate(
33467
33616
  identityBuf.toString("hex"),
33468
33617
  verusNetwork,
33469
- params.expiryHeight || 0
33618
+ resolveExpiryHeight(params.expiryHeight)
33470
33619
  );
33471
33620
  const selection = selectUtxos(
33472
33621
  params.utxos,
@@ -33475,11 +33624,15 @@ function buildAndSignIdentityUpdate(params, network, operation = "update", lockU
33475
33624
  1,
33476
33625
  systemId,
33477
33626
  void 0,
33478
- true
33627
+ true,
33628
+ // The identity output embeds the full serialized identity (a large
33629
+ // contentMultimap can make it multi-KB); size the fee from its real bytes
33630
+ // so a big update isn't fee-estimated below the relay minimum.
33631
+ unfundedHex.length / 2
33479
33632
  );
33480
33633
  const txb = new import_utxo_lib3.TransactionBuilder(verusNetwork);
33481
33634
  txb.setVersion(4);
33482
- txb.setExpiryHeight(params.expiryHeight || 0);
33635
+ txb.setExpiryHeight(resolveExpiryHeight(params.expiryHeight));
33483
33636
  txb.setVersionGroupId(VERSION_GROUP_ID);
33484
33637
  for (const utxo of selection.selected) {
33485
33638
  txb.addInput(
@@ -33500,6 +33653,11 @@ function buildAndSignIdentityUpdate(params, network, operation = "update", lockU
33500
33653
  const fundedHex = fundedTx.toHex();
33501
33654
  const prevOutScripts = selection.selected.map((u) => Buffer.from(u.script, "hex"));
33502
33655
  const idUtxo = params.identityUtxo;
33656
+ if (idUtxo.satoshis !== 0n) {
33657
+ throw new TransactionBuildError(
33658
+ `identityUtxo carries ${idUtxo.satoshis} native satoshis, which would be burned to miner fee (the recreated identity output is value 0). Spend that value separately before updating.`
33659
+ );
33660
+ }
33503
33661
  const completedHex = completeFundedIdentityUpdate(
33504
33662
  fundedHex,
33505
33663
  verusNetwork,
@@ -33561,21 +33719,35 @@ function parseAddress(address, addressType) {
33561
33719
  switch (addressType) {
33562
33720
  case "PKH": {
33563
33721
  type = import_verus_typescript_primitives5.DEST_PKH;
33564
- destinationBytes = decodeBase58Address(address).slice(1);
33722
+ const decoded = decodeBase58Address(address);
33723
+ if (decoded.length !== 21 || decoded[0] !== PUBKEY_HASH_PREFIX) {
33724
+ throw new InvalidAddressError(
33725
+ address,
33726
+ "addressType 'PKH' requires an R-address (transparent P2PKH); got a different address version"
33727
+ );
33728
+ }
33729
+ destinationBytes = decoded.slice(1);
33565
33730
  break;
33566
33731
  }
33567
33732
  case "ID": {
33568
33733
  type = import_verus_typescript_primitives5.DEST_ID;
33569
- destinationBytes = decodeBase58Address(address).slice(1);
33734
+ const decoded = decodeBase58Address(address);
33735
+ if (decoded.length !== 21 || decoded[0] !== I_ADDR_VERSION) {
33736
+ throw new InvalidAddressError(
33737
+ address,
33738
+ "addressType 'ID' requires an identity i-address; got a different address version"
33739
+ );
33740
+ }
33741
+ destinationBytes = decoded.slice(1);
33570
33742
  break;
33571
33743
  }
33572
33744
  case "ETH": {
33573
33745
  type = import_verus_typescript_primitives5.DEST_ETH;
33574
33746
  const addr = address.startsWith("0x") ? address.substring(2) : address;
33575
- destinationBytes = Buffer.from(addr, "hex");
33576
- if (destinationBytes.length !== 20) {
33577
- throw new InvalidAddressError(address, "ETH destination must be 20 bytes of hex");
33747
+ if (!/^[0-9a-fA-F]{40}$/.test(addr)) {
33748
+ throw new InvalidAddressError(address, "ETH destination must be exactly 20 bytes (40 hex chars)");
33578
33749
  }
33750
+ destinationBytes = Buffer.from(addr, "hex");
33579
33751
  break;
33580
33752
  }
33581
33753
  default:
@@ -33604,7 +33776,7 @@ function sendCurrency(params, network) {
33604
33776
  const networkConfig = NETWORK_CONFIG[network];
33605
33777
  const verusNetwork = getNetwork(network === "testnet");
33606
33778
  const systemId = networkConfig.chainId;
33607
- const expiryHeight = params.expiryHeight || 0;
33779
+ const expiryHeight = resolveExpiryHeight(params.expiryHeight);
33608
33780
  const txOutputs = params.outputs.map((out) => ({
33609
33781
  currency: out.currency,
33610
33782
  satoshis: out.satoshis.toString(10),
@@ -33639,6 +33811,12 @@ function sendCurrency(params, network) {
33639
33811
  (requiredCurrencies.get(out.currency) || 0n) + out.satoshis
33640
33812
  );
33641
33813
  }
33814
+ if (out.feeCurrency !== void 0 && out.feeCurrency !== systemId && out.feeSatoshis !== void 0) {
33815
+ requiredCurrencies.set(
33816
+ out.feeCurrency,
33817
+ (requiredCurrencies.get(out.feeCurrency) || 0n) + out.feeSatoshis
33818
+ );
33819
+ }
33642
33820
  }
33643
33821
  const selection = selectUtxos(
33644
33822
  params.utxos,
@@ -33719,7 +33897,7 @@ function transfer(params, network) {
33719
33897
  }],
33720
33898
  utxos: params.utxos,
33721
33899
  changeAddress: params.changeAddress,
33722
- ...params.expiryHeight !== void 0 ? { expiryHeight: params.expiryHeight } : {}
33900
+ expiryHeight: params.expiryHeight
33723
33901
  }, network);
33724
33902
  }
33725
33903
  function transferToken(params, network) {
@@ -33734,7 +33912,7 @@ function transferToken(params, network) {
33734
33912
  }],
33735
33913
  utxos: params.utxos,
33736
33914
  changeAddress: params.changeAddress,
33737
- ...params.expiryHeight !== void 0 ? { expiryHeight: params.expiryHeight } : {}
33915
+ expiryHeight: params.expiryHeight
33738
33916
  }, network);
33739
33917
  }
33740
33918
  function convert(params, network) {
@@ -33752,7 +33930,7 @@ function convert(params, network) {
33752
33930
  }],
33753
33931
  utxos: params.utxos,
33754
33932
  changeAddress: params.changeAddress,
33755
- ...params.expiryHeight !== void 0 ? { expiryHeight: params.expiryHeight } : {}
33933
+ expiryHeight: params.expiryHeight
33756
33934
  }, network);
33757
33935
  }
33758
33936
  function buildAndSign(params, network) {
@@ -33784,7 +33962,7 @@ function buildAndSign(params, network) {
33784
33962
  }
33785
33963
  const txb = new import_utxo_lib4.TransactionBuilder(verusNetwork);
33786
33964
  txb.setVersion(4);
33787
- txb.setExpiryHeight(params.expiryHeight || 0);
33965
+ txb.setExpiryHeight(resolveExpiryHeight(params.expiryHeight));
33788
33966
  txb.setVersionGroupId(VERSION_GROUP_ID);
33789
33967
  for (const inp of params.inputs) {
33790
33968
  txb.addInput(
@@ -33933,11 +34111,12 @@ function defineCurrency(params, network) {
33933
34111
  2,
33934
34112
  systemId,
33935
34113
  void 0,
33936
- true
34114
+ true,
34115
+ identityOutputScript.length + currencyDefScript.length
33937
34116
  );
33938
34117
  const txb = new import_utxo_lib6.TransactionBuilder(verusNetwork);
33939
34118
  txb.setVersion(4);
33940
- txb.setExpiryHeight(params.expiryHeight || 0);
34119
+ txb.setExpiryHeight(resolveExpiryHeight(params.expiryHeight));
33941
34120
  txb.setVersionGroupId(VERSION_GROUP_ID);
33942
34121
  for (const utxo of selection.selected) {
33943
34122
  txb.addInput(
@@ -33956,6 +34135,11 @@ function defineCurrency(params, network) {
33956
34135
  const fundedHex = fundedTx.toHex();
33957
34136
  const prevOutScripts = selection.selected.map((u) => Buffer.from(u.script, "hex"));
33958
34137
  const idUtxo = params.identityUtxo;
34138
+ if (idUtxo.satoshis !== 0n) {
34139
+ throw new TransactionBuildError(
34140
+ `identityUtxo carries ${idUtxo.satoshis} native satoshis, which would be burned to miner fee (the recreated identity output is value 0). Spend that value separately first.`
34141
+ );
34142
+ }
33959
34143
  const completedHex = completeFundedIdentityUpdate2(
33960
34144
  fundedHex,
33961
34145
  verusNetwork,
@@ -34032,7 +34216,7 @@ var VerusSDK = class {
34032
34216
  identityUtxo: params.identityUtxo,
34033
34217
  utxos: params.utxos,
34034
34218
  changeAddress: params.changeAddress,
34035
- ...params.expiryHeight !== void 0 ? { expiryHeight: params.expiryHeight } : {}
34219
+ expiryHeight: params.expiryHeight
34036
34220
  },
34037
34221
  this.network,
34038
34222
  "lock",
@@ -34048,7 +34232,7 @@ var VerusSDK = class {
34048
34232
  identityUtxo: params.identityUtxo,
34049
34233
  utxos: params.utxos,
34050
34234
  changeAddress: params.changeAddress,
34051
- ...params.expiryHeight !== void 0 ? { expiryHeight: params.expiryHeight } : {}
34235
+ expiryHeight: params.expiryHeight
34052
34236
  },
34053
34237
  this.network,
34054
34238
  "unlock"
@@ -34063,7 +34247,7 @@ var VerusSDK = class {
34063
34247
  identityUtxo: params.identityUtxo,
34064
34248
  utxos: params.utxos,
34065
34249
  changeAddress: params.changeAddress,
34066
- ...params.expiryHeight !== void 0 ? { expiryHeight: params.expiryHeight } : {}
34250
+ expiryHeight: params.expiryHeight
34067
34251
  },
34068
34252
  this.network,
34069
34253
  "revoke"
@@ -34081,7 +34265,7 @@ var VerusSDK = class {
34081
34265
  ...params.primaryAddresses !== void 0 ? { primaryAddresses: params.primaryAddresses } : {},
34082
34266
  ...params.revocationAuthority !== void 0 ? { revocationAuthority: params.revocationAuthority } : {},
34083
34267
  ...params.recoveryAuthority !== void 0 ? { recoveryAuthority: params.recoveryAuthority } : {},
34084
- ...params.expiryHeight !== void 0 ? { expiryHeight: params.expiryHeight } : {}
34268
+ expiryHeight: params.expiryHeight
34085
34269
  },
34086
34270
  this.network,
34087
34271
  "recover"
@@ -34153,6 +34337,7 @@ function isIdentityName(input) {
34153
34337
  BASE58_RE,
34154
34338
  CONSENSUS_BRANCH_ID,
34155
34339
  CURRENCY_TYPE_ORDER,
34340
+ DEFAULT_EXPIRY_DELTA,
34156
34341
  DEFAULT_FEE_PER_KB,
34157
34342
  DEFAULT_REFERRAL_LEVELS,
34158
34343
  DEFAULT_REGISTRATION_FEE,