@chainvue/verus-sdk 0.6.2 → 0.7.0

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
@@ -10364,7 +10364,7 @@ var require_transaction = __commonJS({
10364
10364
  return sum + varSliceSize(witness);
10365
10365
  }, 0);
10366
10366
  }
10367
- function Transaction4(network) {
10367
+ function Transaction5(network) {
10368
10368
  if (network === void 0) {
10369
10369
  network = networks3.bitcoin;
10370
10370
  }
@@ -10387,15 +10387,15 @@ var require_transaction = __commonJS({
10387
10387
  this.extraPayload = Buffer2.alloc(0);
10388
10388
  }
10389
10389
  }
10390
- Transaction4.DEFAULT_SEQUENCE = 4294967295;
10391
- Transaction4.SIGHASH_ALL = 1;
10392
- Transaction4.SIGHASH_NONE = 2;
10393
- Transaction4.SIGHASH_SINGLE = 3;
10394
- Transaction4.SIGHASH_ANYONECANPAY = 128;
10395
- Transaction4.SIGHASH_FORKID = 64;
10396
- Transaction4.SIGHASH_BITCOINCASHBIP143 = Transaction4.SIGHASH_FORKID;
10397
- Transaction4.ADVANCED_TRANSACTION_MARKER = 0;
10398
- Transaction4.ADVANCED_TRANSACTION_FLAG = 1;
10390
+ Transaction5.DEFAULT_SEQUENCE = 4294967295;
10391
+ Transaction5.SIGHASH_ALL = 1;
10392
+ Transaction5.SIGHASH_NONE = 2;
10393
+ Transaction5.SIGHASH_SINGLE = 3;
10394
+ Transaction5.SIGHASH_ANYONECANPAY = 128;
10395
+ Transaction5.SIGHASH_FORKID = 64;
10396
+ Transaction5.SIGHASH_BITCOINCASHBIP143 = Transaction5.SIGHASH_FORKID;
10397
+ Transaction5.ADVANCED_TRANSACTION_MARKER = 0;
10398
+ Transaction5.ADVANCED_TRANSACTION_FLAG = 1;
10399
10399
  var EMPTY_SCRIPT = Buffer2.allocUnsafe(0);
10400
10400
  var EMPTY_WITNESS = [];
10401
10401
  var ZERO = Buffer2.from("0000000000000000000000000000000000000000000000000000000000000000", "hex");
@@ -10406,19 +10406,19 @@ var require_transaction = __commonJS({
10406
10406
  script: EMPTY_SCRIPT,
10407
10407
  valueBuffer: VALUE_UINT64_MAX
10408
10408
  };
10409
- Transaction4.DASH_NORMAL = 0;
10410
- Transaction4.DASH_PROVIDER_REGISTER = 1;
10411
- Transaction4.DASH_PROVIDER_UPDATE_SERVICE = 2;
10412
- Transaction4.DASH_PROVIDER_UPDATE_REGISTRAR = 3;
10413
- Transaction4.DASH_PROVIDER_UPDATE_REVOKE = 4;
10414
- Transaction4.DASH_COINBASE = 5;
10415
- Transaction4.DASH_QUORUM_COMMITMENT = 6;
10416
- Transaction4.fromBuffer = function(buffer, network, __noStrict) {
10409
+ Transaction5.DASH_NORMAL = 0;
10410
+ Transaction5.DASH_PROVIDER_REGISTER = 1;
10411
+ Transaction5.DASH_PROVIDER_UPDATE_SERVICE = 2;
10412
+ Transaction5.DASH_PROVIDER_UPDATE_REGISTRAR = 3;
10413
+ Transaction5.DASH_PROVIDER_UPDATE_REVOKE = 4;
10414
+ Transaction5.DASH_COINBASE = 5;
10415
+ Transaction5.DASH_QUORUM_COMMITMENT = 6;
10416
+ Transaction5.fromBuffer = function(buffer, network, __noStrict) {
10417
10417
  if (network === void 0) {
10418
10418
  network = networks3.bitcoin;
10419
10419
  }
10420
10420
  var bufferReader = new BufferReader(buffer);
10421
- var tx = new Transaction4(network);
10421
+ var tx = new Transaction5(network);
10422
10422
  tx.version = bufferReader.readInt32();
10423
10423
  if (coins.isZcashCompatible(network)) {
10424
10424
  tx.overwintered = tx.version >>> 31;
@@ -10431,14 +10431,14 @@ var require_transaction = __commonJS({
10431
10431
  if (coins.isDash(network)) {
10432
10432
  tx.type = tx.version >> 16;
10433
10433
  tx.version = tx.version & 65535;
10434
- if (tx.version === 3 && (tx.type < Transaction4.DASH_NORMAL || tx.type > Transaction4.DASH_QUORUM_COMMITMENT)) {
10434
+ if (tx.version === 3 && (tx.type < Transaction5.DASH_NORMAL || tx.type > Transaction5.DASH_QUORUM_COMMITMENT)) {
10435
10435
  throw new Error("Unsupported Dash transaction type");
10436
10436
  }
10437
10437
  }
10438
10438
  var marker = bufferReader.readUInt8();
10439
10439
  var flag = bufferReader.readUInt8();
10440
10440
  var hasWitnesses = false;
10441
- if (marker === Transaction4.ADVANCED_TRANSACTION_MARKER && flag === Transaction4.ADVANCED_TRANSACTION_FLAG && !coins.isZcashCompatible(network)) {
10441
+ if (marker === Transaction5.ADVANCED_TRANSACTION_MARKER && flag === Transaction5.ADVANCED_TRANSACTION_FLAG && !coins.isZcashCompatible(network)) {
10442
10442
  hasWitnesses = true;
10443
10443
  } else {
10444
10444
  bufferReader.offset -= 2;
@@ -10506,10 +10506,10 @@ var require_transaction = __commonJS({
10506
10506
  throw new Error("Transaction has unexpected data");
10507
10507
  return tx;
10508
10508
  };
10509
- Transaction4.fromHex = function(hex, network) {
10510
- return Transaction4.fromBuffer(Buffer2.from(hex, "hex"), network);
10509
+ Transaction5.fromHex = function(hex, network) {
10510
+ return Transaction5.fromBuffer(Buffer2.from(hex, "hex"), network);
10511
10511
  };
10512
- Transaction4.isCoinbaseHash = function(buffer) {
10512
+ Transaction5.isCoinbaseHash = function(buffer) {
10513
10513
  typeforce(types.Hash256bit, buffer);
10514
10514
  for (var i = 0; i < 32; ++i) {
10515
10515
  if (buffer[i] !== 0)
@@ -10517,28 +10517,28 @@ var require_transaction = __commonJS({
10517
10517
  }
10518
10518
  return true;
10519
10519
  };
10520
- Transaction4.prototype.isSaplingCompatible = function() {
10520
+ Transaction5.prototype.isSaplingCompatible = function() {
10521
10521
  return coins.isZcashCompatible(this.network) && this.version >= zcashVersion.SAPLING;
10522
10522
  };
10523
- Transaction4.prototype.isOverwinterCompatible = function() {
10523
+ Transaction5.prototype.isOverwinterCompatible = function() {
10524
10524
  return coins.isZcashCompatible(this.network) && this.version >= zcashVersion.OVERWINTER;
10525
10525
  };
10526
- Transaction4.prototype.supportsJoinSplits = function() {
10526
+ Transaction5.prototype.supportsJoinSplits = function() {
10527
10527
  return coins.isZcashCompatible(this.network) && this.version >= zcashVersion.JOINSPLITS_SUPPORT;
10528
10528
  };
10529
- Transaction4.prototype.versionSupportsDashSpecialTransactions = function() {
10529
+ Transaction5.prototype.versionSupportsDashSpecialTransactions = function() {
10530
10530
  return coins.isDash(this.network) && this.version >= 3;
10531
10531
  };
10532
- Transaction4.prototype.isDashSpecialTransaction = function() {
10533
- return this.versionSupportsDashSpecialTransactions() && this.type !== Transaction4.DASH_NORMAL;
10532
+ Transaction5.prototype.isDashSpecialTransaction = function() {
10533
+ return this.versionSupportsDashSpecialTransactions() && this.type !== Transaction5.DASH_NORMAL;
10534
10534
  };
10535
- Transaction4.prototype.isCoinbase = function() {
10536
- return this.ins.length === 1 && Transaction4.isCoinbaseHash(this.ins[0].hash);
10535
+ Transaction5.prototype.isCoinbase = function() {
10536
+ return this.ins.length === 1 && Transaction5.isCoinbaseHash(this.ins[0].hash);
10537
10537
  };
10538
- Transaction4.prototype.addInput = function(hash, index, sequence, scriptSig) {
10538
+ Transaction5.prototype.addInput = function(hash, index, sequence, scriptSig) {
10539
10539
  typeforce(types.tuple(types.Hash256bit, types.UInt32, types.maybe(types.UInt32), types.maybe(types.Buffer)), arguments);
10540
10540
  if (types.Null(sequence)) {
10541
- sequence = Transaction4.DEFAULT_SEQUENCE;
10541
+ sequence = Transaction5.DEFAULT_SEQUENCE;
10542
10542
  }
10543
10543
  return this.ins.push({
10544
10544
  hash,
@@ -10548,30 +10548,30 @@ var require_transaction = __commonJS({
10548
10548
  witness: EMPTY_WITNESS
10549
10549
  }) - 1;
10550
10550
  };
10551
- Transaction4.prototype.addOutput = function(scriptPubKey, value) {
10551
+ Transaction5.prototype.addOutput = function(scriptPubKey, value) {
10552
10552
  typeforce(types.tuple(types.Buffer, types.Satoshi), arguments);
10553
10553
  return this.outs.push({
10554
10554
  script: scriptPubKey,
10555
10555
  value
10556
10556
  }) - 1;
10557
10557
  };
10558
- Transaction4.prototype.hasWitnesses = function() {
10558
+ Transaction5.prototype.hasWitnesses = function() {
10559
10559
  return this.ins.some(function(x) {
10560
10560
  return x.witness.length !== 0;
10561
10561
  });
10562
10562
  };
10563
- Transaction4.prototype.weight = function() {
10563
+ Transaction5.prototype.weight = function() {
10564
10564
  var base = this.__byteLength(false);
10565
10565
  var total = this.__byteLength(true);
10566
10566
  return base * 3 + total;
10567
10567
  };
10568
- Transaction4.prototype.virtualSize = function() {
10568
+ Transaction5.prototype.virtualSize = function() {
10569
10569
  return Math.ceil(this.weight() / 4);
10570
10570
  };
10571
- Transaction4.prototype.byteLength = function() {
10571
+ Transaction5.prototype.byteLength = function() {
10572
10572
  return this.__byteLength(true);
10573
10573
  };
10574
- Transaction4.prototype.zcashTransactionByteLength = function() {
10574
+ Transaction5.prototype.zcashTransactionByteLength = function() {
10575
10575
  if (!coins.isZcashCompatible(this.network)) {
10576
10576
  throw new Error("zcashTransactionByteLength can only be called when using Zcash or compatible network");
10577
10577
  }
@@ -10602,7 +10602,7 @@ var require_transaction = __commonJS({
10602
10602
  }
10603
10603
  return byteLength;
10604
10604
  };
10605
- Transaction4.prototype.__byteLength = function(__allowWitness) {
10605
+ Transaction5.prototype.__byteLength = function(__allowWitness) {
10606
10606
  var hasWitnesses = __allowWitness && this.hasWitnesses();
10607
10607
  if (coins.isZcashCompatible(this.network)) {
10608
10608
  return this.zcashTransactionByteLength();
@@ -10615,8 +10615,8 @@ var require_transaction = __commonJS({
10615
10615
  return sum + vectorSize(input.witness);
10616
10616
  }, 0) : 0);
10617
10617
  };
10618
- Transaction4.prototype.clone = function() {
10619
- var newTx = new Transaction4(this.network);
10618
+ Transaction5.prototype.clone = function() {
10619
+ var newTx = new Transaction5(this.network);
10620
10620
  newTx.version = this.version;
10621
10621
  newTx.locktime = this.locktime;
10622
10622
  newTx.network = this.network;
@@ -10652,12 +10652,12 @@ var require_transaction = __commonJS({
10652
10652
  });
10653
10653
  return newTx;
10654
10654
  };
10655
- Transaction4.prototype.getHeader = function() {
10655
+ Transaction5.prototype.getHeader = function() {
10656
10656
  var mask = this.overwintered ? 1 : 0;
10657
10657
  var header = this.version | mask << 31;
10658
10658
  return header;
10659
10659
  };
10660
- Transaction4.prototype.hashForSignature = function(inIndex, prevOutScript, hashType) {
10660
+ Transaction5.prototype.hashForSignature = function(inIndex, prevOutScript, hashType) {
10661
10661
  typeforce(types.tuple(
10662
10662
  types.UInt32,
10663
10663
  types.Buffer,
@@ -10670,14 +10670,14 @@ var require_transaction = __commonJS({
10670
10670
  return x !== opcodes3.OP_CODESEPARATOR;
10671
10671
  }));
10672
10672
  var txTmp = this.clone();
10673
- if ((hashType & 31) === Transaction4.SIGHASH_NONE) {
10673
+ if ((hashType & 31) === Transaction5.SIGHASH_NONE) {
10674
10674
  txTmp.outs = [];
10675
10675
  txTmp.ins.forEach(function(input, i2) {
10676
10676
  if (i2 === inIndex)
10677
10677
  return;
10678
10678
  input.sequence = 0;
10679
10679
  });
10680
- } else if ((hashType & 31) === Transaction4.SIGHASH_SINGLE) {
10680
+ } else if ((hashType & 31) === Transaction5.SIGHASH_SINGLE) {
10681
10681
  if (inIndex >= this.outs.length)
10682
10682
  return ONE;
10683
10683
  txTmp.outs.length = inIndex + 1;
@@ -10690,7 +10690,7 @@ var require_transaction = __commonJS({
10690
10690
  input.sequence = 0;
10691
10691
  });
10692
10692
  }
10693
- if (hashType & Transaction4.SIGHASH_ANYONECANPAY) {
10693
+ if (hashType & Transaction5.SIGHASH_ANYONECANPAY) {
10694
10694
  txTmp.ins = [txTmp.ins[inIndex]];
10695
10695
  txTmp.ins[0].script = ourScript;
10696
10696
  } else {
@@ -10704,7 +10704,7 @@ var require_transaction = __commonJS({
10704
10704
  txTmp.__toBuffer(buffer, 0, false);
10705
10705
  return bcrypto.hash256(buffer);
10706
10706
  };
10707
- Transaction4.prototype.hashForSignatureByNetwork = function(inIndex, prevoutScript, value, hashType, isSegwit) {
10707
+ Transaction5.prototype.hashForSignatureByNetwork = function(inIndex, prevoutScript, value, hashType, isSegwit) {
10708
10708
  switch (coins.getMainnet(this.network)) {
10709
10709
  case networks3.zcash:
10710
10710
  case networks3.verus:
@@ -10714,7 +10714,7 @@ var require_transaction = __commonJS({
10714
10714
  case networks3.bitcoincash:
10715
10715
  case networks3.bitcoinsv:
10716
10716
  case networks3.bitcoingold:
10717
- var addForkId = (hashType & Transaction4.SIGHASH_FORKID) > 0;
10717
+ var addForkId = (hashType & Transaction5.SIGHASH_FORKID) > 0;
10718
10718
  if (addForkId) {
10719
10719
  hashType = (hashType | this.network.forkId << 8) >>> 0;
10720
10720
  return this.hashForWitnessV0(inIndex, prevoutScript, value, hashType);
@@ -10726,7 +10726,7 @@ var require_transaction = __commonJS({
10726
10726
  return this.hashForSignature(inIndex, prevoutScript, hashType);
10727
10727
  }
10728
10728
  };
10729
- Transaction4.prototype.hashForCashSignature = function() {
10729
+ Transaction5.prototype.hashForCashSignature = function() {
10730
10730
  var args = [];
10731
10731
  for (var _i = 0; _i < arguments.length; _i++) {
10732
10732
  args[_i] = arguments[_i];
@@ -10736,7 +10736,7 @@ var require_transaction = __commonJS({
10736
10736
  }
10737
10737
  return this.hashForSignatureByNetwork.apply(this, args);
10738
10738
  };
10739
- Transaction4.prototype.hashForGoldSignature = function() {
10739
+ Transaction5.prototype.hashForGoldSignature = function() {
10740
10740
  var args = [];
10741
10741
  for (var _i = 0; _i < arguments.length; _i++) {
10742
10742
  args[_i] = arguments[_i];
@@ -10746,12 +10746,12 @@ var require_transaction = __commonJS({
10746
10746
  }
10747
10747
  return this.hashForSignatureByNetwork.apply(this, args);
10748
10748
  };
10749
- Transaction4.prototype.getBlake2bHash = function(bufferToHash, personalization) {
10749
+ Transaction5.prototype.getBlake2bHash = function(bufferToHash, personalization) {
10750
10750
  var out = Buffer2.allocUnsafe(32);
10751
10751
  return blake2b(out.length, null, null, Buffer2.from(personalization)).update(bufferToHash).digest(out);
10752
10752
  };
10753
- Transaction4.prototype.getPrevoutHash = function(hashType) {
10754
- if (!(hashType & Transaction4.SIGHASH_ANYONECANPAY)) {
10753
+ Transaction5.prototype.getPrevoutHash = function(hashType) {
10754
+ if (!(hashType & Transaction5.SIGHASH_ANYONECANPAY)) {
10755
10755
  var bufferWriter = new BufferWriter(Buffer2.allocUnsafe(36 * this.ins.length));
10756
10756
  this.ins.forEach(function(txIn) {
10757
10757
  bufferWriter.writeSlice(txIn.hash);
@@ -10764,8 +10764,8 @@ var require_transaction = __commonJS({
10764
10764
  }
10765
10765
  return ZERO;
10766
10766
  };
10767
- Transaction4.prototype.getSequenceHash = function(hashType) {
10768
- if (!(hashType & Transaction4.SIGHASH_ANYONECANPAY) && (hashType & 31) !== Transaction4.SIGHASH_SINGLE && (hashType & 31) !== Transaction4.SIGHASH_NONE) {
10767
+ Transaction5.prototype.getSequenceHash = function(hashType) {
10768
+ if (!(hashType & Transaction5.SIGHASH_ANYONECANPAY) && (hashType & 31) !== Transaction5.SIGHASH_SINGLE && (hashType & 31) !== Transaction5.SIGHASH_NONE) {
10769
10769
  var bufferWriter = new BufferWriter(Buffer2.allocUnsafe(4 * this.ins.length));
10770
10770
  this.ins.forEach(function(txIn) {
10771
10771
  bufferWriter.writeUInt32(txIn.sequence);
@@ -10777,9 +10777,9 @@ var require_transaction = __commonJS({
10777
10777
  }
10778
10778
  return ZERO;
10779
10779
  };
10780
- Transaction4.prototype.getOutputsHash = function(hashType, inIndex) {
10780
+ Transaction5.prototype.getOutputsHash = function(hashType, inIndex) {
10781
10781
  var bufferWriter;
10782
- if ((hashType & 31) !== Transaction4.SIGHASH_SINGLE && (hashType & 31) !== Transaction4.SIGHASH_NONE) {
10782
+ if ((hashType & 31) !== Transaction5.SIGHASH_SINGLE && (hashType & 31) !== Transaction5.SIGHASH_NONE) {
10783
10783
  var txOutsSize = this.outs.reduce(function(sum, output2) {
10784
10784
  return sum + 8 + varSliceSize(output2.script);
10785
10785
  }, 0);
@@ -10792,7 +10792,7 @@ var require_transaction = __commonJS({
10792
10792
  return this.getBlake2bHash(bufferWriter.buffer, "ZcashOutputsHash");
10793
10793
  }
10794
10794
  return bcrypto.hash256(bufferWriter.buffer);
10795
- } else if ((hashType & 31) === Transaction4.SIGHASH_SINGLE && inIndex < this.outs.length) {
10795
+ } else if ((hashType & 31) === Transaction5.SIGHASH_SINGLE && inIndex < this.outs.length) {
10796
10796
  var output = this.outs[inIndex];
10797
10797
  bufferWriter = new BufferWriter(Buffer2.allocUnsafe(8 + varSliceSize(output.script)));
10798
10798
  bufferWriter.writeUInt64(output.value);
@@ -10804,7 +10804,7 @@ var require_transaction = __commonJS({
10804
10804
  }
10805
10805
  return ZERO;
10806
10806
  };
10807
- Transaction4.prototype.hashForZcashSignature = function(inIndex, prevOutScript, value, hashType) {
10807
+ Transaction5.prototype.hashForZcashSignature = function(inIndex, prevOutScript, value, hashType) {
10808
10808
  typeforce(types.tuple(types.UInt32, types.Buffer, types.Satoshi, types.UInt32), arguments);
10809
10809
  if (!coins.isZcashCompatible(this.network)) {
10810
10810
  throw new Error("hashForZcashSignature can only be called when using Zcash or compatible network");
@@ -10866,7 +10866,7 @@ var require_transaction = __commonJS({
10866
10866
  }
10867
10867
  throw new Error("unsupported version");
10868
10868
  };
10869
- Transaction4.prototype.hashForWitnessV0 = function(inIndex, prevOutScript, value, hashType) {
10869
+ Transaction5.prototype.hashForWitnessV0 = function(inIndex, prevOutScript, value, hashType) {
10870
10870
  typeforce(types.tuple(types.UInt32, types.Buffer, types.Satoshi, types.UInt32), arguments);
10871
10871
  var hashPrevouts = this.getPrevoutHash(hashType);
10872
10872
  var hashSequence = this.getSequenceHash(hashType);
@@ -10886,16 +10886,16 @@ var require_transaction = __commonJS({
10886
10886
  bufferWriter.writeUInt32(hashType);
10887
10887
  return bcrypto.hash256(bufferWriter.buffer);
10888
10888
  };
10889
- Transaction4.prototype.getHash = function() {
10889
+ Transaction5.prototype.getHash = function() {
10890
10890
  return bcrypto.hash256(this.__toBuffer(void 0, void 0, false));
10891
10891
  };
10892
- Transaction4.prototype.getId = function() {
10892
+ Transaction5.prototype.getId = function() {
10893
10893
  return this.getHash().reverse().toString("hex");
10894
10894
  };
10895
- Transaction4.prototype.toBuffer = function(buffer, initialOffset) {
10895
+ Transaction5.prototype.toBuffer = function(buffer, initialOffset) {
10896
10896
  return this.__toBuffer(buffer, initialOffset, true);
10897
10897
  };
10898
- Transaction4.prototype.__toBuffer = function(buffer, initialOffset, __allowWitness) {
10898
+ Transaction5.prototype.__toBuffer = function(buffer, initialOffset, __allowWitness) {
10899
10899
  if (!buffer)
10900
10900
  buffer = Buffer2.allocUnsafe(this.__byteLength(__allowWitness));
10901
10901
  var bufferWriter = new BufferWriter(buffer, initialOffset || 0);
@@ -10914,8 +10914,8 @@ var require_transaction = __commonJS({
10914
10914
  }
10915
10915
  var hasWitnesses = __allowWitness && this.hasWitnesses();
10916
10916
  if (hasWitnesses) {
10917
- bufferWriter.writeUInt8(Transaction4.ADVANCED_TRANSACTION_MARKER);
10918
- bufferWriter.writeUInt8(Transaction4.ADVANCED_TRANSACTION_FLAG);
10917
+ bufferWriter.writeUInt8(Transaction5.ADVANCED_TRANSACTION_MARKER);
10918
+ bufferWriter.writeUInt8(Transaction5.ADVANCED_TRANSACTION_FLAG);
10919
10919
  }
10920
10920
  bufferWriter.writeVarInt(this.ins.length);
10921
10921
  this.ins.forEach(function(txIn) {
@@ -10957,18 +10957,18 @@ var require_transaction = __commonJS({
10957
10957
  return buffer.slice(initialOffset, bufferWriter.offset);
10958
10958
  return buffer.slice(0, bufferWriter.offset);
10959
10959
  };
10960
- Transaction4.prototype.toHex = function() {
10960
+ Transaction5.prototype.toHex = function() {
10961
10961
  return this.toBuffer().toString("hex");
10962
10962
  };
10963
- Transaction4.prototype.setInputScript = function(index, scriptSig) {
10963
+ Transaction5.prototype.setInputScript = function(index, scriptSig) {
10964
10964
  typeforce(types.tuple(types.Number, types.Buffer), arguments);
10965
10965
  this.ins[index].script = scriptSig;
10966
10966
  };
10967
- Transaction4.prototype.setWitness = function(index, witness) {
10967
+ Transaction5.prototype.setWitness = function(index, witness) {
10968
10968
  typeforce(types.tuple(types.Number, [types.Buffer]), arguments);
10969
10969
  this.ins[index].witness = witness;
10970
10970
  };
10971
- module2.exports = Transaction4;
10971
+ module2.exports = Transaction5;
10972
10972
  }
10973
10973
  });
10974
10974
 
@@ -10984,7 +10984,7 @@ var require_signature = __commonJS({
10984
10984
  var script = require_script();
10985
10985
  var crypto2 = require_crypto();
10986
10986
  var ECPair4 = require_ecpair();
10987
- var Transaction4 = require_transaction();
10987
+ var Transaction5 = require_transaction();
10988
10988
  var ECSignature = require_ecsignature();
10989
10989
  var networks3 = require_networks();
10990
10990
  var coins_1 = require_coins();
@@ -10993,9 +10993,9 @@ var require_signature = __commonJS({
10993
10993
  case networks3.bitcoincash:
10994
10994
  case networks3.bitcoinsv:
10995
10995
  case networks3.bitcoingold:
10996
- return Transaction4.SIGHASH_ALL | Transaction4.SIGHASH_BITCOINCASHBIP143;
10996
+ return Transaction5.SIGHASH_ALL | Transaction5.SIGHASH_BITCOINCASHBIP143;
10997
10997
  default:
10998
- return Transaction4.SIGHASH_ALL;
10998
+ return Transaction5.SIGHASH_ALL;
10999
10999
  }
11000
11000
  }
11001
11001
  function parseSignatureScript(input) {
@@ -11837,7 +11837,7 @@ var require_transaction_builder = __commonJS({
11837
11837
  var P2SH = SIGNABLE.concat([btemplates.types.P2WPKH, btemplates.types.P2WSH]);
11838
11838
  var ECPair4 = require_ecpair();
11839
11839
  var ECSignature = require_ecsignature();
11840
- var Transaction4 = require_transaction();
11840
+ var Transaction5 = require_transaction();
11841
11841
  var SmartTransactionSignatures = require_smart_transaction_signatures();
11842
11842
  var SmartTransactionSignature = require_smart_transaction_signature();
11843
11843
  var getMainnet = require_coins().getMainnet;
@@ -12245,7 +12245,7 @@ var require_transaction_builder = __commonJS({
12245
12245
  this.network = network || networks3.bitcoin;
12246
12246
  this.maximumFeeRate = maximumFeeRate || 2500;
12247
12247
  this.inputs = [];
12248
- this.tx = new Transaction4(this.network);
12248
+ this.tx = new Transaction5(this.network);
12249
12249
  }
12250
12250
  TransactionBuilder5.prototype.setLockTime = function(locktime) {
12251
12251
  typeforce(types.UInt32, locktime);
@@ -12381,7 +12381,7 @@ var require_transaction_builder = __commonJS({
12381
12381
  var value;
12382
12382
  if (typeof txHash === "string") {
12383
12383
  txHash = Buffer2.from(txHash, "hex").reverse();
12384
- } else if (txHash instanceof Transaction4) {
12384
+ } else if (txHash instanceof Transaction5) {
12385
12385
  var txOut = txHash.outs[vout];
12386
12386
  prevOutScript = txOut.script;
12387
12387
  value = txOut.value;
@@ -12394,7 +12394,7 @@ var require_transaction_builder = __commonJS({
12394
12394
  });
12395
12395
  };
12396
12396
  TransactionBuilder5.prototype.__addInputUnsafe = function(txHash, vout, options) {
12397
- if (Transaction4.isCoinbaseHash(txHash)) {
12397
+ if (Transaction5.isCoinbaseHash(txHash)) {
12398
12398
  throw new Error("coinbase inputs not supported");
12399
12399
  }
12400
12400
  var prevTxOut = txHash.toString("hex") + ":" + vout;
@@ -12478,7 +12478,7 @@ var require_transaction_builder = __commonJS({
12478
12478
  throw new TypeError("Inconsistent network");
12479
12479
  if (!this.inputs[vin])
12480
12480
  throw new Error("No input at index: " + vin);
12481
- hashType = hashType || Transaction4.SIGHASH_ALL;
12481
+ hashType = hashType || Transaction5.SIGHASH_ALL;
12482
12482
  var input = this.inputs[vin];
12483
12483
  if (input.redeemScript !== void 0 && redeemScript && !input.redeemScript.equals(redeemScript)) {
12484
12484
  throw new Error("Inconsistent redeemScript");
@@ -12531,7 +12531,7 @@ var require_transaction_builder = __commonJS({
12531
12531
  if (!signature)
12532
12532
  return true;
12533
12533
  var hashType = signatureHashType(signature);
12534
- return hashType & Transaction4.SIGHASH_ANYONECANPAY;
12534
+ return hashType & Transaction5.SIGHASH_ANYONECANPAY;
12535
12535
  });
12536
12536
  });
12537
12537
  };
@@ -12554,9 +12554,9 @@ var require_transaction_builder = __commonJS({
12554
12554
  return true;
12555
12555
  var hashType = signatureHashType(signature);
12556
12556
  var hashTypeMod = hashType & 31;
12557
- if (hashTypeMod === Transaction4.SIGHASH_NONE)
12557
+ if (hashTypeMod === Transaction5.SIGHASH_NONE)
12558
12558
  return true;
12559
- if (hashTypeMod === Transaction4.SIGHASH_SINGLE) {
12559
+ if (hashTypeMod === Transaction5.SIGHASH_SINGLE) {
12560
12560
  return nInputs <= nOutputs;
12561
12561
  }
12562
12562
  });
@@ -12589,7 +12589,7 @@ var require_transaction2 = __commonJS({
12589
12589
  exports2.createTransactionForNetwork = createTransactionForNetwork;
12590
12590
  var networks3 = require_networks();
12591
12591
  var coins_1 = require_coins();
12592
- var Transaction4 = require_transaction();
12592
+ var Transaction5 = require_transaction();
12593
12593
  var TransactionBuilder5 = require_transaction_builder();
12594
12594
  function createTransactionFromBuffer(buf, network) {
12595
12595
  switch ((0, coins_1.getMainnet)(network)) {
@@ -12600,7 +12600,7 @@ var require_transaction2 = __commonJS({
12600
12600
  case networks3.dash:
12601
12601
  case networks3.litecoin:
12602
12602
  case networks3.zcash:
12603
- return Transaction4.fromBuffer(buf, network);
12603
+ return Transaction5.fromBuffer(buf, network);
12604
12604
  }
12605
12605
  throw new Error("invalid network");
12606
12606
  }
@@ -12655,7 +12655,7 @@ var require_transaction2 = __commonJS({
12655
12655
  case networks3.dash:
12656
12656
  case networks3.litecoin:
12657
12657
  case networks3.zcash:
12658
- return new Transaction4(network);
12658
+ return new Transaction5(network);
12659
12659
  }
12660
12660
  throw new Error("invalid network");
12661
12661
  }
@@ -12737,7 +12737,7 @@ var require_block = __commonJS({
12737
12737
  var varuint = require_varuint_bitcoin();
12738
12738
  var networks3 = require_networks();
12739
12739
  var coins = require_coins();
12740
- var Transaction4 = require_transaction();
12740
+ var Transaction5 = require_transaction();
12741
12741
  function Block(network) {
12742
12742
  typeforce(types.maybe(types.Network), network);
12743
12743
  if (coins.isZcash(network)) {
@@ -12801,7 +12801,7 @@ var require_block = __commonJS({
12801
12801
  if (bufferReader.buffer.length === headerLength)
12802
12802
  return block;
12803
12803
  function readTransaction() {
12804
- var tx2 = Transaction4.fromBuffer(buffer.slice(bufferReader.offset), network, true);
12804
+ var tx2 = Transaction5.fromBuffer(buffer.slice(bufferReader.offset), network, true);
12805
12805
  bufferReader.offset += tx2.byteLength();
12806
12806
  return tx2;
12807
12807
  }
@@ -19831,7 +19831,7 @@ var require_TransferDestination = __commonJS({
19831
19831
  exports2.FLAG_DEST_AUX = new bn_js_1.BN(64, 10);
19832
19832
  exports2.FLAG_DEST_GATEWAY = new bn_js_1.BN(128, 10);
19833
19833
  exports2.FLAG_MASK = exports2.FLAG_DEST_AUX.add(exports2.FLAG_DEST_GATEWAY);
19834
- var TransferDestination3 = class _TransferDestination {
19834
+ var TransferDestination2 = class _TransferDestination {
19835
19835
  constructor(data) {
19836
19836
  this.type = exports2.DEST_INVALID;
19837
19837
  this.destination_bytes = Buffer.alloc(0);
@@ -20033,7 +20033,7 @@ var require_TransferDestination = __commonJS({
20033
20033
  return retVal;
20034
20034
  }
20035
20035
  };
20036
- exports2.TransferDestination = TransferDestination3;
20036
+ exports2.TransferDestination = TransferDestination2;
20037
20037
  }
20038
20038
  });
20039
20039
 
@@ -23341,7 +23341,7 @@ var require_ReserveTransfer = __commonJS({
23341
23341
  type: TransferDestination_1.DEST_PKH,
23342
23342
  destination_bytes: (0, address_1.fromBase58Check)("RTqQe58LSj2yr5CrwYFwcsAQ1edQwmrkUU").hash
23343
23343
  });
23344
- var ReserveTransfer2 = class extends TokenOutput_1.TokenOutput {
23344
+ var ReserveTransfer = class extends TokenOutput_1.TokenOutput {
23345
23345
  constructor(data) {
23346
23346
  super(data);
23347
23347
  this.flags = exports2.RESERVE_TRANSFER_INVALID;
@@ -23463,7 +23463,7 @@ var require_ReserveTransfer = __commonJS({
23463
23463
  return reader.offset;
23464
23464
  }
23465
23465
  };
23466
- exports2.ReserveTransfer = ReserveTransfer2;
23466
+ exports2.ReserveTransfer = ReserveTransfer;
23467
23467
  }
23468
23468
  });
23469
23469
 
@@ -31619,7 +31619,7 @@ var require_smart_transactions = __commonJS({
31619
31619
  exports2.getFundedTxBuilder = exports2.completeFundedIdentityUpdate = exports2.createUnfundedIdentityUpdate = exports2.createUnfundedCurrencyTransfer = exports2.validateFundedCurrencyTransfer = exports2.unpackOutput = void 0;
31620
31620
  var verus_typescript_primitives_1 = require_dist2();
31621
31621
  var bn_js_1 = require("bn.js");
31622
- var Transaction4 = require_transaction();
31622
+ var Transaction5 = require_transaction();
31623
31623
  var TransactionBuilder5 = require_transaction_builder();
31624
31624
  var TxDestination2 = require_tx_destination();
31625
31625
  var script = require_script();
@@ -31822,9 +31822,9 @@ var require_smart_transactions = __commonJS({
31822
31822
  var amountsOut = (_b = {}, _b[systemId] = new bn_js_1.BN(0), _b);
31823
31823
  var amountChange = (_c = {}, _c[systemId] = new bn_js_1.BN(0), _c);
31824
31824
  var amountsFee = (_d = {}, _d[systemId] = new bn_js_1.BN(0), _d);
31825
- var fundedTx = Transaction4.fromHex(fundedTxHex, network);
31826
- var unfundedTx = Transaction4.fromHex(unfundedTxHex, network);
31827
- var fundedTxComparison = Transaction4.fromHex(fundedTxHex, network);
31825
+ var fundedTx = Transaction5.fromHex(fundedTxHex, network);
31826
+ var unfundedTx = Transaction5.fromHex(unfundedTxHex, network);
31827
+ var fundedTxComparison = Transaction5.fromHex(fundedTxHex, network);
31828
31828
  if (!fundedTxComparison.ins.length) {
31829
31829
  return {
31830
31830
  valid: false,
@@ -32153,7 +32153,7 @@ var require_smart_transactions = __commonJS({
32153
32153
  };
32154
32154
  exports2.completeFundedIdentityUpdate = completeFundedIdentityUpdate3;
32155
32155
  var getFundedTxBuilder2 = function(fundedTxHex, network, prevOutScripts) {
32156
- var tx = Transaction4.fromHex(fundedTxHex, network);
32156
+ var tx = Transaction5.fromHex(fundedTxHex, network);
32157
32157
  var inputs = tx.ins;
32158
32158
  var txb = TransactionBuilder5.fromTransaction(tx, network);
32159
32159
  txb.inputs = [];
@@ -32296,7 +32296,6 @@ var DUST_THRESHOLD = 546n;
32296
32296
  var DEFAULT_REGISTRATION_FEE = 10000000000n;
32297
32297
  var DEFAULT_REFERRAL_LEVELS = 3;
32298
32298
  var RESERVE_TRANSFER_FEE = 20000n;
32299
- var RESERVE_TRANSFER_EVAL_PKH = "RTqQe58LSj2yr5CrwYFwcsAQ1edQwmrkUU";
32300
32299
  var DEFAULT_EXPIRY_DELTA = 20;
32301
32300
  var I_ADDR_VERSION = 102;
32302
32301
  var PUBKEY_HASH_PREFIX = 60;
@@ -32309,6 +32308,7 @@ var HASH_SHA256 = 5;
32309
32308
  // src/signing/index.ts
32310
32309
  var signing_exports = {};
32311
32310
  __export(signing_exports, {
32311
+ assertNativeConservation: () => assertNativeConservation,
32312
32312
  createTransactionBuilder: () => createTransactionBuilder,
32313
32313
  getNetwork: () => getNetwork,
32314
32314
  resolveExpiryHeight: () => resolveExpiryHeight,
@@ -32473,6 +32473,12 @@ function addressToScriptPubKey(address) {
32473
32473
  }
32474
32474
  const prefix = decoded[0];
32475
32475
  const hash = decoded.slice(1);
32476
+ if (hash.length !== 20) {
32477
+ throw new InvalidAddressError(
32478
+ address,
32479
+ `Expected a 20-byte hash payload, got ${hash.length} bytes`
32480
+ );
32481
+ }
32476
32482
  if (prefix === 60) {
32477
32483
  return Buffer.concat([
32478
32484
  Buffer.from([118, 169, 20]),
@@ -32498,10 +32504,10 @@ function addressToScriptPubKey(address) {
32498
32504
  }
32499
32505
  function summarizeSignedTransaction(hex, network) {
32500
32506
  const utxolib = require_src2();
32501
- const { Transaction: Transaction4, address: addressLib, networks: networks3, smarttxs: smarttxs6 } = utxolib;
32507
+ const { Transaction: Transaction5, address: addressLib, networks: networks3, smarttxs: smarttxs6 } = utxolib;
32502
32508
  const net = network === "testnet" ? networks3.verustest : networks3.verus;
32503
32509
  const chainId = network === "testnet" ? NETWORK_CONFIG.testnet.chainId : NETWORK_CONFIG.mainnet.chainId;
32504
- const tx = Transaction4.fromHex(hex, net);
32510
+ const tx = Transaction5.fromHex(hex, net);
32505
32511
  const inputs = tx.ins.map((input) => ({
32506
32512
  txid: Buffer.from(input.hash).reverse().toString("hex"),
32507
32513
  vout: input.index
@@ -32546,6 +32552,16 @@ function resolveExpiryHeight(expiryHeight) {
32546
32552
  }
32547
32553
  return expiryHeight;
32548
32554
  }
32555
+ function assertNativeConservation(inputUtxos, txOuts, expectedFeeSats, label) {
32556
+ const totalIn = inputUtxos.reduce((sum, u) => sum + u.satoshis, 0n);
32557
+ const totalOut = txOuts.reduce((sum, o) => sum + BigInt(o.value), 0n);
32558
+ const assembled = totalIn - totalOut;
32559
+ if (assembled !== expectedFeeSats) {
32560
+ throw new TransactionBuildError(
32561
+ `${label} value conservation failed: assembled native fee ${assembled} sat != intended ${expectedFeeSats} sat`
32562
+ );
32563
+ }
32564
+ }
32549
32565
  function getNetwork(testnet = false) {
32550
32566
  return testnet ? import_utxo_lib.networks.verustest : import_utxo_lib.networks.verus;
32551
32567
  }
@@ -32790,6 +32806,8 @@ function selectUtxos(utxos, requiredNative, requiredCurrencies = /* @__PURE__ */
32790
32806
  // src/identity/index.ts
32791
32807
  var identity_exports = {};
32792
32808
  __export(identity_exports, {
32809
+ assertAddressVersion: () => assertAddressVersion,
32810
+ assertWifIsPrimary: () => assertWifIsPrimary,
32793
32811
  buildAndSignCommitment: () => buildAndSignCommitment,
32794
32812
  buildAndSignIdentityUpdate: () => buildAndSignIdentityUpdate,
32795
32813
  buildAndSignRegistration: () => buildAndSignRegistration,
@@ -32846,6 +32864,9 @@ function validateWif(wif) {
32846
32864
  if (prefix !== WIF_PREFIX) {
32847
32865
  return { valid: false, error: `Invalid WIF prefix: ${prefix}` };
32848
32866
  }
32867
+ if (decoded.length === 34 && decoded[33] !== 1) {
32868
+ return { valid: false, error: `Invalid WIF compression flag: ${decoded[33]}` };
32869
+ }
32849
32870
  return { valid: true };
32850
32871
  } catch (error) {
32851
32872
  return { valid: false, error: `Invalid WIF format: ${error.message}` };
@@ -32934,6 +32955,15 @@ function assertAddressVersion(address, expectedVersion, label) {
32934
32955
  );
32935
32956
  }
32936
32957
  }
32958
+ function assertWifIsPrimary(wif, identity, network) {
32959
+ const signerAddress = import_utxo_lib3.ECPair.fromWIF(wif, network).getAddress();
32960
+ const currentPrimaries = (identity.primary_addresses ?? []).map((k) => k.toAddress());
32961
+ if (!currentPrimaries.includes(signerAddress)) {
32962
+ throw new TransactionBuildError(
32963
+ `the provided WIF (${signerAddress}) is not among the identity's primary addresses [${currentPrimaries.join(", ")}]; it cannot authorize this operation.`
32964
+ );
32965
+ }
32966
+ }
32937
32967
  function validateMinSigs(minSigs, primaryCount) {
32938
32968
  if (!Number.isInteger(minSigs) || minSigs < 1 || minSigs > primaryCount) {
32939
32969
  throw new TransactionBuildError(
@@ -33036,6 +33066,9 @@ function isVRSCParent(parentIAddress, network = "mainnet") {
33036
33066
  function prepareNameCommitment(name, controlAddress, referralIAddress, parentIAddress, network = "mainnet") {
33037
33067
  const salt = generateSalt();
33038
33068
  const systemId = NETWORK_CONFIG[network].chainId;
33069
+ if (referralIAddress) {
33070
+ assertAddressVersion(referralIAddress, I_ADDR_VERSION, "referral");
33071
+ }
33039
33072
  const referralHash = referralIAddress ? iAddressToHash(referralIAddress) : NULL_ID_HASH;
33040
33073
  const effectiveParent = parentIAddress && parentIAddress !== systemId ? parentIAddress : void 0;
33041
33074
  const identityAddress = deriveIdentityAddress(name, effectiveParent || systemId);
@@ -33132,44 +33165,8 @@ function createIdentityObject(params) {
33132
33165
  return identity;
33133
33166
  }
33134
33167
  function buildRegistrationFeeOutput(parentCurrencyId, feeAmount, systemId, _controlAddress) {
33135
- const destination = new import_verus_typescript_primitives2.TxDestination(import_verus_typescript_primitives2.KeyID.fromAddress(RESERVE_TRANSFER_EVAL_PKH));
33136
- const values = new import_verus_typescript_primitives2.CurrencyValueMap({
33137
- value_map: /* @__PURE__ */ new Map([[parentCurrencyId, new import_bn.default(feeAmount.toString(10))]]),
33138
- multivalue: false
33139
- });
33140
- const parentHash = (0, import_verus_typescript_primitives4.fromBase58Check)(parentCurrencyId).hash;
33141
- const transferDest = new import_verus_typescript_primitives2.TransferDestination({
33142
- type: import_verus_typescript_primitives2.DEST_ID,
33143
- destination_bytes: Buffer.from(parentHash)
33144
- });
33145
- const flags = import_verus_typescript_primitives2.RESERVE_TRANSFER_VALID.or(import_verus_typescript_primitives2.RESERVE_TRANSFER_BURN_CHANGE_PRICE);
33146
- const resTransfer = new import_verus_typescript_primitives2.ReserveTransfer({
33147
- values,
33148
- version: new import_bn.default(1),
33149
- flags,
33150
- fee_currency_id: systemId,
33151
- fee_amount: new import_bn.default(RESERVE_TRANSFER_FEE.toString(10)),
33152
- transfer_destination: transferDest,
33153
- dest_currency_id: parentCurrencyId
33154
- });
33155
- const master = new import_verus_typescript_primitives2.OptCCParams({
33156
- version: new import_bn.default(3),
33157
- eval_code: new import_bn.default(import_verus_typescript_primitives3.EVALS.EVAL_NONE),
33158
- m: new import_bn.default(1),
33159
- n: new import_bn.default(1),
33160
- destinations: [destination],
33161
- vdata: []
33162
- });
33163
- const params = new import_verus_typescript_primitives2.OptCCParams({
33164
- version: new import_bn.default(3),
33165
- eval_code: new import_bn.default(import_verus_typescript_primitives3.EVALS.EVAL_RESERVE_TRANSFER),
33166
- m: new import_bn.default(1),
33167
- n: new import_bn.default(1),
33168
- destinations: [destination],
33169
- vdata: [resTransfer.toBuffer()]
33170
- });
33171
- const script = new import_verus_typescript_primitives2.SmartTransactionScript(master, params);
33172
- return { script: script.toBuffer(), nativeValue: RESERVE_TRANSFER_FEE };
33168
+ void systemId;
33169
+ return buildTokenChangeOutput(parentCurrencyId, /* @__PURE__ */ new Map([[parentCurrencyId, feeAmount]]));
33173
33170
  }
33174
33171
  function buildTokenChangeOutput(changeAddress, currencyChanges) {
33175
33172
  const version = (0, import_verus_typescript_primitives4.fromBase58Check)(changeAddress).version;
@@ -33346,6 +33343,7 @@ function _buildVrscRegistration(params, identityScript, reservationScript, ident
33346
33343
  const referralOutputs = [];
33347
33344
  if (hasReferral) {
33348
33345
  const chain = params.referralChain && params.referralChain.length > 0 ? params.referralChain : commitData.referral ? [commitData.referral] : [];
33346
+ chain.forEach((addr, i) => assertAddressVersion(addr, I_ADDR_VERSION, `referralChain[${i}]`));
33349
33347
  const referralLevels = params.referralLevels ?? DEFAULT_REFERRAL_LEVELS;
33350
33348
  if (chain.length > referralLevels) {
33351
33349
  throw new TransactionBuildError(
@@ -33502,6 +33500,12 @@ function _buildSubIdRegistration(params, identity, identityScript, reservationSc
33502
33500
  }
33503
33501
  const unsignedTx = txb.buildIncomplete();
33504
33502
  const allUtxos = [commitUtxo, ...selection.selected];
33503
+ assertNativeConservation(
33504
+ allUtxos,
33505
+ unsignedTx.outs,
33506
+ commitUtxo.satoshis + nativeImportFee + selection.fee,
33507
+ "sub-ID registration"
33508
+ );
33505
33509
  const { signedTx, txid } = signTransactionSmart(
33506
33510
  unsignedTx.toHex(),
33507
33511
  params.wif,
@@ -33694,6 +33698,12 @@ function buildAndSignIdentityUpdate(params, network, operation = "update", lockU
33694
33698
  }
33695
33699
  );
33696
33700
  const allUtxos = [...selection.selected, idUtxo];
33701
+ assertNativeConservation(
33702
+ allUtxos,
33703
+ import_utxo_lib3.Transaction.fromHex(completedHex, verusNetwork).outs,
33704
+ selection.fee,
33705
+ `identity ${operation}`
33706
+ );
33697
33707
  const { signedTx, txid } = signTransactionSmart(
33698
33708
  completedHex,
33699
33709
  params.wif,
@@ -34024,12 +34034,26 @@ __export(message_exports, {
34024
34034
  verifyMessage: () => verifyMessage
34025
34035
  });
34026
34036
  var import_utxo_lib5 = __toESM(require_src2());
34037
+ function resolveBlockHeight(blockHeight) {
34038
+ if (blockHeight === void 0) {
34039
+ throw new TransactionBuildError(
34040
+ "blockHeight is required: pass the current chain height so the signature resolves the identity's keys at the right block (this SDK is offline and cannot read the chain tip)."
34041
+ );
34042
+ }
34043
+ if (!Number.isInteger(blockHeight) || blockHeight < 0) {
34044
+ throw new TransactionBuildError(
34045
+ `Invalid blockHeight: must be a non-negative integer (got ${blockHeight})`
34046
+ );
34047
+ }
34048
+ return blockHeight;
34049
+ }
34027
34050
  function signMessage(params, network) {
34028
34051
  const verusNetwork = network === "testnet" ? import_utxo_lib5.networks.verustest : import_utxo_lib5.networks.verus;
34029
34052
  const networkConfig = NETWORK_CONFIG[network];
34030
34053
  const chainId = params.chainId || networkConfig.chainId;
34031
34054
  const version = params.version || 2;
34032
- const blockHeight = params.blockHeight || 0;
34055
+ assertAddressVersion(params.identityAddress, I_ADDR_VERSION, "identityAddress");
34056
+ const blockHeight = resolveBlockHeight(params.blockHeight);
34033
34057
  const keyPair = import_utxo_lib5.ECPair.fromWIF(params.wif, verusNetwork);
34034
34058
  const idSig = new import_utxo_lib5.IdentitySignature(
34035
34059
  verusNetwork,
@@ -34057,18 +34081,38 @@ function verifyMessage(params, network) {
34057
34081
  const verusNetwork = network === "testnet" ? import_utxo_lib5.networks.verustest : import_utxo_lib5.networks.verus;
34058
34082
  const networkConfig = NETWORK_CONFIG[network];
34059
34083
  const chainId = params.chainId || networkConfig.chainId;
34060
- const version = params.version || 2;
34061
- const blockHeight = params.blockHeight || 0;
34062
- const signatureBuffer = Buffer.from(params.signature, "base64");
34063
- const idSig = new import_utxo_lib5.IdentitySignature(
34064
- verusNetwork,
34065
- version,
34066
- HASH_SHA256,
34067
- blockHeight,
34068
- [signatureBuffer],
34069
- chainId,
34070
- params.identityAddress
34071
- );
34084
+ assertAddressVersion(params.identityAddress, I_ADDR_VERSION, "identityAddress");
34085
+ const sigBytes = Buffer.from(params.signature, "base64");
34086
+ const isDaemonFormat = sigBytes.length > 65 && (sigBytes[0] === 1 || sigBytes[0] === 2);
34087
+ let idSig;
34088
+ let blockHeight;
34089
+ let version;
34090
+ if (isDaemonFormat) {
34091
+ idSig = new import_utxo_lib5.IdentitySignature(
34092
+ verusNetwork,
34093
+ void 0,
34094
+ HASH_SHA256,
34095
+ void 0,
34096
+ void 0,
34097
+ chainId,
34098
+ params.identityAddress
34099
+ );
34100
+ idSig.fromBuffer(sigBytes, 0, chainId, params.identityAddress);
34101
+ blockHeight = idSig.blockHeight;
34102
+ version = idSig.version;
34103
+ } else {
34104
+ version = params.version || 2;
34105
+ blockHeight = resolveBlockHeight(params.blockHeight);
34106
+ idSig = new import_utxo_lib5.IdentitySignature(
34107
+ verusNetwork,
34108
+ version,
34109
+ HASH_SHA256,
34110
+ blockHeight,
34111
+ [sigBytes],
34112
+ chainId,
34113
+ params.identityAddress
34114
+ );
34115
+ }
34072
34116
  const results = idSig.verifyMessageOffline(params.message, params.signingAddress);
34073
34117
  const valid = results.length > 0 && results[0] === true;
34074
34118
  return {
@@ -34134,6 +34178,7 @@ function defineCurrency(params, network) {
34134
34178
  const currencyDefValue = params.currencyDefValue || 0n;
34135
34179
  const identity = new import_verus_typescript_primitives6.Identity();
34136
34180
  identity.fromBuffer(Buffer.from(params.identityHex, "hex"));
34181
+ assertWifIsPrimary(params.wif, identity, verusNetwork);
34137
34182
  if (!identity.hasActiveCurrency()) {
34138
34183
  const currentFlags = identity.flags.toNumber();
34139
34184
  identity.flags = new import_bn3.default(currentFlags | IDENTITY_FLAG_ACTIVECURRENCY);
@@ -34193,6 +34238,12 @@ function defineCurrency(params, network) {
34193
34238
  }
34194
34239
  );
34195
34240
  const allUtxos = [...selection.selected, idUtxo];
34241
+ assertNativeConservation(
34242
+ allUtxos,
34243
+ import_utxo_lib6.Transaction.fromHex(completedHex, verusNetwork).outs,
34244
+ selection.fee,
34245
+ "currency definition"
34246
+ );
34196
34247
  const { signedTx, txid } = signTransactionSmart(
34197
34248
  completedHex,
34198
34249
  params.wif,