@chainvue/verus-sdk 0.6.0 → 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;
@@ -11835,7 +11835,7 @@ var require_transaction_builder = __commonJS({
11835
11835
  btemplates.types.SMART_TRANSACTION
11836
11836
  ];
11837
11837
  var P2SH = SIGNABLE.concat([btemplates.types.P2WPKH, btemplates.types.P2WSH]);
11838
- var ECPair3 = require_ecpair();
11838
+ var ECPair4 = require_ecpair();
11839
11839
  var ECSignature = require_ecsignature();
11840
11840
  var Transaction4 = require_transaction();
11841
11841
  var SmartTransactionSignatures = require_smart_transaction_signatures();
@@ -11991,7 +11991,7 @@ var require_transaction_builder = __commonJS({
11991
11991
  network = network || networks3.bitcoin;
11992
11992
  var unmatched = input.signatures.concat();
11993
11993
  input.signatures = input.pubKeys.map(function(pubKey) {
11994
- var keyPair = ECPair3.fromPublicKeyBuffer(pubKey);
11994
+ var keyPair = ECPair4.fromPublicKeyBuffer(pubKey);
11995
11995
  var match;
11996
11996
  unmatched.some(function(signature, i) {
11997
11997
  if (!signature)
@@ -12911,7 +12911,7 @@ var require_hdnode = __commonJS({
12911
12911
  var types = require_types();
12912
12912
  var NETWORKS = require_networks();
12913
12913
  var BigInteger = require_lib();
12914
- var ECPair3 = require_ecpair();
12914
+ var ECPair4 = require_ecpair();
12915
12915
  var ecurve = require_lib2();
12916
12916
  var curve = ecurve.getCurveByName("secp256k1");
12917
12917
  var fastcurve = require_fastcurve();
@@ -12939,7 +12939,7 @@ var require_hdnode = __commonJS({
12939
12939
  var IL = I.slice(0, 32);
12940
12940
  var IR = I.slice(32);
12941
12941
  var pIL = BigInteger.fromBuffer(IL);
12942
- var keyPair = new ECPair3(pIL, null, {
12942
+ var keyPair = new ECPair4(pIL, null, {
12943
12943
  network
12944
12944
  });
12945
12945
  return new HDNode(keyPair, IR);
@@ -12979,11 +12979,11 @@ var require_hdnode = __commonJS({
12979
12979
  if (buffer.readUInt8(45) !== 0)
12980
12980
  throw new Error("Invalid private key");
12981
12981
  var d = BigInteger.fromBuffer(buffer.slice(46, 78));
12982
- keyPair = new ECPair3(d, null, { network });
12982
+ keyPair = new ECPair4(d, null, { network });
12983
12983
  } else {
12984
12984
  var Q = ecurve.Point.decodeFrom(curve, buffer.slice(45, 78));
12985
12985
  curve.validate(Q);
12986
- keyPair = new ECPair3(null, Q, { network });
12986
+ keyPair = new ECPair4(null, Q, { network });
12987
12987
  }
12988
12988
  var hd = new HDNode(keyPair, chainCode);
12989
12989
  hd.depth = depth;
@@ -13007,7 +13007,7 @@ var require_hdnode = __commonJS({
13007
13007
  return this.keyPair.getPublicKeyBuffer();
13008
13008
  };
13009
13009
  HDNode.prototype.neutered = function() {
13010
- var neuteredKeyPair = new ECPair3(null, this.keyPair.Q, {
13010
+ var neuteredKeyPair = new ECPair4(null, this.keyPair.Q, {
13011
13011
  network: this.keyPair.network
13012
13012
  });
13013
13013
  var neutered = new HDNode(neuteredKeyPair, this.chainCode);
@@ -13068,7 +13068,7 @@ var require_hdnode = __commonJS({
13068
13068
  if (ki.signum() === 0) {
13069
13069
  return this.derive(index + 1);
13070
13070
  }
13071
- derivedKeyPair = new ECPair3(ki, null, {
13071
+ derivedKeyPair = new ECPair4(ki, null, {
13072
13072
  network: this.keyPair.network
13073
13073
  });
13074
13074
  } else {
@@ -13077,7 +13077,7 @@ var require_hdnode = __commonJS({
13077
13077
  if (curve.isInfinity(Ki)) {
13078
13078
  return this.derive(index + 1);
13079
13079
  }
13080
- derivedKeyPair = new ECPair3(null, Ki, {
13080
+ derivedKeyPair = new ECPair4(null, Ki, {
13081
13081
  network: this.keyPair.network
13082
13082
  });
13083
13083
  }
@@ -13127,7 +13127,7 @@ var require_hdnode = __commonJS({
13127
13127
  };
13128
13128
  HDNode.prototype.cloneKeypair = function() {
13129
13129
  var k = this.keyPair;
13130
- var result = new ECPair3(k.d, k.d ? null : k.Q, {
13130
+ var result = new ECPair4(k.d, k.d ? null : k.Q, {
13131
13131
  network: k.network,
13132
13132
  compressed: k.compressed
13133
13133
  });
@@ -13154,7 +13154,7 @@ var require_identity_signature = __commonJS({
13154
13154
  var sha256 = require_crypto().sha256;
13155
13155
  var createHash3 = require("create-hash");
13156
13156
  var ECSignature = require_ecsignature();
13157
- var ECPair3 = require_ecpair();
13157
+ var ECPair4 = require_ecpair();
13158
13158
  var VERUS_DATA_SIGNATURE_PREFIX_STRING = "Verus signed data:\n";
13159
13159
  var bufferWriter = new bufferutils.BufferWriter(Buffer2.alloc(VERUS_DATA_SIGNATURE_PREFIX_STRING.length + 1));
13160
13160
  bufferWriter.writeVarSlice(Buffer2.from("Verus signed data:\n", "utf-8"));
@@ -13221,7 +13221,7 @@ var require_identity_signature = __commonJS({
13221
13221
  var compactSig;
13222
13222
  for (recid = 0; recid < 4; recid++) {
13223
13223
  compactSig = signature.toCompact(recid, true);
13224
- var recoveredKeyPair = ECPair3.recoverFromSignature(buffer, compactSig, this.network);
13224
+ var recoveredKeyPair = ECPair4.recoverFromSignature(buffer, compactSig, this.network);
13225
13225
  if (recoveredKeyPair.getAddress() === signingAddress) {
13226
13226
  this.signatures.push(compactSig);
13227
13227
  return compactSig;
@@ -13237,7 +13237,7 @@ var require_identity_signature = __commonJS({
13237
13237
  for (var i = 0; i < this.signatures.length; i++) {
13238
13238
  try {
13239
13239
  var sig = ECSignature.parseCompact(this.signatures[i]);
13240
- 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);
13241
13241
  if (pubKeyPair.getAddress() === signingAddress) {
13242
13242
  var verification = pubKeyPair.verify(hash, sig.signature);
13243
13243
  results.push(verification);
@@ -32539,6 +32539,11 @@ function resolveExpiryHeight(expiryHeight) {
32539
32539
  `Invalid expiryHeight: must be a non-negative integer (got ${expiryHeight})`
32540
32540
  );
32541
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
+ }
32542
32547
  return expiryHeight;
32543
32548
  }
32544
32549
  function getNetwork(testnet = false) {
@@ -32657,13 +32662,13 @@ function decodeUtxo(utxo, systemId) {
32657
32662
  }
32658
32663
  return { ...utxo, currencyValues };
32659
32664
  }
32660
- 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) {
32661
32666
  const outputSize = hasSmartOutputs ? SMART_OUTPUT_SIZE : P2PKH_OUTPUT_SIZE;
32662
- const txSize = TX_OVERHEAD + numInputs * INPUT_SIZE + numOutputs * outputSize;
32667
+ const txSize = TX_OVERHEAD + numInputs * INPUT_SIZE + numOutputs * outputSize + extraBytes;
32663
32668
  const fee = (BigInt(txSize) * feePerKb + 999n) / 1000n;
32664
32669
  return fee > MIN_FEE ? fee : MIN_FEE;
32665
32670
  }
32666
- 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) {
32667
32672
  const seenOutpoints = /* @__PURE__ */ new Set();
32668
32673
  for (const u of utxos) {
32669
32674
  const outpoint = `${u.txid}:${u.outputIndex}`;
@@ -32712,18 +32717,32 @@ function selectUtxos(utxos, requiredNative, requiredCurrencies = /* @__PURE__ */
32712
32717
  }
32713
32718
  }
32714
32719
  }
32715
- const nativeOnly = decoded.filter((u) => !selected.includes(u)).sort((a, b) => b.satoshis > a.satoshis ? 1 : b.satoshis < a.satoshis ? -1 : 0);
32716
- let changeOutputCount = 0;
32717
- for (const [currency, needed] of remaining) {
32718
- if (currency !== systemId && needed < 0n) {
32719
- changeOutputCount++;
32720
+ const carriesToken = (u) => {
32721
+ for (const [currency, amount] of u.currencyValues) {
32722
+ if (currency !== systemId && amount > 0n) return true;
32720
32723
  }
32721
- }
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();
32722
32740
  let fee = estimateFee(
32723
32741
  selected.length + 1,
32724
32742
  numOutputs + 1 + changeOutputCount,
32725
32743
  feePerKb,
32726
- hasSmartOutputs
32744
+ hasSmartOutputs,
32745
+ extraOutputBytes
32727
32746
  );
32728
32747
  while (remainingNative + fee > 0n) {
32729
32748
  const next = nativeOnly.shift();
@@ -32737,11 +32756,17 @@ function selectUtxos(utxos, requiredNative, requiredCurrencies = /* @__PURE__ */
32737
32756
  }
32738
32757
  selected.push(next);
32739
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();
32740
32764
  fee = estimateFee(
32741
32765
  selected.length,
32742
32766
  numOutputs + 1 + changeOutputCount,
32743
32767
  feePerKb,
32744
- hasSmartOutputs
32768
+ hasSmartOutputs,
32769
+ extraOutputBytes
32745
32770
  );
32746
32771
  }
32747
32772
  const totalNativeIn = selected.reduce((sum, u) => sum + u.satoshis, 0n);
@@ -32895,6 +32920,38 @@ var HASH160_BYTE_LENGTH = 20;
32895
32920
  var HASH256_BYTE_LENGTH = 32;
32896
32921
  var NULL_ID_HASH = Buffer.alloc(HASH160_BYTE_LENGTH, 0);
32897
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
+ }
32898
32955
  function generateSalt() {
32899
32956
  return (0, import_crypto2.randomBytes)(HASH256_BYTE_LENGTH);
32900
32957
  }
@@ -33052,6 +33109,12 @@ function calculateRegistrationFees(hasReferral, totalFee = DEFAULT_REGISTRATION_
33052
33109
  return { issuerFee, referralAmount, totalRequired };
33053
33110
  }
33054
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);
33055
33118
  const primaryKeys = params.primaryAddresses.map((addr) => import_verus_typescript_primitives2.KeyID.fromAddress(addr));
33056
33119
  const identity = new import_verus_typescript_primitives2.Identity({
33057
33120
  version: import_verus_typescript_primitives2.Identity.VERSION_CURRENT,
@@ -33109,7 +33172,17 @@ function buildRegistrationFeeOutput(parentCurrencyId, feeAmount, systemId, _cont
33109
33172
  return { script: script.toBuffer(), nativeValue: RESERVE_TRANSFER_FEE };
33110
33173
  }
33111
33174
  function buildTokenChangeOutput(changeAddress, currencyChanges) {
33112
- 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
+ }
33113
33186
  const valueMap = /* @__PURE__ */ new Map();
33114
33187
  for (const [currency, amount] of currencyChanges) {
33115
33188
  if (amount > 0n) {
@@ -33268,6 +33341,12 @@ function _buildVrscRegistration(params, identityScript, reservationScript, ident
33268
33341
  const referralOutputs = [];
33269
33342
  if (hasReferral) {
33270
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
+ }
33271
33350
  for (const referrerAddr of chain) {
33272
33351
  referralOutputs.push({
33273
33352
  script: buildReferralPaymentScript(referrerAddr),
@@ -33277,7 +33356,7 @@ function _buildVrscRegistration(params, identityScript, reservationScript, ident
33277
33356
  }
33278
33357
  const totalFee = params.registrationFee ?? DEFAULT_REGISTRATION_FEE;
33279
33358
  const totalReferralPayments = referralOutputs.reduce((sum, o) => sum + o.value, 0n);
33280
- const requiredNative = totalFee;
33359
+ const requiredNative = hasReferral ? fees.issuerFee : totalFee;
33281
33360
  const numOutputs = 2 + referralOutputs.length + 1;
33282
33361
  const selection = selectUtxos(
33283
33362
  params.utxos,
@@ -33317,7 +33396,7 @@ function _buildVrscRegistration(params, identityScript, reservationScript, ident
33317
33396
  }
33318
33397
  const unsignedTx = txb.buildIncomplete();
33319
33398
  const allUtxos = [commitUtxo, ...selection.selected];
33320
- const expectedImplicitFee = commitUtxo.satoshis + totalFee - totalReferralPayments + selection.fee;
33399
+ const expectedImplicitFee = commitUtxo.satoshis + requiredNative - totalReferralPayments + selection.fee;
33321
33400
  const assembledNativeFee = allUtxos.reduce((sum, u) => sum + u.satoshis, 0n) - unsignedTx.outs.reduce((sum, o) => sum + BigInt(o.value), 0n);
33322
33401
  if (assembledNativeFee !== expectedImplicitFee) {
33323
33402
  throw new TransactionBuildError(
@@ -33336,7 +33415,10 @@ function _buildVrscRegistration(params, identityScript, reservationScript, ident
33336
33415
  txid,
33337
33416
  fee: selection.fee,
33338
33417
  identityAddress,
33339
- 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,
33340
33422
  referralPayments: referralOutputs.length,
33341
33423
  referralAmountEach: fees.referralAmount,
33342
33424
  inputsUsed: allUtxos.length,
@@ -33438,12 +33520,23 @@ function buildAndSignIdentityUpdate(params, network, operation = "update", lockU
33438
33520
  const systemId = networkConfig.chainId;
33439
33521
  const identity = new import_verus_typescript_primitives2.Identity();
33440
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
+ }
33441
33532
  switch (operation) {
33442
33533
  case "update": {
33534
+ validateUpdateAddressParams(params);
33443
33535
  if (params.primaryAddresses) {
33444
33536
  identity.setPrimaryAddresses(params.primaryAddresses);
33445
33537
  }
33446
33538
  if (params.minSigs !== void 0) {
33539
+ validateMinSigs(params.minSigs, identity.primary_addresses?.length ?? 0);
33447
33540
  identity.min_sigs = new import_bn.default(params.minSigs);
33448
33541
  }
33449
33542
  if (params.revocationAuthority) {
@@ -33465,7 +33558,15 @@ function buildAndSignIdentityUpdate(params, network, operation = "update", lockU
33465
33558
  if (params.contentMultimap) {
33466
33559
  const jsonObj = {};
33467
33560
  for (const [key, value] of Object.entries(params.contentMultimap)) {
33468
- 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;
33469
33570
  }
33470
33571
  identity.content_multimap = import_verus_typescript_primitives2.ContentMultiMap.fromJson(jsonObj);
33471
33572
  }
@@ -33477,6 +33578,7 @@ function buildAndSignIdentityUpdate(params, network, operation = "update", lockU
33477
33578
  break;
33478
33579
  }
33479
33580
  case "recover": {
33581
+ validateUpdateAddressParams(params);
33480
33582
  identity.unrevoke();
33481
33583
  identity.clearContentMultiMap();
33482
33584
  if (params.primaryAddresses) {
@@ -33499,7 +33601,13 @@ function buildAndSignIdentityUpdate(params, network, operation = "update", lockU
33499
33601
  break;
33500
33602
  }
33501
33603
  case "unlock": {
33502
- identity.unlock(new import_bn.default(0), new import_bn.default(resolveExpiryHeight(params.expiryHeight)));
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));
33503
33611
  break;
33504
33612
  }
33505
33613
  }
@@ -33516,7 +33624,11 @@ function buildAndSignIdentityUpdate(params, network, operation = "update", lockU
33516
33624
  1,
33517
33625
  systemId,
33518
33626
  void 0,
33519
- 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
33520
33632
  );
33521
33633
  const txb = new import_utxo_lib3.TransactionBuilder(verusNetwork);
33522
33634
  txb.setVersion(4);
@@ -33541,6 +33653,11 @@ function buildAndSignIdentityUpdate(params, network, operation = "update", lockU
33541
33653
  const fundedHex = fundedTx.toHex();
33542
33654
  const prevOutScripts = selection.selected.map((u) => Buffer.from(u.script, "hex"));
33543
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
+ }
33544
33661
  const completedHex = completeFundedIdentityUpdate(
33545
33662
  fundedHex,
33546
33663
  verusNetwork,
@@ -33627,10 +33744,10 @@ function parseAddress(address, addressType) {
33627
33744
  case "ETH": {
33628
33745
  type = import_verus_typescript_primitives5.DEST_ETH;
33629
33746
  const addr = address.startsWith("0x") ? address.substring(2) : address;
33630
- destinationBytes = Buffer.from(addr, "hex");
33631
- if (destinationBytes.length !== 20) {
33632
- 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)");
33633
33749
  }
33750
+ destinationBytes = Buffer.from(addr, "hex");
33634
33751
  break;
33635
33752
  }
33636
33753
  default:
@@ -33694,6 +33811,12 @@ function sendCurrency(params, network) {
33694
33811
  (requiredCurrencies.get(out.currency) || 0n) + out.satoshis
33695
33812
  );
33696
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
+ }
33697
33820
  }
33698
33821
  const selection = selectUtxos(
33699
33822
  params.utxos,
@@ -33988,7 +34111,8 @@ function defineCurrency(params, network) {
33988
34111
  2,
33989
34112
  systemId,
33990
34113
  void 0,
33991
- true
34114
+ true,
34115
+ identityOutputScript.length + currencyDefScript.length
33992
34116
  );
33993
34117
  const txb = new import_utxo_lib6.TransactionBuilder(verusNetwork);
33994
34118
  txb.setVersion(4);
@@ -34011,6 +34135,11 @@ function defineCurrency(params, network) {
34011
34135
  const fundedHex = fundedTx.toHex();
34012
34136
  const prevOutScripts = selection.selected.map((u) => Buffer.from(u.script, "hex"));
34013
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
+ }
34014
34143
  const completedHex = completeFundedIdentityUpdate2(
34015
34144
  fundedHex,
34016
34145
  verusNetwork,
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/currency/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AAGH,OAAO,EAAE,gBAAgB,EAAE,mBAAmB,EAAE,MAAM,eAAe,CAAC;AACtE,YAAY,EAAE,YAAY,EAAE,MAAM,eAAe,CAAC;AAMlD,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,uBAAuB,CAAC;AAIrD,OAAO,KAAK,EAAQ,oBAAoB,EAAE,oBAAoB,EAAE,MAAM,mBAAmB,CAAC;AAI1F;;;;GAIG;AACH,wBAAgB,cAAc,CAC5B,MAAM,EAAE,oBAAoB,EAC5B,OAAO,EAAE,OAAO,GACf,oBAAoB,CAsFtB"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/currency/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AAGH,OAAO,EAAE,gBAAgB,EAAE,mBAAmB,EAAE,MAAM,eAAe,CAAC;AACtE,YAAY,EAAE,YAAY,EAAE,MAAM,eAAe,CAAC;AAMlD,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,uBAAuB,CAAC;AAKrD,OAAO,KAAK,EAAQ,oBAAoB,EAAE,oBAAoB,EAAE,MAAM,mBAAmB,CAAC;AAI1F;;;;GAIG;AACH,wBAAgB,cAAc,CAC5B,MAAM,EAAE,oBAAoB,EAC5B,OAAO,EAAE,OAAO,GACf,oBAAoB,CAiGtB"}
@@ -27,6 +27,7 @@ const index_js_1 = require("../constants/index.js");
27
27
  const index_js_2 = require("../signing/index.js");
28
28
  const index_js_3 = require("../utxo/index.js");
29
29
  const index_js_4 = require("../utils/index.js");
30
+ const errors_js_1 = require("../errors.js");
30
31
  const { completeFundedIdentityUpdate } = utxo_lib_1.smarttxs;
31
32
  /**
32
33
  * Build and sign a currency definition transaction (manual mode)
@@ -48,8 +49,10 @@ function defineCurrency(params, network) {
48
49
  const identityScript = verus_typescript_primitives_1.IdentityScript.fromIdentity(identity);
49
50
  const identityOutputScript = identityScript.toBuffer();
50
51
  const currencyDefScript = Buffer.from(params.currencyDefScript, 'hex');
51
- // Select funding UTXOs
52
- const selection = (0, index_js_3.selectUtxos)(params.utxos, currencyDefValue, new Map(), 2, systemId, undefined, true);
52
+ // Select funding UTXOs. The identity + currency-definition outputs can be
53
+ // large; size the fee from their real byte length so the tx isn't estimated
54
+ // below the relay minimum.
55
+ const selection = (0, index_js_3.selectUtxos)(params.utxos, currencyDefValue, new Map(), 2, systemId, undefined, true, identityOutputScript.length + currencyDefScript.length);
53
56
  // Build transaction
54
57
  const txb = new utxo_lib_1.TransactionBuilder(verusNetwork);
55
58
  txb.setVersion(4);
@@ -68,6 +71,12 @@ function defineCurrency(params, network) {
68
71
  // Add the previous identity UTXO as last input
69
72
  const prevOutScripts = selection.selected.map(u => Buffer.from(u.script, 'hex'));
70
73
  const idUtxo = params.identityUtxo;
74
+ // Any native value on the identity input would be burned to miner fee (the
75
+ // recreated identity output is value 0). Identity outputs normally carry 0.
76
+ if (idUtxo.satoshis !== 0n) {
77
+ throw new errors_js_1.TransactionBuildError(`identityUtxo carries ${idUtxo.satoshis} native satoshis, which would be burned to miner fee ` +
78
+ `(the recreated identity output is value 0). Spend that value separately first.`);
79
+ }
71
80
  const completedHex = completeFundedIdentityUpdate(fundedHex, verusNetwork, prevOutScripts, {
72
81
  hash: Buffer.from(idUtxo.txid, 'hex').reverse(),
73
82
  index: idUtxo.outputIndex,
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/currency/index.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;GAUG;;;;;;AAuBH,wCAyFC;AA9GD,qCAAqC;AACrC,6CAAsE;AAA7D,+GAAA,gBAAgB,OAAA;AAAE,kHAAA,mBAAmB,OAAA;AAG9C,8CAA+D;AAC/D,6EAAuE;AACvE,kDAAuB;AACvB,oDAAuG;AAEvG,kDAA4F;AAC5F,+CAA+C;AAC/C,gDAAiD;AAGjD,MAAM,EAAE,4BAA4B,EAAE,GAAG,mBAAQ,CAAC;AAElD;;;;GAI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