@chainvue/verus-sdk 0.6.3 → 0.8.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
@@ -109,7 +109,7 @@ var require_bip66 = __commonJS({
109
109
  if (lenS > 1 && buffer[lenR + 6] === 0 && !(buffer[lenR + 7] & 128)) return false;
110
110
  return true;
111
111
  }
112
- function decode(buffer) {
112
+ function decode2(buffer) {
113
113
  if (buffer.length < 8) throw new Error("DER sequence length is too short");
114
114
  if (buffer.length > 72) throw new Error("DER sequence length is too long");
115
115
  if (buffer[0] !== 48) throw new Error("Expected DER sequence");
@@ -155,7 +155,7 @@ var require_bip66 = __commonJS({
155
155
  }
156
156
  module2.exports = {
157
157
  check,
158
- decode,
158
+ decode: decode2,
159
159
  encode
160
160
  };
161
161
  }
@@ -313,7 +313,7 @@ var require_pushdata_bitcoin = __commonJS({
313
313
  }
314
314
  return size;
315
315
  }
316
- function decode(buffer, offset) {
316
+ function decode2(buffer, offset) {
317
317
  var opcode = buffer.readUInt8(offset);
318
318
  var number, size;
319
319
  if (opcode < OPS.OP_PUSHDATA1) {
@@ -342,7 +342,7 @@ var require_pushdata_bitcoin = __commonJS({
342
342
  module2.exports = {
343
343
  encodingLength,
344
344
  encode,
345
- decode
345
+ decode: decode2
346
346
  };
347
347
  }
348
348
  });
@@ -892,7 +892,7 @@ var require_script_number = __commonJS({
892
892
  "node_modules/.pnpm/@bitgo+utxo-lib@https+++codeload.github.com+VerusCoin+BitGoJS+tar.gz+9701df63b479984f27_7b6d2dd0c6d9d9555ac626a4a148d56a/node_modules/@bitgo/utxo-lib/dist/src/script_number.js"(exports2, module2) {
893
893
  "use strict";
894
894
  var Buffer2 = require_safe_buffer().Buffer;
895
- function decode(buffer, maxLength, minimal) {
895
+ function decode2(buffer, maxLength, minimal) {
896
896
  maxLength = maxLength || 4;
897
897
  minimal = minimal === void 0 ? true : minimal;
898
898
  var length = buffer.length;
@@ -941,7 +941,7 @@ var require_script_number = __commonJS({
941
941
  return buffer;
942
942
  }
943
943
  module2.exports = {
944
- decode,
944
+ decode: decode2,
945
945
  encode
946
946
  };
947
947
  }
@@ -1138,13 +1138,13 @@ var require_script = __commonJS({
1138
1138
  var require_output = __commonJS({
1139
1139
  "node_modules/.pnpm/@bitgo+utxo-lib@https+++codeload.github.com+VerusCoin+BitGoJS+tar.gz+9701df63b479984f27_7b6d2dd0c6d9d9555ac626a4a148d56a/node_modules/@bitgo/utxo-lib/dist/src/templates/multisig/output.js"(exports2, module2) {
1140
1140
  "use strict";
1141
- var bscript3 = require_script();
1141
+ var bscript2 = require_script();
1142
1142
  var types = require_types();
1143
1143
  var typeforce = require_typeforce();
1144
1144
  var OPS = require_bitcoin_ops();
1145
1145
  var OP_INT_BASE = OPS.OP_RESERVED;
1146
1146
  function check(script, allowIncomplete) {
1147
- var chunks = bscript3.decompile(script);
1147
+ var chunks = bscript2.decompile(script);
1148
1148
  if (chunks.length < 4)
1149
1149
  return false;
1150
1150
  if (chunks[chunks.length - 1] !== OPS.OP_CHECKMULTISIG)
@@ -1166,7 +1166,7 @@ var require_output = __commonJS({
1166
1166
  if (allowIncomplete)
1167
1167
  return true;
1168
1168
  var keys = chunks.slice(1, -2);
1169
- return keys.every(bscript3.isCanonicalPubKey);
1169
+ return keys.every(bscript2.isCanonicalPubKey);
1170
1170
  }
1171
1171
  check.toJSON = function() {
1172
1172
  return "multi-sig output";
@@ -1174,7 +1174,7 @@ var require_output = __commonJS({
1174
1174
  function encode(m, pubKeys) {
1175
1175
  typeforce({
1176
1176
  m: types.Number,
1177
- pubKeys: [bscript3.isCanonicalPubKey]
1177
+ pubKeys: [bscript2.isCanonicalPubKey]
1178
1178
  }, {
1179
1179
  m,
1180
1180
  pubKeys
@@ -1182,10 +1182,10 @@ var require_output = __commonJS({
1182
1182
  var n = pubKeys.length;
1183
1183
  if (n < m)
1184
1184
  throw new TypeError("Not enough pubKeys provided");
1185
- return bscript3.compile([].concat(OP_INT_BASE + m, pubKeys, OP_INT_BASE + n, OPS.OP_CHECKMULTISIG));
1185
+ return bscript2.compile([].concat(OP_INT_BASE + m, pubKeys, OP_INT_BASE + n, OPS.OP_CHECKMULTISIG));
1186
1186
  }
1187
- function decode(buffer, allowIncomplete) {
1188
- var chunks = bscript3.decompile(buffer);
1187
+ function decode2(buffer, allowIncomplete) {
1188
+ var chunks = bscript2.decompile(buffer);
1189
1189
  typeforce(check, chunks, allowIncomplete);
1190
1190
  return {
1191
1191
  m: chunks[0] - OP_INT_BASE,
@@ -1194,7 +1194,7 @@ var require_output = __commonJS({
1194
1194
  }
1195
1195
  module2.exports = {
1196
1196
  check,
1197
- decode,
1197
+ decode: decode2,
1198
1198
  encode
1199
1199
  };
1200
1200
  }
@@ -1205,15 +1205,15 @@ var require_input = __commonJS({
1205
1205
  "node_modules/.pnpm/@bitgo+utxo-lib@https+++codeload.github.com+VerusCoin+BitGoJS+tar.gz+9701df63b479984f27_7b6d2dd0c6d9d9555ac626a4a148d56a/node_modules/@bitgo/utxo-lib/dist/src/templates/multisig/input.js"(exports2, module2) {
1206
1206
  "use strict";
1207
1207
  var Buffer2 = require_safe_buffer().Buffer;
1208
- var bscript3 = require_script();
1208
+ var bscript2 = require_script();
1209
1209
  var p2mso = require_output();
1210
1210
  var typeforce = require_typeforce();
1211
1211
  var OPS = require_bitcoin_ops();
1212
1212
  function partialSignature(value) {
1213
- return value === OPS.OP_0 || bscript3.isCanonicalSignature(value);
1213
+ return value === OPS.OP_0 || bscript2.isCanonicalSignature(value);
1214
1214
  }
1215
1215
  function check(script, allowIncomplete) {
1216
- var chunks = bscript3.decompile(script);
1216
+ var chunks = bscript2.decompile(script);
1217
1217
  if (chunks.length < 2)
1218
1218
  return false;
1219
1219
  if (chunks[0] !== OPS.OP_0)
@@ -1221,7 +1221,7 @@ var require_input = __commonJS({
1221
1221
  if (allowIncomplete) {
1222
1222
  return chunks.slice(1).every(partialSignature);
1223
1223
  }
1224
- return chunks.slice(1).every(bscript3.isCanonicalSignature);
1224
+ return chunks.slice(1).every(bscript2.isCanonicalSignature);
1225
1225
  }
1226
1226
  check.toJSON = function() {
1227
1227
  return "multisig input";
@@ -1246,19 +1246,19 @@ var require_input = __commonJS({
1246
1246
  }));
1247
1247
  }
1248
1248
  function encode(signatures, scriptPubKey) {
1249
- return bscript3.compile(encodeStack(signatures, scriptPubKey));
1249
+ return bscript2.compile(encodeStack(signatures, scriptPubKey));
1250
1250
  }
1251
1251
  function decodeStack(stack, allowIncomplete) {
1252
1252
  typeforce(check, stack, allowIncomplete);
1253
1253
  return stack.slice(1);
1254
1254
  }
1255
- function decode(buffer, allowIncomplete) {
1256
- var stack = bscript3.decompile(buffer);
1255
+ function decode2(buffer, allowIncomplete) {
1256
+ var stack = bscript2.decompile(buffer);
1257
1257
  return decodeStack(stack, allowIncomplete);
1258
1258
  }
1259
1259
  module2.exports = {
1260
1260
  check,
1261
- decode,
1261
+ decode: decode2,
1262
1262
  decodeStack,
1263
1263
  encode,
1264
1264
  encodeStack
@@ -1281,12 +1281,12 @@ var require_multisig = __commonJS({
1281
1281
  var require_nulldata = __commonJS({
1282
1282
  "node_modules/.pnpm/@bitgo+utxo-lib@https+++codeload.github.com+VerusCoin+BitGoJS+tar.gz+9701df63b479984f27_7b6d2dd0c6d9d9555ac626a4a148d56a/node_modules/@bitgo/utxo-lib/dist/src/templates/nulldata.js"(exports2, module2) {
1283
1283
  "use strict";
1284
- var bscript3 = require_script();
1284
+ var bscript2 = require_script();
1285
1285
  var types = require_types();
1286
1286
  var typeforce = require_typeforce();
1287
1287
  var OPS = require_bitcoin_ops();
1288
1288
  function check(script) {
1289
- var buffer = bscript3.compile(script);
1289
+ var buffer = bscript2.compile(script);
1290
1290
  return buffer.length > 1 && buffer[0] === OPS.OP_RETURN;
1291
1291
  }
1292
1292
  check.toJSON = function() {
@@ -1294,18 +1294,18 @@ var require_nulldata = __commonJS({
1294
1294
  };
1295
1295
  function encode(data) {
1296
1296
  typeforce(typeforce.oneOf(types.Buffer, types.Array), data);
1297
- return bscript3.compile([OPS.OP_RETURN].concat(data));
1297
+ return bscript2.compile([OPS.OP_RETURN].concat(data));
1298
1298
  }
1299
- function decode(buffer) {
1299
+ function decode2(buffer) {
1300
1300
  typeforce(check, buffer);
1301
- var chunks = bscript3.decompile(buffer);
1301
+ var chunks = bscript2.decompile(buffer);
1302
1302
  chunks.shift();
1303
1303
  return chunks.length === 1 ? chunks[0] : chunks;
1304
1304
  }
1305
1305
  module2.exports = {
1306
1306
  output: {
1307
1307
  check,
1308
- decode,
1308
+ decode: decode2,
1309
1309
  encode
1310
1310
  }
1311
1311
  };
@@ -1316,33 +1316,33 @@ var require_nulldata = __commonJS({
1316
1316
  var require_input2 = __commonJS({
1317
1317
  "node_modules/.pnpm/@bitgo+utxo-lib@https+++codeload.github.com+VerusCoin+BitGoJS+tar.gz+9701df63b479984f27_7b6d2dd0c6d9d9555ac626a4a148d56a/node_modules/@bitgo/utxo-lib/dist/src/templates/pubkey/input.js"(exports2, module2) {
1318
1318
  "use strict";
1319
- var bscript3 = require_script();
1319
+ var bscript2 = require_script();
1320
1320
  var typeforce = require_typeforce();
1321
1321
  function check(script) {
1322
- var chunks = bscript3.decompile(script);
1323
- return chunks.length === 1 && bscript3.isCanonicalSignature(chunks[0]);
1322
+ var chunks = bscript2.decompile(script);
1323
+ return chunks.length === 1 && bscript2.isCanonicalSignature(chunks[0]);
1324
1324
  }
1325
1325
  check.toJSON = function() {
1326
1326
  return "pubKey input";
1327
1327
  };
1328
1328
  function encodeStack(signature) {
1329
- typeforce(bscript3.isCanonicalSignature, signature);
1329
+ typeforce(bscript2.isCanonicalSignature, signature);
1330
1330
  return [signature];
1331
1331
  }
1332
1332
  function encode(signature) {
1333
- return bscript3.compile(encodeStack(signature));
1333
+ return bscript2.compile(encodeStack(signature));
1334
1334
  }
1335
1335
  function decodeStack(stack) {
1336
1336
  typeforce(check, stack);
1337
1337
  return stack[0];
1338
1338
  }
1339
- function decode(buffer) {
1340
- var stack = bscript3.decompile(buffer);
1339
+ function decode2(buffer) {
1340
+ var stack = bscript2.decompile(buffer);
1341
1341
  return decodeStack(stack);
1342
1342
  }
1343
1343
  module2.exports = {
1344
1344
  check,
1345
- decode,
1345
+ decode: decode2,
1346
1346
  decodeStack,
1347
1347
  encode,
1348
1348
  encodeStack
@@ -1354,28 +1354,28 @@ var require_input2 = __commonJS({
1354
1354
  var require_output2 = __commonJS({
1355
1355
  "node_modules/.pnpm/@bitgo+utxo-lib@https+++codeload.github.com+VerusCoin+BitGoJS+tar.gz+9701df63b479984f27_7b6d2dd0c6d9d9555ac626a4a148d56a/node_modules/@bitgo/utxo-lib/dist/src/templates/pubkey/output.js"(exports2, module2) {
1356
1356
  "use strict";
1357
- var bscript3 = require_script();
1357
+ var bscript2 = require_script();
1358
1358
  var typeforce = require_typeforce();
1359
1359
  var OPS = require_bitcoin_ops();
1360
1360
  function check(script) {
1361
- var chunks = bscript3.decompile(script);
1362
- return chunks.length === 2 && bscript3.isCanonicalPubKey(chunks[0]) && chunks[1] === OPS.OP_CHECKSIG;
1361
+ var chunks = bscript2.decompile(script);
1362
+ return chunks.length === 2 && bscript2.isCanonicalPubKey(chunks[0]) && chunks[1] === OPS.OP_CHECKSIG;
1363
1363
  }
1364
1364
  check.toJSON = function() {
1365
1365
  return "pubKey output";
1366
1366
  };
1367
1367
  function encode(pubKey) {
1368
- typeforce(bscript3.isCanonicalPubKey, pubKey);
1369
- return bscript3.compile([pubKey, OPS.OP_CHECKSIG]);
1368
+ typeforce(bscript2.isCanonicalPubKey, pubKey);
1369
+ return bscript2.compile([pubKey, OPS.OP_CHECKSIG]);
1370
1370
  }
1371
- function decode(buffer) {
1372
- var chunks = bscript3.decompile(buffer);
1371
+ function decode2(buffer) {
1372
+ var chunks = bscript2.decompile(buffer);
1373
1373
  typeforce(check, chunks);
1374
1374
  return chunks[0];
1375
1375
  }
1376
1376
  module2.exports = {
1377
1377
  check,
1378
- decode,
1378
+ decode: decode2,
1379
1379
  encode
1380
1380
  };
1381
1381
  }
@@ -1396,19 +1396,19 @@ var require_pubkey = __commonJS({
1396
1396
  var require_input3 = __commonJS({
1397
1397
  "node_modules/.pnpm/@bitgo+utxo-lib@https+++codeload.github.com+VerusCoin+BitGoJS+tar.gz+9701df63b479984f27_7b6d2dd0c6d9d9555ac626a4a148d56a/node_modules/@bitgo/utxo-lib/dist/src/templates/pubkeyhash/input.js"(exports2, module2) {
1398
1398
  "use strict";
1399
- var bscript3 = require_script();
1399
+ var bscript2 = require_script();
1400
1400
  var typeforce = require_typeforce();
1401
1401
  function check(script) {
1402
- var chunks = bscript3.decompile(script);
1403
- return chunks.length === 2 && bscript3.isCanonicalSignature(chunks[0]) && bscript3.isCanonicalPubKey(chunks[1]);
1402
+ var chunks = bscript2.decompile(script);
1403
+ return chunks.length === 2 && bscript2.isCanonicalSignature(chunks[0]) && bscript2.isCanonicalPubKey(chunks[1]);
1404
1404
  }
1405
1405
  check.toJSON = function() {
1406
1406
  return "pubKeyHash input";
1407
1407
  };
1408
1408
  function encodeStack(signature, pubKey) {
1409
1409
  typeforce({
1410
- signature: bscript3.isCanonicalSignature,
1411
- pubKey: bscript3.isCanonicalPubKey
1410
+ signature: bscript2.isCanonicalSignature,
1411
+ pubKey: bscript2.isCanonicalPubKey
1412
1412
  }, {
1413
1413
  signature,
1414
1414
  pubKey
@@ -1416,7 +1416,7 @@ var require_input3 = __commonJS({
1416
1416
  return [signature, pubKey];
1417
1417
  }
1418
1418
  function encode(signature, pubKey) {
1419
- return bscript3.compile(encodeStack(signature, pubKey));
1419
+ return bscript2.compile(encodeStack(signature, pubKey));
1420
1420
  }
1421
1421
  function decodeStack(stack) {
1422
1422
  typeforce(check, stack);
@@ -1425,13 +1425,13 @@ var require_input3 = __commonJS({
1425
1425
  pubKey: stack[1]
1426
1426
  };
1427
1427
  }
1428
- function decode(buffer) {
1429
- var stack = bscript3.decompile(buffer);
1428
+ function decode2(buffer) {
1429
+ var stack = bscript2.decompile(buffer);
1430
1430
  return decodeStack(stack);
1431
1431
  }
1432
1432
  module2.exports = {
1433
1433
  check,
1434
- decode,
1434
+ decode: decode2,
1435
1435
  decodeStack,
1436
1436
  encode,
1437
1437
  encodeStack
@@ -1443,12 +1443,12 @@ var require_input3 = __commonJS({
1443
1443
  var require_output3 = __commonJS({
1444
1444
  "node_modules/.pnpm/@bitgo+utxo-lib@https+++codeload.github.com+VerusCoin+BitGoJS+tar.gz+9701df63b479984f27_7b6d2dd0c6d9d9555ac626a4a148d56a/node_modules/@bitgo/utxo-lib/dist/src/templates/pubkeyhash/output.js"(exports2, module2) {
1445
1445
  "use strict";
1446
- var bscript3 = require_script();
1446
+ var bscript2 = require_script();
1447
1447
  var types = require_types();
1448
1448
  var typeforce = require_typeforce();
1449
1449
  var OPS = require_bitcoin_ops();
1450
1450
  function check(script) {
1451
- var buffer = bscript3.compile(script);
1451
+ var buffer = bscript2.compile(script);
1452
1452
  return buffer.length === 25 && buffer[0] === OPS.OP_DUP && buffer[1] === OPS.OP_HASH160 && buffer[2] === 20 && buffer[23] === OPS.OP_EQUALVERIFY && buffer[24] === OPS.OP_CHECKSIG;
1453
1453
  }
1454
1454
  check.toJSON = function() {
@@ -1456,7 +1456,7 @@ var require_output3 = __commonJS({
1456
1456
  };
1457
1457
  function encode(pubKeyHash) {
1458
1458
  typeforce(types.Hash160bit, pubKeyHash);
1459
- return bscript3.compile([
1459
+ return bscript2.compile([
1460
1460
  OPS.OP_DUP,
1461
1461
  OPS.OP_HASH160,
1462
1462
  pubKeyHash,
@@ -1464,13 +1464,13 @@ var require_output3 = __commonJS({
1464
1464
  OPS.OP_CHECKSIG
1465
1465
  ]);
1466
1466
  }
1467
- function decode(buffer) {
1467
+ function decode2(buffer) {
1468
1468
  typeforce(check, buffer);
1469
1469
  return buffer.slice(3, 23);
1470
1470
  }
1471
1471
  module2.exports = {
1472
1472
  check,
1473
- decode,
1473
+ decode: decode2,
1474
1474
  encode
1475
1475
  };
1476
1476
  }
@@ -1491,12 +1491,12 @@ var require_pubkeyhash = __commonJS({
1491
1491
  var require_output4 = __commonJS({
1492
1492
  "node_modules/.pnpm/@bitgo+utxo-lib@https+++codeload.github.com+VerusCoin+BitGoJS+tar.gz+9701df63b479984f27_7b6d2dd0c6d9d9555ac626a4a148d56a/node_modules/@bitgo/utxo-lib/dist/src/templates/witnesspubkeyhash/output.js"(exports2, module2) {
1493
1493
  "use strict";
1494
- var bscript3 = require_script();
1494
+ var bscript2 = require_script();
1495
1495
  var types = require_types();
1496
1496
  var typeforce = require_typeforce();
1497
1497
  var OPS = require_bitcoin_ops();
1498
1498
  function check(script) {
1499
- var buffer = bscript3.compile(script);
1499
+ var buffer = bscript2.compile(script);
1500
1500
  return buffer.length === 22 && buffer[0] === OPS.OP_0 && buffer[1] === 20;
1501
1501
  }
1502
1502
  check.toJSON = function() {
@@ -1504,15 +1504,15 @@ var require_output4 = __commonJS({
1504
1504
  };
1505
1505
  function encode(pubKeyHash) {
1506
1506
  typeforce(types.Hash160bit, pubKeyHash);
1507
- return bscript3.compile([OPS.OP_0, pubKeyHash]);
1507
+ return bscript2.compile([OPS.OP_0, pubKeyHash]);
1508
1508
  }
1509
- function decode(buffer) {
1509
+ function decode2(buffer) {
1510
1510
  typeforce(check, buffer);
1511
1511
  return buffer.slice(2);
1512
1512
  }
1513
1513
  module2.exports = {
1514
1514
  check,
1515
- decode,
1515
+ decode: decode2,
1516
1516
  encode
1517
1517
  };
1518
1518
  }
@@ -1522,12 +1522,12 @@ var require_output4 = __commonJS({
1522
1522
  var require_output5 = __commonJS({
1523
1523
  "node_modules/.pnpm/@bitgo+utxo-lib@https+++codeload.github.com+VerusCoin+BitGoJS+tar.gz+9701df63b479984f27_7b6d2dd0c6d9d9555ac626a4a148d56a/node_modules/@bitgo/utxo-lib/dist/src/templates/witnessscripthash/output.js"(exports2, module2) {
1524
1524
  "use strict";
1525
- var bscript3 = require_script();
1525
+ var bscript2 = require_script();
1526
1526
  var types = require_types();
1527
1527
  var typeforce = require_typeforce();
1528
1528
  var OPS = require_bitcoin_ops();
1529
1529
  function check(script) {
1530
- var buffer = bscript3.compile(script);
1530
+ var buffer = bscript2.compile(script);
1531
1531
  return buffer.length === 34 && buffer[0] === OPS.OP_0 && buffer[1] === 32;
1532
1532
  }
1533
1533
  check.toJSON = function() {
@@ -1535,15 +1535,15 @@ var require_output5 = __commonJS({
1535
1535
  };
1536
1536
  function encode(scriptHash) {
1537
1537
  typeforce(types.Hash256bit, scriptHash);
1538
- return bscript3.compile([OPS.OP_0, scriptHash]);
1538
+ return bscript2.compile([OPS.OP_0, scriptHash]);
1539
1539
  }
1540
- function decode(buffer) {
1540
+ function decode2(buffer) {
1541
1541
  typeforce(check, buffer);
1542
1542
  return buffer.slice(2);
1543
1543
  }
1544
1544
  module2.exports = {
1545
1545
  check,
1546
- decode,
1546
+ decode: decode2,
1547
1547
  encode
1548
1548
  };
1549
1549
  }
@@ -1554,7 +1554,7 @@ var require_input4 = __commonJS({
1554
1554
  "node_modules/.pnpm/@bitgo+utxo-lib@https+++codeload.github.com+VerusCoin+BitGoJS+tar.gz+9701df63b479984f27_7b6d2dd0c6d9d9555ac626a4a148d56a/node_modules/@bitgo/utxo-lib/dist/src/templates/scripthash/input.js"(exports2, module2) {
1555
1555
  "use strict";
1556
1556
  var Buffer2 = require_safe_buffer().Buffer;
1557
- var bscript3 = require_script();
1557
+ var bscript2 = require_script();
1558
1558
  var typeforce = require_typeforce();
1559
1559
  var p2ms = require_multisig();
1560
1560
  var p2pk = require_pubkey();
@@ -1562,17 +1562,17 @@ var require_input4 = __commonJS({
1562
1562
  var p2wpkho = require_output4();
1563
1563
  var p2wsho = require_output5();
1564
1564
  function check(script, allowIncomplete) {
1565
- var chunks = bscript3.decompile(script);
1565
+ var chunks = bscript2.decompile(script);
1566
1566
  if (chunks.length < 1)
1567
1567
  return false;
1568
1568
  var lastChunk = chunks[chunks.length - 1];
1569
1569
  if (!Buffer2.isBuffer(lastChunk))
1570
1570
  return false;
1571
- var scriptSigChunks = bscript3.decompile(bscript3.compile(chunks.slice(0, -1)));
1572
- var redeemScriptChunks = bscript3.decompile(lastChunk);
1571
+ var scriptSigChunks = bscript2.decompile(bscript2.compile(chunks.slice(0, -1)));
1572
+ var redeemScriptChunks = bscript2.decompile(lastChunk);
1573
1573
  if (redeemScriptChunks.length === 0)
1574
1574
  return false;
1575
- if (!bscript3.isPushOnly(scriptSigChunks))
1575
+ if (!bscript2.isPushOnly(scriptSigChunks))
1576
1576
  return false;
1577
1577
  if (chunks.length === 1) {
1578
1578
  return p2wsho.check(redeemScriptChunks) || p2wpkho.check(redeemScriptChunks);
@@ -1589,12 +1589,12 @@ var require_input4 = __commonJS({
1589
1589
  return "scriptHash input";
1590
1590
  };
1591
1591
  function encodeStack(redeemScriptStack, redeemScript) {
1592
- var serializedScriptPubKey = bscript3.compile(redeemScript);
1592
+ var serializedScriptPubKey = bscript2.compile(redeemScript);
1593
1593
  return [].concat(redeemScriptStack, serializedScriptPubKey);
1594
1594
  }
1595
1595
  function encode(redeemScriptSig, redeemScript) {
1596
- var redeemScriptStack = bscript3.decompile(redeemScriptSig);
1597
- return bscript3.compile(encodeStack(redeemScriptStack, redeemScript));
1596
+ var redeemScriptStack = bscript2.decompile(redeemScriptSig);
1597
+ return bscript2.compile(encodeStack(redeemScriptStack, redeemScript));
1598
1598
  }
1599
1599
  function decodeStack(stack) {
1600
1600
  typeforce(check, stack);
@@ -1603,16 +1603,16 @@ var require_input4 = __commonJS({
1603
1603
  redeemScript: stack[stack.length - 1]
1604
1604
  };
1605
1605
  }
1606
- function decode(buffer) {
1607
- var stack = bscript3.decompile(buffer);
1606
+ function decode2(buffer) {
1607
+ var stack = bscript2.decompile(buffer);
1608
1608
  var result = decodeStack(stack);
1609
- result.redeemScriptSig = bscript3.compile(result.redeemScriptStack);
1609
+ result.redeemScriptSig = bscript2.compile(result.redeemScriptStack);
1610
1610
  delete result.redeemScriptStack;
1611
1611
  return result;
1612
1612
  }
1613
1613
  module2.exports = {
1614
1614
  check,
1615
- decode,
1615
+ decode: decode2,
1616
1616
  decodeStack,
1617
1617
  encode,
1618
1618
  encodeStack
@@ -1624,12 +1624,12 @@ var require_input4 = __commonJS({
1624
1624
  var require_output6 = __commonJS({
1625
1625
  "node_modules/.pnpm/@bitgo+utxo-lib@https+++codeload.github.com+VerusCoin+BitGoJS+tar.gz+9701df63b479984f27_7b6d2dd0c6d9d9555ac626a4a148d56a/node_modules/@bitgo/utxo-lib/dist/src/templates/scripthash/output.js"(exports2, module2) {
1626
1626
  "use strict";
1627
- var bscript3 = require_script();
1627
+ var bscript2 = require_script();
1628
1628
  var types = require_types();
1629
1629
  var typeforce = require_typeforce();
1630
1630
  var OPS = require_bitcoin_ops();
1631
1631
  function check(script) {
1632
- var buffer = bscript3.compile(script);
1632
+ var buffer = bscript2.compile(script);
1633
1633
  return buffer.length === 23 && buffer[0] === OPS.OP_HASH160 && buffer[1] === 20 && buffer[22] === OPS.OP_EQUAL;
1634
1634
  }
1635
1635
  check.toJSON = function() {
@@ -1637,15 +1637,15 @@ var require_output6 = __commonJS({
1637
1637
  };
1638
1638
  function encode(scriptHash) {
1639
1639
  typeforce(types.Hash160bit, scriptHash);
1640
- return bscript3.compile([OPS.OP_HASH160, scriptHash, OPS.OP_EQUAL]);
1640
+ return bscript2.compile([OPS.OP_HASH160, scriptHash, OPS.OP_EQUAL]);
1641
1641
  }
1642
- function decode(buffer) {
1642
+ function decode2(buffer) {
1643
1643
  typeforce(check, buffer);
1644
1644
  return buffer.slice(2, 22);
1645
1645
  }
1646
1646
  module2.exports = {
1647
1647
  check,
1648
- decode,
1648
+ decode: decode2,
1649
1649
  encode
1650
1650
  };
1651
1651
  }
@@ -1666,21 +1666,21 @@ var require_scripthash = __commonJS({
1666
1666
  var require_input5 = __commonJS({
1667
1667
  "node_modules/.pnpm/@bitgo+utxo-lib@https+++codeload.github.com+VerusCoin+BitGoJS+tar.gz+9701df63b479984f27_7b6d2dd0c6d9d9555ac626a4a148d56a/node_modules/@bitgo/utxo-lib/dist/src/templates/witnesspubkeyhash/input.js"(exports2, module2) {
1668
1668
  "use strict";
1669
- var bscript3 = require_script();
1669
+ var bscript2 = require_script();
1670
1670
  var typeforce = require_typeforce();
1671
1671
  function isCompressedCanonicalPubKey(pubKey) {
1672
- return bscript3.isCanonicalPubKey(pubKey) && pubKey.length === 33;
1672
+ return bscript2.isCanonicalPubKey(pubKey) && pubKey.length === 33;
1673
1673
  }
1674
1674
  function check(script) {
1675
- var chunks = bscript3.decompile(script);
1676
- return chunks.length === 2 && bscript3.isCanonicalSignature(chunks[0]) && isCompressedCanonicalPubKey(chunks[1]);
1675
+ var chunks = bscript2.decompile(script);
1676
+ return chunks.length === 2 && bscript2.isCanonicalSignature(chunks[0]) && isCompressedCanonicalPubKey(chunks[1]);
1677
1677
  }
1678
1678
  check.toJSON = function() {
1679
1679
  return "witnessPubKeyHash input";
1680
1680
  };
1681
1681
  function encodeStack(signature, pubKey) {
1682
1682
  typeforce({
1683
- signature: bscript3.isCanonicalSignature,
1683
+ signature: bscript2.isCanonicalSignature,
1684
1684
  pubKey: isCompressedCanonicalPubKey
1685
1685
  }, {
1686
1686
  signature,
@@ -1718,7 +1718,7 @@ var require_witnesspubkeyhash = __commonJS({
1718
1718
  var require_input6 = __commonJS({
1719
1719
  "node_modules/.pnpm/@bitgo+utxo-lib@https+++codeload.github.com+VerusCoin+BitGoJS+tar.gz+9701df63b479984f27_7b6d2dd0c6d9d9555ac626a4a148d56a/node_modules/@bitgo/utxo-lib/dist/src/templates/witnessscripthash/input.js"(exports2, module2) {
1720
1720
  "use strict";
1721
- var bscript3 = require_script();
1721
+ var bscript2 = require_script();
1722
1722
  var types = require_types();
1723
1723
  var typeforce = require_typeforce();
1724
1724
  var p2ms = require_multisig();
@@ -1731,10 +1731,10 @@ var require_input6 = __commonJS({
1731
1731
  var witnessScript = chunks[chunks.length - 1];
1732
1732
  if (!Buffer.isBuffer(witnessScript))
1733
1733
  return false;
1734
- var witnessScriptChunks = bscript3.decompile(witnessScript);
1734
+ var witnessScriptChunks = bscript2.decompile(witnessScript);
1735
1735
  if (witnessScriptChunks.length === 0)
1736
1736
  return false;
1737
- var witnessRawScriptSig = bscript3.compile(chunks.slice(0, -1));
1737
+ var witnessRawScriptSig = bscript2.compile(chunks.slice(0, -1));
1738
1738
  if (p2pkh.input.check(witnessRawScriptSig) && p2pkh.output.check(witnessScriptChunks))
1739
1739
  return true;
1740
1740
  if (p2ms.input.check(witnessRawScriptSig, allowIncomplete) && p2ms.output.check(witnessScriptChunks))
@@ -1787,13 +1787,13 @@ var require_output7 = __commonJS({
1787
1787
  "node_modules/.pnpm/@bitgo+utxo-lib@https+++codeload.github.com+VerusCoin+BitGoJS+tar.gz+9701df63b479984f27_7b6d2dd0c6d9d9555ac626a4a148d56a/node_modules/@bitgo/utxo-lib/dist/src/templates/witnesscommitment/output.js"(exports2, module2) {
1788
1788
  "use strict";
1789
1789
  var Buffer2 = require_safe_buffer().Buffer;
1790
- var bscript3 = require_script();
1790
+ var bscript2 = require_script();
1791
1791
  var types = require_types();
1792
1792
  var typeforce = require_typeforce();
1793
1793
  var OPS = require_bitcoin_ops();
1794
1794
  var HEADER = Buffer2.from("aa21a9ed", "hex");
1795
1795
  function check(script) {
1796
- var buffer = bscript3.compile(script);
1796
+ var buffer = bscript2.compile(script);
1797
1797
  return buffer.length > 37 && buffer[0] === OPS.OP_RETURN && buffer[1] === 36 && buffer.slice(2, 6).equals(HEADER);
1798
1798
  }
1799
1799
  check.toJSON = function() {
@@ -1804,15 +1804,15 @@ var require_output7 = __commonJS({
1804
1804
  var buffer = Buffer2.allocUnsafe(36);
1805
1805
  HEADER.copy(buffer, 0);
1806
1806
  commitment.copy(buffer, 4);
1807
- return bscript3.compile([OPS.OP_RETURN, buffer]);
1807
+ return bscript2.compile([OPS.OP_RETURN, buffer]);
1808
1808
  }
1809
- function decode(buffer) {
1809
+ function decode2(buffer) {
1810
1810
  typeforce(check, buffer);
1811
- return bscript3.decompile(buffer)[1].slice(4, 36);
1811
+ return bscript2.decompile(buffer)[1].slice(4, 36);
1812
1812
  }
1813
1813
  module2.exports = {
1814
1814
  check,
1815
- decode,
1815
+ decode: decode2,
1816
1816
  encode
1817
1817
  };
1818
1818
  }
@@ -1860,21 +1860,21 @@ var require_varuint_bitcoin = __commonJS({
1860
1860
  }
1861
1861
  return buffer;
1862
1862
  }
1863
- function decode(buffer, offset) {
1863
+ function decode2(buffer, offset) {
1864
1864
  if (!Buffer.isBuffer(buffer)) throw new TypeError("buffer must be a Buffer instance");
1865
1865
  if (!offset) offset = 0;
1866
1866
  var first = buffer.readUInt8(offset);
1867
1867
  if (first < 253) {
1868
- decode.bytes = 1;
1868
+ decode2.bytes = 1;
1869
1869
  return first;
1870
1870
  } else if (first === 253) {
1871
- decode.bytes = 3;
1871
+ decode2.bytes = 3;
1872
1872
  return buffer.readUInt16LE(offset + 1);
1873
1873
  } else if (first === 254) {
1874
- decode.bytes = 5;
1874
+ decode2.bytes = 5;
1875
1875
  return buffer.readUInt32LE(offset + 1);
1876
1876
  } else {
1877
- decode.bytes = 9;
1877
+ decode2.bytes = 9;
1878
1878
  var lo = buffer.readUInt32LE(offset + 1);
1879
1879
  var hi = buffer.readUInt32LE(offset + 5);
1880
1880
  var number = hi * 4294967296 + lo;
@@ -1886,7 +1886,7 @@ var require_varuint_bitcoin = __commonJS({
1886
1886
  checkUInt53(number);
1887
1887
  return number < 253 ? 1 : number <= 65535 ? 3 : number <= 4294967295 ? 5 : 9;
1888
1888
  }
1889
- module2.exports = { encode, decode, encodingLength };
1889
+ module2.exports = { encode, decode: decode2, encodingLength };
1890
1890
  }
1891
1891
  });
1892
1892
 
@@ -1979,7 +1979,7 @@ var require_smart_transaction_signatures = __commonJS({
1979
1979
  "node_modules/.pnpm/@bitgo+utxo-lib@https+++codeload.github.com+VerusCoin+BitGoJS+tar.gz+9701df63b479984f27_7b6d2dd0c6d9d9555ac626a4a148d56a/node_modules/@bitgo/utxo-lib/dist/src/smart_transaction_signatures.js"(exports2, module2) {
1980
1980
  "use strict";
1981
1981
  var Buffer2 = require_safe_buffer().Buffer;
1982
- var bscript3 = require_script();
1982
+ var bscript2 = require_script();
1983
1983
  var varuint = require_varuint_bitcoin();
1984
1984
  var SmartTransactionSignature = require_smart_transaction_signature();
1985
1985
  var SmartTransactionSignatures = (
@@ -1998,7 +1998,7 @@ var require_smart_transaction_signatures = __commonJS({
1998
1998
  this.error = null;
1999
1999
  }
2000
2000
  SmartTransactionSignatures2.prototype.isValid = function() {
2001
- return this.version > 0 && this.version < 2 && bscript3.isDefinedHashType(this.sigHashType) && this.signatures.length > 0;
2001
+ return this.version > 0 && this.version < 2 && bscript2.isDefinedHashType(this.sigHashType) && this.signatures.length > 0;
2002
2002
  };
2003
2003
  SmartTransactionSignatures2.prototype.__byteLength = function() {
2004
2004
  return this.signatures.reduce(function(a, x) {
@@ -2066,7 +2066,7 @@ var require_smart_transaction_signatures = __commonJS({
2066
2066
  }
2067
2067
  this.version = readUInt8();
2068
2068
  this.sigHashType = readUInt8();
2069
- if (!(this.version > 0 && this.version < 2 && bscript3.isDefinedHashType(this.sigHashType))) {
2069
+ if (!(this.version > 0 && this.version < 2 && bscript2.isDefinedHashType(this.sigHashType))) {
2070
2070
  return initialOffset;
2071
2071
  }
2072
2072
  this.signatures = this.signatures ? this.signatures : [];
@@ -2091,15 +2091,15 @@ var require_smart_transaction_signatures = __commonJS({
2091
2091
  var require_input7 = __commonJS({
2092
2092
  "node_modules/.pnpm/@bitgo+utxo-lib@https+++codeload.github.com+VerusCoin+BitGoJS+tar.gz+9701df63b479984f27_7b6d2dd0c6d9d9555ac626a4a148d56a/node_modules/@bitgo/utxo-lib/dist/src/templates/smarttransaction/input.js"(exports2, module2) {
2093
2093
  "use strict";
2094
- var bscript3 = require_script();
2094
+ var bscript2 = require_script();
2095
2095
  var typeforce = require_typeforce();
2096
2096
  var OPS = require_bitcoin_ops();
2097
2097
  var SmartTransactionSignatures = require_smart_transaction_signatures();
2098
2098
  function partialSignature(value) {
2099
- return value === OPS.OP_0 || bscript3.isCanonicalSignature(value);
2099
+ return value === OPS.OP_0 || bscript2.isCanonicalSignature(value);
2100
2100
  }
2101
2101
  function check(script) {
2102
- var chunks = bscript3.decompile(script);
2102
+ var chunks = bscript2.decompile(script);
2103
2103
  if (chunks.length !== 1)
2104
2104
  return false;
2105
2105
  return SmartTransactionSignatures.fromChunk(chunks[0]).isValid();
@@ -2115,19 +2115,19 @@ var require_input7 = __commonJS({
2115
2115
  throw smartTxSigs.error;
2116
2116
  }
2117
2117
  function encode(signatures, scriptPubKey) {
2118
- return bscript3.compile(encodeStack(signatures, scriptPubKey));
2118
+ return bscript2.compile(encodeStack(signatures, scriptPubKey));
2119
2119
  }
2120
2120
  function decodeStack(stack, allowIncomplete) {
2121
2121
  typeforce(check, stack, allowIncomplete);
2122
2122
  return stack.slice(1);
2123
2123
  }
2124
- function decode(buffer, allowIncomplete) {
2125
- var stack = bscript3.decompile(buffer);
2124
+ function decode2(buffer, allowIncomplete) {
2125
+ var stack = bscript2.decompile(buffer);
2126
2126
  return decodeStack(stack, allowIncomplete);
2127
2127
  }
2128
2128
  module2.exports = {
2129
2129
  check,
2130
- decode,
2130
+ decode: decode2,
2131
2131
  decodeStack,
2132
2132
  encode,
2133
2133
  encodeStack,
@@ -2546,7 +2546,7 @@ var require_bufferutils = __commonJS({
2546
2546
  var require_optccparams = __commonJS({
2547
2547
  "node_modules/.pnpm/@bitgo+utxo-lib@https+++codeload.github.com+VerusCoin+BitGoJS+tar.gz+9701df63b479984f27_7b6d2dd0c6d9d9555ac626a4a148d56a/node_modules/@bitgo/utxo-lib/dist/src/optccparams.js"(exports2, module2) {
2548
2548
  "use strict";
2549
- var bscript3 = require_script();
2549
+ var bscript2 = require_script();
2550
2550
  var EVALS2 = require_evals();
2551
2551
  var varuint = require_varuint_bitcoin();
2552
2552
  var TxDestination2 = require_tx_destination();
@@ -2677,7 +2677,7 @@ var require_optccparams = __commonJS({
2677
2677
  return readSlice(readVarInt());
2678
2678
  }
2679
2679
  var scriptInVector = readVarSlice();
2680
- var chunks = bscript3.decompile(scriptInVector);
2680
+ var chunks = bscript2.decompile(scriptInVector);
2681
2681
  if (chunks[0].length !== 4) {
2682
2682
  this.version = 0;
2683
2683
  this.error = new Error("invalid optional parameters header");
@@ -2724,7 +2724,7 @@ var require_optccparams = __commonJS({
2724
2724
  this.vData.forEach(function(x) {
2725
2725
  chunks.push(x);
2726
2726
  });
2727
- return varSliceSize(bscript3.compile(chunks));
2727
+ return varSliceSize(bscript2.compile(chunks));
2728
2728
  };
2729
2729
  OptCCParams3.prototype.toBuffer = function(buffer, initialOffset, asChunk) {
2730
2730
  if (asChunk === void 0) {
@@ -2753,7 +2753,7 @@ var require_optccparams = __commonJS({
2753
2753
  this.vData.forEach(function(x) {
2754
2754
  chunks.push(x);
2755
2755
  });
2756
- var scriptStore = bscript3.compile(chunks);
2756
+ var scriptStore = bscript2.compile(chunks);
2757
2757
  if (!buffer)
2758
2758
  buffer = Buffer.allocUnsafe(asChunk ? scriptStore.length : varSliceSize(scriptStore));
2759
2759
  if (asChunk) {
@@ -2776,14 +2776,14 @@ var require_optccparams = __commonJS({
2776
2776
  var require_output8 = __commonJS({
2777
2777
  "node_modules/.pnpm/@bitgo+utxo-lib@https+++codeload.github.com+VerusCoin+BitGoJS+tar.gz+9701df63b479984f27_7b6d2dd0c6d9d9555ac626a4a148d56a/node_modules/@bitgo/utxo-lib/dist/src/templates/smarttransaction/output.js"(exports2, module2) {
2778
2778
  "use strict";
2779
- var bscript3 = require_script();
2779
+ var bscript2 = require_script();
2780
2780
  var types = require_types();
2781
2781
  var typeforce = require_typeforce();
2782
2782
  var OPS = require_bitcoin_ops();
2783
2783
  var OptCCParams2 = require_optccparams();
2784
2784
  var OP_INT_BASE = OPS.OP_RESERVED;
2785
2785
  function check(script) {
2786
- var chunks = bscript3.decompile(script);
2786
+ var chunks = bscript2.decompile(script);
2787
2787
  if (chunks.length < 4 || !(chunks[chunks.length - 1] === OPS.OP_DROP && chunks[1] === OPS.OP_CHECKCRYPTOCONDITION)) {
2788
2788
  return false;
2789
2789
  }
@@ -2800,7 +2800,7 @@ var require_output8 = __commonJS({
2800
2800
  function encode(m, pubKeys) {
2801
2801
  typeforce({
2802
2802
  m: types.Number,
2803
- pubKeys: [bscript3.isCanonicalPubKey]
2803
+ pubKeys: [bscript2.isCanonicalPubKey]
2804
2804
  }, {
2805
2805
  m,
2806
2806
  pubKeys
@@ -2808,10 +2808,10 @@ var require_output8 = __commonJS({
2808
2808
  var n = pubKeys.length;
2809
2809
  if (n < m)
2810
2810
  throw new TypeError("Not enough pubKeys provided");
2811
- return bscript3.compile([].concat(OP_INT_BASE + m, pubKeys, OP_INT_BASE + n, OPS.OP_CHECKMULTISIG));
2811
+ return bscript2.compile([].concat(OP_INT_BASE + m, pubKeys, OP_INT_BASE + n, OPS.OP_CHECKMULTISIG));
2812
2812
  }
2813
- function decode(buffer, allowIncomplete) {
2814
- var chunks = bscript3.decompile(buffer);
2813
+ function decode2(buffer, allowIncomplete) {
2814
+ var chunks = bscript2.decompile(buffer);
2815
2815
  typeforce(check, chunks, allowIncomplete);
2816
2816
  return {
2817
2817
  m: chunks[0] - OP_INT_BASE,
@@ -2820,7 +2820,7 @@ var require_output8 = __commonJS({
2820
2820
  }
2821
2821
  module2.exports = {
2822
2822
  check,
2823
- decode,
2823
+ decode: decode2,
2824
2824
  encode
2825
2825
  };
2826
2826
  }
@@ -4424,7 +4424,7 @@ var require_bech32 = __commonJS({
4424
4424
  }
4425
4425
  return result;
4426
4426
  }
4427
- function decode(str) {
4427
+ function decode2(str) {
4428
4428
  if (str.length < 8) throw new TypeError(str + " too short");
4429
4429
  if (str.length > 90) throw new TypeError(str + " too long");
4430
4430
  let lowered = str.toLowerCase();
@@ -4478,7 +4478,7 @@ var require_bech32 = __commonJS({
4478
4478
  function fromWords(words) {
4479
4479
  return convert2(words, 5, 8, false);
4480
4480
  }
4481
- module2.exports = { decode, encode, toWords, fromWords };
4481
+ module2.exports = { decode: decode2, encode, toWords, fromWords };
4482
4482
  }
4483
4483
  });
4484
4484
 
@@ -4811,14 +4811,14 @@ var require_address = __commonJS({
4811
4811
  "use strict";
4812
4812
  var Buffer2 = require_safe_buffer().Buffer;
4813
4813
  var bech32 = require_bech32();
4814
- var bs58check4 = require("bs58check");
4815
- var bscript3 = require_script();
4814
+ var bs58check5 = require("bs58check");
4815
+ var bscript2 = require_script();
4816
4816
  var btemplates = require_templates();
4817
4817
  var networks3 = require_networks();
4818
4818
  var typeforce = require_typeforce();
4819
4819
  var types = require_types();
4820
4820
  function fromBase58Check3(address) {
4821
- var payload = bs58check4.decode(address);
4821
+ var payload = bs58check5.decode(address);
4822
4822
  if (payload.length < 21)
4823
4823
  throw new TypeError(address + " is too short");
4824
4824
  if (payload.length > 22)
@@ -4846,7 +4846,7 @@ var require_address = __commonJS({
4846
4846
  var payload = Buffer2.allocUnsafe(size);
4847
4847
  multibyte ? payload.writeUInt16BE(version, 0) : payload.writeUInt8(version, 0);
4848
4848
  hash.copy(payload, offset);
4849
- return bs58check4.encode(payload);
4849
+ return bs58check5.encode(payload);
4850
4850
  }
4851
4851
  function toBech32(data, version, prefix) {
4852
4852
  var words = bech32.toWords(data);
@@ -4856,40 +4856,40 @@ var require_address = __commonJS({
4856
4856
  function fromOutputScript(outputScript, network) {
4857
4857
  network = network || networks3.bitcoin;
4858
4858
  if (btemplates.pubKeyHash.output.check(outputScript))
4859
- return toBase58Check(bscript3.compile(outputScript).slice(3, 23), network.pubKeyHash);
4859
+ return toBase58Check(bscript2.compile(outputScript).slice(3, 23), network.pubKeyHash);
4860
4860
  if (btemplates.scriptHash.output.check(outputScript))
4861
- return toBase58Check(bscript3.compile(outputScript).slice(2, 22), network.scriptHash);
4861
+ return toBase58Check(bscript2.compile(outputScript).slice(2, 22), network.scriptHash);
4862
4862
  if (btemplates.witnessPubKeyHash.output.check(outputScript))
4863
- return toBech32(bscript3.compile(outputScript).slice(2, 22), 0, network.bech32);
4863
+ return toBech32(bscript2.compile(outputScript).slice(2, 22), 0, network.bech32);
4864
4864
  if (btemplates.witnessScriptHash.output.check(outputScript))
4865
- return toBech32(bscript3.compile(outputScript).slice(2, 34), 0, network.bech32);
4866
- throw new Error(bscript3.toASM(outputScript) + " has no matching Address");
4865
+ return toBech32(bscript2.compile(outputScript).slice(2, 34), 0, network.bech32);
4866
+ throw new Error(bscript2.toASM(outputScript) + " has no matching Address");
4867
4867
  }
4868
4868
  function toOutputScript(address, network) {
4869
4869
  network = network || networks3.bitcoin;
4870
- var decode;
4870
+ var decode2;
4871
4871
  try {
4872
- decode = fromBase58Check3(address);
4872
+ decode2 = fromBase58Check3(address);
4873
4873
  } catch (e) {
4874
4874
  }
4875
- if (decode) {
4876
- if (decode.version === network.pubKeyHash)
4877
- return btemplates.pubKeyHash.output.encode(decode.hash);
4878
- if (decode.version === network.scriptHash)
4879
- return btemplates.scriptHash.output.encode(decode.hash);
4875
+ if (decode2) {
4876
+ if (decode2.version === network.pubKeyHash)
4877
+ return btemplates.pubKeyHash.output.encode(decode2.hash);
4878
+ if (decode2.version === network.scriptHash)
4879
+ return btemplates.scriptHash.output.encode(decode2.hash);
4880
4880
  } else {
4881
4881
  try {
4882
- decode = fromBech32(address);
4882
+ decode2 = fromBech32(address);
4883
4883
  } catch (e) {
4884
4884
  }
4885
- if (decode) {
4886
- if (decode.prefix !== network.bech32)
4885
+ if (decode2) {
4886
+ if (decode2.prefix !== network.bech32)
4887
4887
  throw new Error(address + " has an invalid prefix");
4888
- if (decode.version === 0) {
4889
- if (decode.data.length === 20)
4890
- return btemplates.witnessPubKeyHash.output.encode(decode.data);
4891
- if (decode.data.length === 32)
4892
- return btemplates.witnessScriptHash.output.encode(decode.data);
4888
+ if (decode2.version === 0) {
4889
+ if (decode2.data.length === 20)
4890
+ return btemplates.witnessPubKeyHash.output.encode(decode2.data);
4891
+ if (decode2.data.length === 32)
4892
+ return btemplates.witnessScriptHash.output.encode(decode2.data);
4893
4893
  }
4894
4894
  }
4895
4895
  }
@@ -4984,9 +4984,9 @@ var require_ecsignature = __commonJS({
4984
4984
  return new ECSignature(r, s);
4985
4985
  };
4986
4986
  ECSignature.fromDER = function(buffer) {
4987
- var decode = bip66.decode(buffer);
4988
- var r = BigInteger.fromDERInteger(decode.r);
4989
- var s = BigInteger.fromDERInteger(decode.s);
4987
+ var decode2 = bip66.decode(buffer);
4988
+ var r = BigInteger.fromDERInteger(decode2.r);
4989
+ var s = BigInteger.fromDERInteger(decode2.s);
4990
4990
  return new ECSignature(r, s);
4991
4991
  };
4992
4992
  ECSignature.parseScriptSignature = function(buffer) {
@@ -10342,12 +10342,12 @@ var require_transaction = __commonJS({
10342
10342
  "use strict";
10343
10343
  var Buffer2 = require_safe_buffer().Buffer;
10344
10344
  var bcrypto = require_crypto();
10345
- var bscript3 = require_script();
10345
+ var bscript2 = require_script();
10346
10346
  var _a = require_bufferutils();
10347
10347
  var BufferReader = _a.BufferReader;
10348
10348
  var BufferWriter = _a.BufferWriter;
10349
10349
  var coins = require_coins();
10350
- var opcodes3 = require_bitcoin_ops();
10350
+ var opcodes2 = require_bitcoin_ops();
10351
10351
  var networks3 = require_networks();
10352
10352
  var typeforce = require_typeforce();
10353
10353
  var types = require_types();
@@ -10666,8 +10666,8 @@ var require_transaction = __commonJS({
10666
10666
  ), arguments);
10667
10667
  if (inIndex >= this.ins.length)
10668
10668
  return ONE;
10669
- var ourScript = bscript3.compile(bscript3.decompile(prevOutScript).filter(function(x) {
10670
- return x !== opcodes3.OP_CODESEPARATOR;
10669
+ var ourScript = bscript2.compile(bscript2.decompile(prevOutScript).filter(function(x) {
10670
+ return x !== opcodes2.OP_CODESEPARATOR;
10671
10671
  }));
10672
10672
  var txTmp = this.clone();
10673
10673
  if ((hashType & 31) === Transaction5.SIGHASH_NONE) {
@@ -10980,7 +10980,7 @@ var require_signature = __commonJS({
10980
10980
  exports2.getDefaultSigHash = getDefaultSigHash;
10981
10981
  exports2.parseSignatureScript = parseSignatureScript;
10982
10982
  exports2.verifySignature = verifySignature;
10983
- var opcodes3 = require_bitcoin_ops();
10983
+ var opcodes2 = require_bitcoin_ops();
10984
10984
  var script = require_script();
10985
10985
  var crypto2 = require_crypto();
10986
10986
  var ECPair4 = require_ecpair();
@@ -11043,8 +11043,8 @@ var require_signature = __commonJS({
11043
11043
  throw new Error("expected ".concat(nPubKeys, " public keys, got ").concat(publicKeys.length));
11044
11044
  }
11045
11045
  var lastOpCode = decompiledPubScript[len - 1];
11046
- if (lastOpCode !== opcodes3.OP_CHECKMULTISIG) {
11047
- throw new Error("expected opcode #".concat(opcodes3.OP_CHECKMULTISIG, ", got opcode #").concat(lastOpCode));
11046
+ if (lastOpCode !== opcodes2.OP_CHECKMULTISIG) {
11047
+ throw new Error("expected opcode #".concat(opcodes2.OP_CHECKMULTISIG, ", got opcode #").concat(lastOpCode));
11048
11048
  }
11049
11049
  return { isSegwitInput, inputClassification, signatures, publicKeys, pubScript };
11050
11050
  }
@@ -11820,7 +11820,7 @@ var require_transaction_builder = __commonJS({
11820
11820
  var Buffer2 = require_safe_buffer().Buffer;
11821
11821
  var baddress = require_address();
11822
11822
  var bcrypto = require_crypto();
11823
- var bscript3 = require_script();
11823
+ var bscript2 = require_script();
11824
11824
  var btemplates = require_templates();
11825
11825
  var coins = require_coins();
11826
11826
  var networks3 = require_networks();
@@ -11894,7 +11894,7 @@ var require_transaction_builder = __commonJS({
11894
11894
  var p2sh = false;
11895
11895
  var witnessProgram;
11896
11896
  var chunks;
11897
- var scriptSigChunks = bscript3.decompile(scriptSig);
11897
+ var scriptSigChunks = bscript2.decompile(scriptSig);
11898
11898
  var sigType = btemplates.classifyInput(scriptSigChunks, true);
11899
11899
  if (sigType === scriptTypes.P2SH) {
11900
11900
  p2sh = true;
@@ -12012,7 +12012,7 @@ var require_transaction_builder = __commonJS({
12012
12012
  }
12013
12013
  function expandOutput(script, scriptType, ourPubKey) {
12014
12014
  typeforce(types.Buffer, script);
12015
- var scriptChunks = bscript3.decompile(script);
12015
+ var scriptChunks = bscript2.decompile(script);
12016
12016
  if (!scriptType) {
12017
12017
  scriptType = btemplates.classifyOutput(script);
12018
12018
  }
@@ -12062,7 +12062,7 @@ var require_transaction_builder = __commonJS({
12062
12062
  if (input.prevOutType) {
12063
12063
  if (input.prevOutType !== scriptTypes.P2SH)
12064
12064
  throw new Error("PrevOutScript must be P2SH");
12065
- var prevOutScriptScriptHash = bscript3.decompile(input.prevOutScript)[1];
12065
+ var prevOutScriptScriptHash = bscript2.decompile(input.prevOutScript)[1];
12066
12066
  if (!prevOutScriptScriptHash.equals(redeemScriptHash))
12067
12067
  throw new Error("Inconsistent hash160(RedeemScript)");
12068
12068
  }
@@ -12071,7 +12071,7 @@ var require_transaction_builder = __commonJS({
12071
12071
  if (input.prevOutType) {
12072
12072
  if (input.prevOutType !== scriptTypes.P2WSH)
12073
12073
  throw new Error("PrevOutScript must be P2WSH");
12074
- var scriptHash = bscript3.decompile(input.prevOutScript)[1];
12074
+ var scriptHash = bscript2.decompile(input.prevOutScript)[1];
12075
12075
  if (!scriptHash.equals(witnessScriptHash))
12076
12076
  throw new Error("Inconsistent sha25(WitnessScript)");
12077
12077
  }
@@ -12097,7 +12097,7 @@ var require_transaction_builder = __commonJS({
12097
12097
  throw new Error("Witness script inconsistent with redeem script");
12098
12098
  expanded = expandOutput(witnessScript, void 0, kpPubKey);
12099
12099
  if (!expanded.pubKeys)
12100
- throw new Error('WitnessScript not supported "' + bscript3.toASM(redeemScript) + '"');
12100
+ throw new Error('WitnessScript not supported "' + bscript2.toASM(redeemScript) + '"');
12101
12101
  prevOutType = btemplates.types.P2SH;
12102
12102
  prevOutScript = btemplates.scriptHash.output.encode(redeemScriptHash);
12103
12103
  p2sh = witness = p2wsh = true;
@@ -12109,7 +12109,7 @@ var require_transaction_builder = __commonJS({
12109
12109
  checkP2SHInput(input, redeemScriptHash);
12110
12110
  expanded = expandOutput(redeemScript, void 0, kpPubKey);
12111
12111
  if (!expanded.pubKeys)
12112
- throw new Error('RedeemScript not supported "' + bscript3.toASM(redeemScript) + '"');
12112
+ throw new Error('RedeemScript not supported "' + bscript2.toASM(redeemScript) + '"');
12113
12113
  prevOutType = btemplates.types.P2SH;
12114
12114
  prevOutScript = btemplates.scriptHash.output.encode(redeemScriptHash);
12115
12115
  p2sh = true;
@@ -12121,7 +12121,7 @@ var require_transaction_builder = __commonJS({
12121
12121
  checkP2WSHInput(input, witnessScriptHash);
12122
12122
  expanded = expandOutput(witnessScript, void 0, kpPubKey);
12123
12123
  if (!expanded.pubKeys)
12124
- throw new Error('WitnessScript not supported "' + bscript3.toASM(redeemScript) + '"');
12124
+ throw new Error('WitnessScript not supported "' + bscript2.toASM(redeemScript) + '"');
12125
12125
  prevOutType = btemplates.types.P2WSH;
12126
12126
  prevOutScript = btemplates.witnessScriptHash.output.encode(witnessScriptHash);
12127
12127
  witness = p2wsh = true;
@@ -12236,7 +12236,7 @@ var require_transaction_builder = __commonJS({
12236
12236
  }
12237
12237
  return {
12238
12238
  type: scriptType,
12239
- script: bscript3.compile(sig),
12239
+ script: bscript2.compile(sig),
12240
12240
  witness
12241
12241
  };
12242
12242
  }
@@ -12282,7 +12282,7 @@ var require_transaction_builder = __commonJS({
12282
12282
  if (input.prevOutType === scriptTypes.SMART_TRANSACTION) {
12283
12283
  if (input.signatures === void 0 || input.signatures.length === 0)
12284
12284
  return true;
12285
- var smartTxSigs = SmartTransactionSignatures.fromChunk(bscript3.decompile(input.signatures)[0]);
12285
+ var smartTxSigs = SmartTransactionSignatures.fromChunk(bscript2.decompile(input.signatures)[0]);
12286
12286
  if (smartTxSigs.error != null || smartTxSigs.signatures.length === 0 || smartTxSigs.signatures.every(function(sig) {
12287
12287
  return sig.oneSignature.length === 0;
12288
12288
  })) {
@@ -12542,7 +12542,7 @@ var require_transaction_builder = __commonJS({
12542
12542
  if (input.signatures === void 0)
12543
12543
  return true;
12544
12544
  if (input.signType === scriptTypes.SMART_TRANSACTION) {
12545
- var smartTxSigs = SmartTransactionSignatures.fromChunk(bscript3.decompile(input.signatures)[0]);
12545
+ var smartTxSigs = SmartTransactionSignatures.fromChunk(bscript2.decompile(input.signatures)[0]);
12546
12546
  if (smartTxSigs.error != null || smartTxSigs.signatures.length === 0 || smartTxSigs.signatures.every(function(sig) {
12547
12547
  return sig.oneSignature.length === 0;
12548
12548
  })) {
@@ -14908,7 +14908,7 @@ var require_base64url = __commonJS({
14908
14908
  }
14909
14909
  return fromBase64(Buffer.from(input, encoding).toString("base64"));
14910
14910
  }
14911
- function decode(base64url2, encoding) {
14911
+ function decode2(base64url2, encoding) {
14912
14912
  if (encoding === void 0) {
14913
14913
  encoding = "utf8";
14914
14914
  }
@@ -14926,7 +14926,7 @@ var require_base64url = __commonJS({
14926
14926
  }
14927
14927
  var base64url = encode;
14928
14928
  base64url.encode = encode;
14929
- base64url.decode = decode;
14929
+ base64url.decode = decode2;
14930
14930
  base64url.toBase64 = toBase64;
14931
14931
  base64url.fromBase64 = fromBase64;
14932
14932
  base64url.toBuffer = toBuffer;
@@ -14983,7 +14983,7 @@ var require_varuint = __commonJS({
14983
14983
  return { buffer, bytes };
14984
14984
  };
14985
14985
  exports2.encode = encode;
14986
- var decode = (buffer, offset) => {
14986
+ var decode2 = (buffer, offset) => {
14987
14987
  if (!Buffer.isBuffer(buffer))
14988
14988
  throw new TypeError("buffer must be a Buffer instance");
14989
14989
  if (!offset)
@@ -15010,7 +15010,7 @@ var require_varuint = __commonJS({
15010
15010
  }
15011
15011
  return { decoded, bytes };
15012
15012
  };
15013
- exports2.decode = decode;
15013
+ exports2.decode = decode2;
15014
15014
  var encodingLength = (number) => {
15015
15015
  checkUInt53(number);
15016
15016
  return number < 253 ? 1 : number <= 65535 ? 3 : number <= 4294967295 ? 5 : 9;
@@ -15073,7 +15073,7 @@ var require_varint = __commonJS({
15073
15073
  const bytes = varintBuf.copy(buffer, offset);
15074
15074
  return { buffer, bytes };
15075
15075
  }
15076
- function decode(buffer, offset) {
15076
+ function decode2(buffer, offset) {
15077
15077
  if (!Buffer.isBuffer(buffer))
15078
15078
  throw new TypeError("buffer must be a Buffer instance");
15079
15079
  if (!offset)
@@ -15083,7 +15083,7 @@ var require_varint = __commonJS({
15083
15083
  }
15084
15084
  exports2.default = {
15085
15085
  encode,
15086
- decode,
15086
+ decode: decode2,
15087
15087
  encodingLength
15088
15088
  };
15089
15089
  }
@@ -15384,9 +15384,9 @@ var require_address2 = __commonJS({
15384
15384
  var vdxf_1 = require_vdxf();
15385
15385
  var hash_1 = require_hash();
15386
15386
  var tolower_1 = require_tolower();
15387
- var bs58check4 = require("bs58check");
15387
+ var bs58check5 = require("bs58check");
15388
15388
  var fromBase58Check3 = (address) => {
15389
- var payload = bs58check4.decode(address);
15389
+ var payload = bs58check5.decode(address);
15390
15390
  if (payload.length < 21)
15391
15391
  throw new TypeError(address + " is too short");
15392
15392
  if (payload.length > 22)
@@ -15405,7 +15405,7 @@ var require_address2 = __commonJS({
15405
15405
  var payload = Buffer.allocUnsafe(size);
15406
15406
  multibyte ? payload.writeUInt16BE(version, 0) : payload.writeUInt8(version, 0);
15407
15407
  hash.copy(payload, offset);
15408
- return bs58check4.encode(payload);
15408
+ return bs58check5.encode(payload);
15409
15409
  };
15410
15410
  exports2.toBase58Check = toBase58Check;
15411
15411
  var nameAndParentAddrToAddr = (name, parentIAddr, version = vdxf_1.I_ADDR_VERSION) => {
@@ -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
 
@@ -20633,7 +20633,7 @@ var require_dist = __commonJS({
20633
20633
  if (typeof res === "object")
20634
20634
  return res;
20635
20635
  }
20636
- function decode(str, LIMIT) {
20636
+ function decode2(str, LIMIT) {
20637
20637
  const res = __decode(str, LIMIT);
20638
20638
  if (typeof res === "object")
20639
20639
  return res;
@@ -20641,7 +20641,7 @@ var require_dist = __commonJS({
20641
20641
  }
20642
20642
  return {
20643
20643
  decodeUnsafe,
20644
- decode,
20644
+ decode: decode2,
20645
20645
  encode,
20646
20646
  toWords,
20647
20647
  fromWordsUnsafe,
@@ -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
 
@@ -23605,7 +23605,7 @@ var require_pushdata = __commonJS({
23605
23605
  Object.defineProperty(exports2, "__esModule", { value: true });
23606
23606
  exports2.encodingLength = encodingLength;
23607
23607
  exports2.encode = encode;
23608
- exports2.decode = decode;
23608
+ exports2.decode = decode2;
23609
23609
  var ops_1 = require_ops();
23610
23610
  function encodingLength(i) {
23611
23611
  return i < ops_1.OPS.OP_PUSHDATA1 ? 1 : i <= 255 ? 2 : i <= 65535 ? 3 : 5;
@@ -23626,7 +23626,7 @@ var require_pushdata = __commonJS({
23626
23626
  }
23627
23627
  return size;
23628
23628
  }
23629
- function decode(buffer, offset) {
23629
+ function decode2(buffer, offset) {
23630
23630
  var opcode = buffer.readUInt8(offset);
23631
23631
  var number, size;
23632
23632
  if (opcode < ops_1.OPS.OP_PUSHDATA1) {
@@ -24039,7 +24039,7 @@ var require_OptCCParams = __commonJS({
24039
24039
  "use strict";
24040
24040
  Object.defineProperty(exports2, "__esModule", { value: true });
24041
24041
  exports2.OptCCParams = void 0;
24042
- var bscript3 = require_script2();
24042
+ var bscript2 = require_script2();
24043
24043
  var evals_1 = require_evals2();
24044
24044
  var varuint_1 = require_varuint();
24045
24045
  var TxDestination_1 = require_TxDestination();
@@ -24141,7 +24141,7 @@ var require_OptCCParams = __commonJS({
24141
24141
  fromBuffer(buffer, offset = 0) {
24142
24142
  const reader = new bufferutils_1.default.BufferReader(buffer, offset);
24143
24143
  const scriptInVector = reader.readVarSlice();
24144
- const chunks = bscript3.decompile(scriptInVector);
24144
+ const chunks = bscript2.decompile(scriptInVector);
24145
24145
  const firstChunk = chunks[0];
24146
24146
  if (!Buffer.isBuffer(firstChunk)) {
24147
24147
  throw new Error("invalid first chunk date type");
@@ -24187,7 +24187,7 @@ var require_OptCCParams = __commonJS({
24187
24187
  this.vdata.forEach((x) => {
24188
24188
  chunks.push(x);
24189
24189
  });
24190
- const buf = bscript3.compile(chunks);
24190
+ const buf = bscript2.compile(chunks);
24191
24191
  return asChunk ? buf.length : varuint_1.default.encodingLength(buf.length) + buf.length;
24192
24192
  }
24193
24193
  getByteLength() {
@@ -24205,8 +24205,8 @@ var require_OptCCParams = __commonJS({
24205
24205
  this.vdata.forEach((x) => {
24206
24206
  chunks.push(x);
24207
24207
  });
24208
- const scriptStore = bscript3.compile(chunks);
24209
- const buf = bscript3.compile(chunks);
24208
+ const scriptStore = bscript2.compile(chunks);
24209
+ const buf = bscript2.compile(chunks);
24210
24210
  const len = asChunk ? buf.length : varuint_1.default.encodingLength(buf.length) + buf.length;
24211
24211
  const buffer = Buffer.alloc(len);
24212
24212
  const writer = new bufferutils_1.default.BufferWriter(buffer);
@@ -31623,7 +31623,7 @@ var require_smart_transactions = __commonJS({
31623
31623
  var TransactionBuilder5 = require_transaction_builder();
31624
31624
  var TxDestination2 = require_tx_destination();
31625
31625
  var script = require_script();
31626
- var opcodes3 = require_bitcoin_ops();
31626
+ var opcodes2 = require_bitcoin_ops();
31627
31627
  var OptCCParams2 = require_optccparams();
31628
31628
  var templates = require_templates();
31629
31629
  var BNClass = new bn_js_1.BN(0);
@@ -32115,9 +32115,9 @@ var require_smart_transactions = __commonJS({
32115
32115
  }
32116
32116
  var outputScript = script.compile([
32117
32117
  outMaster.toChunk(),
32118
- opcodes3.OP_CHECKCRYPTOCONDITION,
32118
+ opcodes2.OP_CHECKCRYPTOCONDITION,
32119
32119
  outParams.toChunk(),
32120
- opcodes3.OP_DROP
32120
+ opcodes2.OP_DROP
32121
32121
  ]);
32122
32122
  txb.addOutput(outputScript, nativeValue.toNumber());
32123
32123
  }
@@ -32242,9 +32242,9 @@ __export(src_exports, {
32242
32242
  classifyCurrency: () => classifyCurrency,
32243
32243
  currency: () => currency_exports,
32244
32244
  identity: () => identity_exports,
32245
- isIAddress: () => isIAddress,
32245
+ isIAddress: () => isIAddress2,
32246
32246
  isIdentityName: () => isIdentityName,
32247
- isRAddress: () => isRAddress,
32247
+ isRAddress: () => isRAddress2,
32248
32248
  isVerusAddress: () => isVerusAddress,
32249
32249
  keys: () => keys_exports,
32250
32250
  message: () => message_exports,
@@ -32271,7 +32271,7 @@ __export(transfer_exports, {
32271
32271
  var import_utxo_lib4 = __toESM(require_src2());
32272
32272
  var import_verus_typescript_primitives5 = __toESM(require_dist2());
32273
32273
  var import_bn2 = __toESM(require("bn.js"));
32274
- var import_bs58check3 = __toESM(require("bs58check"));
32274
+ var import_bs58check4 = __toESM(require("bs58check"));
32275
32275
 
32276
32276
  // src/constants/index.ts
32277
32277
  var NETWORK_CONFIG = {
@@ -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;
@@ -32474,6 +32473,12 @@ function addressToScriptPubKey(address) {
32474
32473
  }
32475
32474
  const prefix = decoded[0];
32476
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
+ }
32477
32482
  if (prefix === 60) {
32478
32483
  return Buffer.concat([
32479
32484
  Buffer.from([118, 169, 20]),
@@ -32627,6 +32632,7 @@ function validateFundedTransaction(systemId, fundedTxHex, unfundedTxHex, changeA
32627
32632
  // src/utxo/index.ts
32628
32633
  var utxo_exports = {};
32629
32634
  __export(utxo_exports, {
32635
+ assertTokenConservation: () => assertTokenConservation,
32630
32636
  decodeUtxo: () => decodeUtxo,
32631
32637
  estimateFee: () => estimateFee,
32632
32638
  selectUtxos: () => selectUtxos
@@ -32673,6 +32679,29 @@ function decodeUtxo(utxo, systemId) {
32673
32679
  }
32674
32680
  return { ...utxo, currencyValues };
32675
32681
  }
32682
+ function assertTokenConservation(selected, spentToOutputs, currencyChanges, systemId, label) {
32683
+ const inSums = /* @__PURE__ */ new Map();
32684
+ for (const u of selected) {
32685
+ const decoded = decodeUtxo(u, systemId);
32686
+ for (const [currency, amount] of decoded.currencyValues) {
32687
+ if (currency === systemId) continue;
32688
+ inSums.set(currency, (inSums.get(currency) || 0n) + amount);
32689
+ }
32690
+ }
32691
+ const currencies = /* @__PURE__ */ new Set();
32692
+ for (const c of inSums.keys()) currencies.add(c);
32693
+ for (const c of spentToOutputs.keys()) if (c !== systemId) currencies.add(c);
32694
+ for (const c of currencyChanges.keys()) if (c !== systemId) currencies.add(c);
32695
+ for (const currency of currencies) {
32696
+ const totalIn = inSums.get(currency) || 0n;
32697
+ const totalOut = (spentToOutputs.get(currency) || 0n) + (currencyChanges.get(currency) || 0n);
32698
+ if (totalIn !== totalOut) {
32699
+ throw new TransactionBuildError(
32700
+ `${label} token conservation failed for ${currency}: selected inputs ${totalIn} != fee+change ${totalOut}`
32701
+ );
32702
+ }
32703
+ }
32704
+ }
32676
32705
  function estimateFee(numInputs, numOutputs, feePerKb = DEFAULT_FEE_PER_KB, hasSmartOutputs = false, extraBytes = 0) {
32677
32706
  const outputSize = hasSmartOutputs ? SMART_OUTPUT_SIZE : P2PKH_OUTPUT_SIZE;
32678
32707
  const txSize = TX_OVERHEAD + numInputs * INPUT_SIZE + numOutputs * outputSize + extraBytes;
@@ -32801,6 +32830,8 @@ function selectUtxos(utxos, requiredNative, requiredCurrencies = /* @__PURE__ */
32801
32830
  // src/identity/index.ts
32802
32831
  var identity_exports = {};
32803
32832
  __export(identity_exports, {
32833
+ assertAddressVersion: () => assertAddressVersion,
32834
+ assertWifIsPrimary: () => assertWifIsPrimary,
32804
32835
  buildAndSignCommitment: () => buildAndSignCommitment,
32805
32836
  buildAndSignIdentityUpdate: () => buildAndSignIdentityUpdate,
32806
32837
  buildAndSignRegistration: () => buildAndSignRegistration,
@@ -32831,6 +32862,55 @@ var import_verus_typescript_primitives3 = __toESM(require_dist2());
32831
32862
  var import_verus_typescript_primitives4 = __toESM(require_dist2());
32832
32863
  var import_utxo_lib3 = __toESM(require_src2());
32833
32864
 
32865
+ // src/core/brands.ts
32866
+ var import_bs58check2 = __toESM(require("bs58check"));
32867
+ var P2SH_VERSION = 85;
32868
+ function decode(s, label) {
32869
+ let decoded;
32870
+ try {
32871
+ decoded = import_bs58check2.default.decode(s);
32872
+ } catch (err) {
32873
+ throw new InvalidAddressError(String(s), `${label} is not valid base58check: ${err.message}`);
32874
+ }
32875
+ if (decoded.length !== 21) {
32876
+ throw new InvalidAddressError(String(s), `${label} must decode to a 1-byte version + 20-byte hash, got ${decoded.length} bytes`);
32877
+ }
32878
+ return { version: decoded[0] };
32879
+ }
32880
+ function parseRAddress(s, label = "address") {
32881
+ const { version } = decode(s, label);
32882
+ if (version !== PUBKEY_HASH_PREFIX) {
32883
+ throw new InvalidAddressError(s, `${label} must be an R-address (version ${PUBKEY_HASH_PREFIX}), got version ${version}`);
32884
+ }
32885
+ return s;
32886
+ }
32887
+ function parseIAddress(s, label = "address") {
32888
+ const { version } = decode(s, label);
32889
+ if (version !== I_ADDR_VERSION) {
32890
+ throw new InvalidAddressError(s, `${label} must be an identity i-address (version ${I_ADDR_VERSION}), got version ${version}`);
32891
+ }
32892
+ return s;
32893
+ }
32894
+ function parseAddress(s, label = "address") {
32895
+ const { version } = decode(s, label);
32896
+ switch (version) {
32897
+ case PUBKEY_HASH_PREFIX:
32898
+ return s;
32899
+ case I_ADDR_VERSION:
32900
+ return s;
32901
+ case P2SH_VERSION:
32902
+ return s;
32903
+ default:
32904
+ throw new InvalidAddressError(s, `${label} has unsupported version byte ${version}`);
32905
+ }
32906
+ }
32907
+ function isIAddress(a) {
32908
+ return decode(a, "address").version === I_ADDR_VERSION;
32909
+ }
32910
+ function isRAddress(a) {
32911
+ return decode(a, "address").version === PUBKEY_HASH_PREFIX;
32912
+ }
32913
+
32834
32914
  // src/keys/index.ts
32835
32915
  var keys_exports = {};
32836
32916
  __export(keys_exports, {
@@ -32845,11 +32925,11 @@ __export(keys_exports, {
32845
32925
  wifToPrivateKey: () => wifToPrivateKey
32846
32926
  });
32847
32927
  var crypto = __toESM(require("crypto"));
32848
- var import_bs58check2 = __toESM(require("bs58check"));
32928
+ var import_bs58check3 = __toESM(require("bs58check"));
32849
32929
  var import_create_hash = __toESM(require("create-hash"));
32850
32930
  function validateWif(wif) {
32851
32931
  try {
32852
- const decoded = import_bs58check2.default.decode(wif);
32932
+ const decoded = import_bs58check3.default.decode(wif);
32853
32933
  if (decoded.length !== 33 && decoded.length !== 34) {
32854
32934
  return { valid: false, error: "Invalid WIF length" };
32855
32935
  }
@@ -32857,13 +32937,16 @@ function validateWif(wif) {
32857
32937
  if (prefix !== WIF_PREFIX) {
32858
32938
  return { valid: false, error: `Invalid WIF prefix: ${prefix}` };
32859
32939
  }
32940
+ if (decoded.length === 34 && decoded[33] !== 1) {
32941
+ return { valid: false, error: `Invalid WIF compression flag: ${decoded[33]}` };
32942
+ }
32860
32943
  return { valid: true };
32861
32944
  } catch (error) {
32862
32945
  return { valid: false, error: `Invalid WIF format: ${error.message}` };
32863
32946
  }
32864
32947
  }
32865
32948
  function wifToPrivateKey(wif) {
32866
- const decoded = import_bs58check2.default.decode(wif);
32949
+ const decoded = import_bs58check3.default.decode(wif);
32867
32950
  if (decoded.length === 34) {
32868
32951
  return Buffer.from(decoded.slice(1, 33));
32869
32952
  } else {
@@ -32871,7 +32954,7 @@ function wifToPrivateKey(wif) {
32871
32954
  }
32872
32955
  }
32873
32956
  function isCompressedWif(wif) {
32874
- const decoded = import_bs58check2.default.decode(wif);
32957
+ const decoded = import_bs58check3.default.decode(wif);
32875
32958
  return decoded.length === 34 && decoded[33] === 1;
32876
32959
  }
32877
32960
  async function privateKeyToPublicKey(privateKey, compressed = true) {
@@ -32892,7 +32975,7 @@ function hash160(data) {
32892
32975
  function publicKeyToAddress(publicKey) {
32893
32976
  const hash = hash160(publicKey);
32894
32977
  const payload = Buffer.concat([Buffer.from([PUBKEY_HASH_PREFIX]), hash]);
32895
- return import_bs58check2.default.encode(payload);
32978
+ return import_bs58check3.default.encode(payload);
32896
32979
  }
32897
32980
  async function wifToAddress(wif) {
32898
32981
  const validation = validateWif(wif);
@@ -32907,11 +32990,11 @@ async function wifToAddress(wif) {
32907
32990
  function generateWif(compressed = true) {
32908
32991
  const privateKey = crypto.randomBytes(32);
32909
32992
  const payload = compressed ? Buffer.concat([Buffer.from([WIF_PREFIX]), privateKey, Buffer.from([1])]) : Buffer.concat([Buffer.from([WIF_PREFIX]), privateKey]);
32910
- return import_bs58check2.default.encode(payload);
32993
+ return import_bs58check3.default.encode(payload);
32911
32994
  }
32912
32995
  function validateAddress(address) {
32913
32996
  try {
32914
- const decoded = import_bs58check2.default.decode(address);
32997
+ const decoded = import_bs58check3.default.decode(address);
32915
32998
  if (decoded.length !== 21) {
32916
32999
  return { valid: false, error: "Invalid address length" };
32917
33000
  }
@@ -32945,6 +33028,15 @@ function assertAddressVersion(address, expectedVersion, label) {
32945
33028
  );
32946
33029
  }
32947
33030
  }
33031
+ function assertWifIsPrimary(wif, identity, network) {
33032
+ const signerAddress = import_utxo_lib3.ECPair.fromWIF(wif, network).getAddress();
33033
+ const currentPrimaries = (identity.primary_addresses ?? []).map((k) => k.toAddress());
33034
+ if (!currentPrimaries.includes(signerAddress)) {
33035
+ throw new TransactionBuildError(
33036
+ `the provided WIF (${signerAddress}) is not among the identity's primary addresses [${currentPrimaries.join(", ")}]; it cannot authorize this operation.`
33037
+ );
33038
+ }
33039
+ }
32948
33040
  function validateMinSigs(minSigs, primaryCount) {
32949
33041
  if (!Number.isInteger(minSigs) || minSigs < 1 || minSigs > primaryCount) {
32950
33042
  throw new TransactionBuildError(
@@ -33037,6 +33129,9 @@ function buildIdentityScript(identity) {
33037
33129
  return identityScript.toBuffer();
33038
33130
  }
33039
33131
  function deriveIdentityAddress(name, parentIAddress) {
33132
+ if (parentIAddress) {
33133
+ assertAddressVersion(parentIAddress, I_ADDR_VERSION, "parent");
33134
+ }
33040
33135
  return (0, import_verus_typescript_primitives4.nameAndParentAddrToIAddr)(name, parentIAddress || void 0);
33041
33136
  }
33042
33137
  function isVRSCParent(parentIAddress, network = "mainnet") {
@@ -33044,9 +33139,11 @@ function isVRSCParent(parentIAddress, network = "mainnet") {
33044
33139
  const systemId = NETWORK_CONFIG[network].chainId;
33045
33140
  return parentIAddress === systemId;
33046
33141
  }
33047
- function prepareNameCommitment(name, controlAddress, referralIAddress, parentIAddress, network = "mainnet") {
33048
- const salt = generateSalt();
33142
+ function prepareNameCommitment(name, controlAddress, referralIAddress, parentIAddress, network = "mainnet", salt = generateSalt()) {
33049
33143
  const systemId = NETWORK_CONFIG[network].chainId;
33144
+ if (referralIAddress) {
33145
+ assertAddressVersion(referralIAddress, I_ADDR_VERSION, "referral");
33146
+ }
33050
33147
  const referralHash = referralIAddress ? iAddressToHash(referralIAddress) : NULL_ID_HASH;
33051
33148
  const effectiveParent = parentIAddress && parentIAddress !== systemId ? parentIAddress : void 0;
33052
33149
  const identityAddress = deriveIdentityAddress(name, effectiveParent || systemId);
@@ -33065,7 +33162,7 @@ function prepareNameCommitment(name, controlAddress, referralIAddress, parentIAd
33065
33162
  }
33066
33163
  const commitmentHash = calculateCommitmentHash(serializedReservation);
33067
33164
  const serializedCommitmentHash = serializeCommitmentHash(commitmentHash);
33068
- const commitmentScript = buildCommitmentScript(commitmentHash, controlAddress);
33165
+ const commitmentScript = buildCommitmentScript(commitmentHash, parseRAddress(controlAddress, "controlAddress"));
33069
33166
  return {
33070
33167
  salt,
33071
33168
  serializedReservation,
@@ -33076,15 +33173,7 @@ function prepareNameCommitment(name, controlAddress, referralIAddress, parentIAd
33076
33173
  };
33077
33174
  }
33078
33175
  function buildP2IDScript(iAddress) {
33079
- const idHash = iAddressToHash(iAddress);
33080
- return import_utxo_lib3.script.compile([
33081
- import_utxo_lib3.opcodes.OP_DUP,
33082
- import_utxo_lib3.opcodes.OP_HASH160,
33083
- idHash,
33084
- import_utxo_lib3.opcodes.OP_EQUALVERIFY,
33085
- import_utxo_lib3.opcodes.OP_CHECKSIG,
33086
- import_utxo_lib3.opcodes.OP_CHECKCRYPTOCONDITION
33087
- ]);
33176
+ return identityPaymentScript(parseIAddress(iAddress, "iAddress"));
33088
33177
  }
33089
33178
  function identityPaymentScript(iAddress) {
33090
33179
  return buildReferralPaymentScript(iAddress);
@@ -33120,11 +33209,6 @@ function calculateRegistrationFees(hasReferral, totalFee = DEFAULT_REGISTRATION_
33120
33209
  return { issuerFee, referralAmount, totalRequired };
33121
33210
  }
33122
33211
  function createIdentityObject(params) {
33123
- params.primaryAddresses.forEach(
33124
- (addr, i) => assertAddressVersion(addr, PUBKEY_HASH_PREFIX, `primaryAddresses[${i}]`)
33125
- );
33126
- assertAddressVersion(params.revocationAuthority, I_ADDR_VERSION, "revocationAuthority");
33127
- assertAddressVersion(params.recoveryAuthority, I_ADDR_VERSION, "recoveryAuthority");
33128
33212
  validateMinSigs(params.minSigs ?? 1, params.primaryAddresses.length);
33129
33213
  const primaryKeys = params.primaryAddresses.map((addr) => import_verus_typescript_primitives2.KeyID.fromAddress(addr));
33130
33214
  const identity = new import_verus_typescript_primitives2.Identity({
@@ -33143,55 +33227,18 @@ function createIdentityObject(params) {
33143
33227
  return identity;
33144
33228
  }
33145
33229
  function buildRegistrationFeeOutput(parentCurrencyId, feeAmount, systemId, _controlAddress) {
33146
- const destination = new import_verus_typescript_primitives2.TxDestination(import_verus_typescript_primitives2.KeyID.fromAddress(RESERVE_TRANSFER_EVAL_PKH));
33147
- const values = new import_verus_typescript_primitives2.CurrencyValueMap({
33148
- value_map: /* @__PURE__ */ new Map([[parentCurrencyId, new import_bn.default(feeAmount.toString(10))]]),
33149
- multivalue: false
33150
- });
33151
- const parentHash = (0, import_verus_typescript_primitives4.fromBase58Check)(parentCurrencyId).hash;
33152
- const transferDest = new import_verus_typescript_primitives2.TransferDestination({
33153
- type: import_verus_typescript_primitives2.DEST_ID,
33154
- destination_bytes: Buffer.from(parentHash)
33155
- });
33156
- const flags = import_verus_typescript_primitives2.RESERVE_TRANSFER_VALID.or(import_verus_typescript_primitives2.RESERVE_TRANSFER_BURN_CHANGE_PRICE);
33157
- const resTransfer = new import_verus_typescript_primitives2.ReserveTransfer({
33158
- values,
33159
- version: new import_bn.default(1),
33160
- flags,
33161
- fee_currency_id: systemId,
33162
- fee_amount: new import_bn.default(RESERVE_TRANSFER_FEE.toString(10)),
33163
- transfer_destination: transferDest,
33164
- dest_currency_id: parentCurrencyId
33165
- });
33166
- const master = new import_verus_typescript_primitives2.OptCCParams({
33167
- version: new import_bn.default(3),
33168
- eval_code: new import_bn.default(import_verus_typescript_primitives3.EVALS.EVAL_NONE),
33169
- m: new import_bn.default(1),
33170
- n: new import_bn.default(1),
33171
- destinations: [destination],
33172
- vdata: []
33173
- });
33174
- const params = new import_verus_typescript_primitives2.OptCCParams({
33175
- version: new import_bn.default(3),
33176
- eval_code: new import_bn.default(import_verus_typescript_primitives3.EVALS.EVAL_RESERVE_TRANSFER),
33177
- m: new import_bn.default(1),
33178
- n: new import_bn.default(1),
33179
- destinations: [destination],
33180
- vdata: [resTransfer.toBuffer()]
33181
- });
33182
- const script = new import_verus_typescript_primitives2.SmartTransactionScript(master, params);
33183
- return { script: script.toBuffer(), nativeValue: RESERVE_TRANSFER_FEE };
33230
+ void systemId;
33231
+ return buildTokenChangeOutput(parseIAddress(parentCurrencyId, "parentCurrencyId"), /* @__PURE__ */ new Map([[parentCurrencyId, feeAmount]]));
33184
33232
  }
33185
33233
  function buildTokenChangeOutput(changeAddress, currencyChanges) {
33186
- const version = (0, import_verus_typescript_primitives4.fromBase58Check)(changeAddress).version;
33187
33234
  let destination;
33188
- if (version === I_ADDR_VERSION) {
33235
+ if (isIAddress(changeAddress)) {
33189
33236
  destination = new import_verus_typescript_primitives2.TxDestination(import_verus_typescript_primitives2.IdentityID.fromAddress(changeAddress));
33190
- } else if (version === PUBKEY_HASH_PREFIX) {
33237
+ } else if (isRAddress(changeAddress)) {
33191
33238
  destination = new import_verus_typescript_primitives2.TxDestination(import_verus_typescript_primitives2.KeyID.fromAddress(changeAddress));
33192
33239
  } else {
33193
33240
  throw new TransactionBuildError(
33194
- `token change address must be an R-address or identity i-address, got version ${version}: ${changeAddress}`
33241
+ `token change address must be an R-address or identity i-address, got: ${changeAddress}`
33195
33242
  );
33196
33243
  }
33197
33244
  const valueMap = /* @__PURE__ */ new Map();
@@ -33256,7 +33303,8 @@ function buildAndSignCommitment(params, network) {
33256
33303
  controlAddress,
33257
33304
  params.referral,
33258
33305
  params.parent,
33259
- network
33306
+ network,
33307
+ params.salt
33260
33308
  );
33261
33309
  const utxos = params.utxos;
33262
33310
  const selection = selectUtxos(
@@ -33281,13 +33329,24 @@ function buildAndSignCommitment(params, network) {
33281
33329
  );
33282
33330
  }
33283
33331
  txb.addOutput(commitment.commitmentScript, 0);
33284
- if (selection.nativeChange > 0n) {
33285
- if (params.changeAddress.startsWith("i")) {
33286
- txb.addOutput(identityPaymentScript(params.changeAddress), toSafeNumber(selection.nativeChange));
33332
+ const hasTokenChange = selection.currencyChanges.size > 0;
33333
+ if (hasTokenChange || selection.nativeChange > 0n) {
33334
+ if (hasTokenChange) {
33335
+ const tokenChangeScript = buildTokenChangeOutput(parseAddress(params.changeAddress, "changeAddress"), selection.currencyChanges);
33336
+ txb.addOutput(tokenChangeScript.script, toSafeNumber(selection.nativeChange));
33337
+ } else if (params.changeAddress.startsWith("i")) {
33338
+ txb.addOutput(identityPaymentScript(parseIAddress(params.changeAddress, "changeAddress")), toSafeNumber(selection.nativeChange));
33287
33339
  } else {
33288
33340
  txb.addOutput(params.changeAddress, toSafeNumber(selection.nativeChange));
33289
33341
  }
33290
33342
  }
33343
+ assertTokenConservation(
33344
+ selection.selected,
33345
+ /* @__PURE__ */ new Map(),
33346
+ selection.currencyChanges,
33347
+ networkConfig.chainId,
33348
+ "name commitment"
33349
+ );
33291
33350
  const unsignedTx = txb.buildIncomplete();
33292
33351
  const { signedTx, txid } = signTransactionSmart(
33293
33352
  unsignedTx.toHex(),
@@ -33328,16 +33387,16 @@ function buildAndSignRegistration(params, network) {
33328
33387
  const identityAddress = deriveIdentityAddress(commitData.name, effectiveParent);
33329
33388
  const identity = createIdentityObject({
33330
33389
  name: commitData.name,
33331
- primaryAddresses: params.primaryAddresses,
33390
+ primaryAddresses: params.primaryAddresses.map((a, i) => parseRAddress(a, `primaryAddresses[${i}]`)),
33332
33391
  ...params.minSigs !== void 0 ? { minSigs: params.minSigs } : {},
33333
- revocationAuthority: params.revocationAuthority || identityAddress,
33334
- recoveryAuthority: params.recoveryAuthority || identityAddress,
33335
- parentIAddress,
33336
- systemId
33392
+ revocationAuthority: parseIAddress(params.revocationAuthority || identityAddress, "revocationAuthority"),
33393
+ recoveryAuthority: parseIAddress(params.recoveryAuthority || identityAddress, "recoveryAuthority"),
33394
+ parentIAddress: parseIAddress(parentIAddress, "parentIAddress"),
33395
+ systemId: parseIAddress(systemId, "systemId")
33337
33396
  });
33338
33397
  const identityScript = buildIdentityScript(identity);
33339
33398
  const reservationScript = buildReservationScript(
33340
- identityAddress,
33399
+ parseIAddress(identityAddress, "identityAddress"),
33341
33400
  Buffer.from(commitData.namereservationHex, "hex"),
33342
33401
  isSubId
33343
33402
  );
@@ -33357,6 +33416,7 @@ function _buildVrscRegistration(params, identityScript, reservationScript, ident
33357
33416
  const referralOutputs = [];
33358
33417
  if (hasReferral) {
33359
33418
  const chain = params.referralChain && params.referralChain.length > 0 ? params.referralChain : commitData.referral ? [commitData.referral] : [];
33419
+ chain.forEach((addr, i) => assertAddressVersion(addr, I_ADDR_VERSION, `referralChain[${i}]`));
33360
33420
  const referralLevels = params.referralLevels ?? DEFAULT_REFERRAL_LEVELS;
33361
33421
  if (chain.length > referralLevels) {
33362
33422
  throw new TransactionBuildError(
@@ -33365,7 +33425,7 @@ function _buildVrscRegistration(params, identityScript, reservationScript, ident
33365
33425
  }
33366
33426
  for (const referrerAddr of chain) {
33367
33427
  referralOutputs.push({
33368
- script: buildReferralPaymentScript(referrerAddr),
33428
+ script: buildReferralPaymentScript(parseIAddress(referrerAddr, "referralChain entry")),
33369
33429
  value: fees.referralAmount
33370
33430
  });
33371
33431
  }
@@ -33407,13 +33467,24 @@ function _buildVrscRegistration(params, identityScript, reservationScript, ident
33407
33467
  txb.addOutput(referralOut.script, toSafeNumber(referralOut.value));
33408
33468
  }
33409
33469
  txb.addOutput(reservationScript, 0);
33410
- if (selection.nativeChange > 0n) {
33411
- if (params.changeAddress.startsWith("i")) {
33412
- txb.addOutput(identityPaymentScript(params.changeAddress), toSafeNumber(selection.nativeChange));
33470
+ const hasTokenChange = selection.currencyChanges.size > 0;
33471
+ if (hasTokenChange || selection.nativeChange > 0n) {
33472
+ if (hasTokenChange) {
33473
+ const tokenChangeScript = buildTokenChangeOutput(parseAddress(params.changeAddress, "changeAddress"), selection.currencyChanges);
33474
+ txb.addOutput(tokenChangeScript.script, toSafeNumber(selection.nativeChange));
33475
+ } else if (params.changeAddress.startsWith("i")) {
33476
+ txb.addOutput(identityPaymentScript(parseIAddress(params.changeAddress, "changeAddress")), toSafeNumber(selection.nativeChange));
33413
33477
  } else {
33414
33478
  txb.addOutput(params.changeAddress, toSafeNumber(selection.nativeChange));
33415
33479
  }
33416
33480
  }
33481
+ assertTokenConservation(
33482
+ selection.selected,
33483
+ /* @__PURE__ */ new Map(),
33484
+ selection.currencyChanges,
33485
+ systemId,
33486
+ "identity registration"
33487
+ );
33417
33488
  const unsignedTx = txb.buildIncomplete();
33418
33489
  const allUtxos = [commitUtxo, ...selection.selected];
33419
33490
  const expectedImplicitFee = commitUtxo.satoshis + requiredNative - totalReferralPayments + selection.fee;
@@ -33471,7 +33542,20 @@ function _buildSubIdRegistration(params, identity, identityScript, reservationSc
33471
33542
  numOutputs,
33472
33543
  systemId,
33473
33544
  void 0,
33474
- true
33545
+ true,
33546
+ // The identity and reservation outputs embed the full serialized identity /
33547
+ // advanced name reservation (a large contentMultimap can make them
33548
+ // multi-KB); size the fee from their real bytes, matching the VRSC
33549
+ // registration / update / define paths, so a big sub-ID isn't fee-estimated
33550
+ // below the relay minimum and rejected.
33551
+ identityScript.length + reservationScript.length + feeOutput.script.length
33552
+ );
33553
+ assertTokenConservation(
33554
+ selection.selected,
33555
+ requiredCurrencies,
33556
+ selection.currencyChanges,
33557
+ systemId,
33558
+ "sub-ID registration"
33475
33559
  );
33476
33560
  const txb = new import_utxo_lib3.TransactionBuilder(network);
33477
33561
  txb.setVersion(4);
@@ -33499,13 +33583,13 @@ function _buildSubIdRegistration(params, identity, identityScript, reservationSc
33499
33583
  if (hasTokenChange || selection.nativeChange > 0n) {
33500
33584
  if (hasTokenChange) {
33501
33585
  const tokenChangeScript = buildTokenChangeOutput(
33502
- params.changeAddress,
33586
+ parseAddress(params.changeAddress, "changeAddress"),
33503
33587
  selection.currencyChanges
33504
33588
  );
33505
33589
  txb.addOutput(tokenChangeScript.script, toSafeNumber(selection.nativeChange));
33506
33590
  } else {
33507
33591
  if (params.changeAddress.startsWith("i")) {
33508
- txb.addOutput(identityPaymentScript(params.changeAddress), toSafeNumber(selection.nativeChange));
33592
+ txb.addOutput(identityPaymentScript(parseIAddress(params.changeAddress, "changeAddress")), toSafeNumber(selection.nativeChange));
33509
33593
  } else {
33510
33594
  txb.addOutput(params.changeAddress, toSafeNumber(selection.nativeChange));
33511
33595
  }
@@ -33513,6 +33597,12 @@ function _buildSubIdRegistration(params, identity, identityScript, reservationSc
33513
33597
  }
33514
33598
  const unsignedTx = txb.buildIncomplete();
33515
33599
  const allUtxos = [commitUtxo, ...selection.selected];
33600
+ assertNativeConservation(
33601
+ allUtxos,
33602
+ unsignedTx.outs,
33603
+ commitUtxo.satoshis + nativeImportFee + selection.fee,
33604
+ "sub-ID registration"
33605
+ );
33516
33606
  const { signedTx, txid } = signTransactionSmart(
33517
33607
  unsignedTx.toHex(),
33518
33608
  params.wif,
@@ -33661,6 +33751,13 @@ function buildAndSignIdentityUpdate(params, network, operation = "update", lockU
33661
33751
  // so a big update isn't fee-estimated below the relay minimum.
33662
33752
  unfundedHex.length / 2
33663
33753
  );
33754
+ assertTokenConservation(
33755
+ selection.selected,
33756
+ /* @__PURE__ */ new Map(),
33757
+ /* @__PURE__ */ new Map(),
33758
+ systemId,
33759
+ "identity update"
33760
+ );
33664
33761
  const txb = new import_utxo_lib3.TransactionBuilder(verusNetwork);
33665
33762
  txb.setVersion(4);
33666
33763
  txb.setExpiryHeight(resolveExpiryHeight(params.expiryHeight));
@@ -33679,7 +33776,7 @@ function buildAndSignIdentityUpdate(params, network, operation = "update", lockU
33679
33776
  }
33680
33777
  if (selection.nativeChange > 0n) {
33681
33778
  if (params.changeAddress.startsWith("i")) {
33682
- txb.addOutput(identityPaymentScript(params.changeAddress), toSafeNumber(selection.nativeChange));
33779
+ txb.addOutput(identityPaymentScript(parseIAddress(params.changeAddress, "changeAddress")), toSafeNumber(selection.nativeChange));
33683
33780
  } else {
33684
33781
  txb.addOutput(params.changeAddress, toSafeNumber(selection.nativeChange));
33685
33782
  }
@@ -33749,12 +33846,12 @@ function validateAmount(amount, label = "amount") {
33749
33846
  }
33750
33847
  function decodeBase58Address(address) {
33751
33848
  try {
33752
- return Buffer.from(import_bs58check3.default.decode(address));
33849
+ return Buffer.from(import_bs58check4.default.decode(address));
33753
33850
  } catch (err) {
33754
33851
  throw new InvalidAddressError(address, err.message);
33755
33852
  }
33756
33853
  }
33757
- function parseAddress(address, addressType) {
33854
+ function parseAddress2(address, addressType) {
33758
33855
  let type;
33759
33856
  let destinationBytes;
33760
33857
  switch (addressType) {
@@ -33821,7 +33918,7 @@ function sendCurrency(params, network) {
33821
33918
  const txOutputs = params.outputs.map((out) => ({
33822
33919
  currency: out.currency,
33823
33920
  satoshis: out.satoshis.toString(10),
33824
- address: parseAddress(out.address, out.addressType || "PKH"),
33921
+ address: parseAddress2(out.address, out.addressType || "PKH"),
33825
33922
  ...out.convertTo !== void 0 ? { convertto: out.convertTo } : {},
33826
33923
  ...out.exportTo !== void 0 ? { exportto: out.exportTo } : {},
33827
33924
  ...out.via !== void 0 ? { via: out.via } : {},
@@ -33885,14 +33982,14 @@ function sendCurrency(params, network) {
33885
33982
  }
33886
33983
  if (selection.currencyChanges.size > 0) {
33887
33984
  const tokenChange = buildTokenChangeOutput(
33888
- params.changeAddress,
33985
+ parseAddress(params.changeAddress, "changeAddress"),
33889
33986
  selection.currencyChanges
33890
33987
  );
33891
33988
  txb.addOutput(tokenChange.script, toSafeNumber(tokenChange.nativeValue));
33892
33989
  }
33893
33990
  if (selection.nativeChange > 0n) {
33894
33991
  if (params.changeAddress.startsWith("i")) {
33895
- txb.addOutput(identityPaymentScript(params.changeAddress), toSafeNumber(selection.nativeChange));
33992
+ txb.addOutput(identityPaymentScript(parseIAddress(params.changeAddress, "changeAddress")), toSafeNumber(selection.nativeChange));
33896
33993
  } else {
33897
33994
  txb.addOutput(params.changeAddress, toSafeNumber(selection.nativeChange));
33898
33995
  }
@@ -34041,12 +34138,26 @@ __export(message_exports, {
34041
34138
  verifyMessage: () => verifyMessage
34042
34139
  });
34043
34140
  var import_utxo_lib5 = __toESM(require_src2());
34141
+ function resolveBlockHeight(blockHeight) {
34142
+ if (blockHeight === void 0) {
34143
+ throw new TransactionBuildError(
34144
+ "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)."
34145
+ );
34146
+ }
34147
+ if (!Number.isInteger(blockHeight) || blockHeight < 0) {
34148
+ throw new TransactionBuildError(
34149
+ `Invalid blockHeight: must be a non-negative integer (got ${blockHeight})`
34150
+ );
34151
+ }
34152
+ return blockHeight;
34153
+ }
34044
34154
  function signMessage(params, network) {
34045
34155
  const verusNetwork = network === "testnet" ? import_utxo_lib5.networks.verustest : import_utxo_lib5.networks.verus;
34046
34156
  const networkConfig = NETWORK_CONFIG[network];
34047
34157
  const chainId = params.chainId || networkConfig.chainId;
34048
34158
  const version = params.version || 2;
34049
- const blockHeight = params.blockHeight || 0;
34159
+ assertAddressVersion(params.identityAddress, I_ADDR_VERSION, "identityAddress");
34160
+ const blockHeight = resolveBlockHeight(params.blockHeight);
34050
34161
  const keyPair = import_utxo_lib5.ECPair.fromWIF(params.wif, verusNetwork);
34051
34162
  const idSig = new import_utxo_lib5.IdentitySignature(
34052
34163
  verusNetwork,
@@ -34074,18 +34185,38 @@ function verifyMessage(params, network) {
34074
34185
  const verusNetwork = network === "testnet" ? import_utxo_lib5.networks.verustest : import_utxo_lib5.networks.verus;
34075
34186
  const networkConfig = NETWORK_CONFIG[network];
34076
34187
  const chainId = params.chainId || networkConfig.chainId;
34077
- const version = params.version || 2;
34078
- const blockHeight = params.blockHeight || 0;
34079
- const signatureBuffer = Buffer.from(params.signature, "base64");
34080
- const idSig = new import_utxo_lib5.IdentitySignature(
34081
- verusNetwork,
34082
- version,
34083
- HASH_SHA256,
34084
- blockHeight,
34085
- [signatureBuffer],
34086
- chainId,
34087
- params.identityAddress
34088
- );
34188
+ assertAddressVersion(params.identityAddress, I_ADDR_VERSION, "identityAddress");
34189
+ const sigBytes = Buffer.from(params.signature, "base64");
34190
+ const isDaemonFormat = sigBytes.length > 65 && (sigBytes[0] === 1 || sigBytes[0] === 2);
34191
+ let idSig;
34192
+ let blockHeight;
34193
+ let version;
34194
+ if (isDaemonFormat) {
34195
+ idSig = new import_utxo_lib5.IdentitySignature(
34196
+ verusNetwork,
34197
+ void 0,
34198
+ HASH_SHA256,
34199
+ void 0,
34200
+ void 0,
34201
+ chainId,
34202
+ params.identityAddress
34203
+ );
34204
+ idSig.fromBuffer(sigBytes, 0, chainId, params.identityAddress);
34205
+ blockHeight = idSig.blockHeight;
34206
+ version = idSig.version;
34207
+ } else {
34208
+ version = params.version || 2;
34209
+ blockHeight = resolveBlockHeight(params.blockHeight);
34210
+ idSig = new import_utxo_lib5.IdentitySignature(
34211
+ verusNetwork,
34212
+ version,
34213
+ HASH_SHA256,
34214
+ blockHeight,
34215
+ [sigBytes],
34216
+ chainId,
34217
+ params.identityAddress
34218
+ );
34219
+ }
34089
34220
  const results = idSig.verifyMessageOffline(params.message, params.signingAddress);
34090
34221
  const valid = results.length > 0 && results[0] === true;
34091
34222
  return {
@@ -34151,6 +34282,7 @@ function defineCurrency(params, network) {
34151
34282
  const currencyDefValue = params.currencyDefValue || 0n;
34152
34283
  const identity = new import_verus_typescript_primitives6.Identity();
34153
34284
  identity.fromBuffer(Buffer.from(params.identityHex, "hex"));
34285
+ assertWifIsPrimary(params.wif, identity, verusNetwork);
34154
34286
  if (!identity.hasActiveCurrency()) {
34155
34287
  const currentFlags = identity.flags.toNumber();
34156
34288
  identity.flags = new import_bn3.default(currentFlags | IDENTITY_FLAG_ACTIVECURRENCY);
@@ -34168,6 +34300,13 @@ function defineCurrency(params, network) {
34168
34300
  true,
34169
34301
  identityOutputScript.length + currencyDefScript.length
34170
34302
  );
34303
+ assertTokenConservation(
34304
+ selection.selected,
34305
+ /* @__PURE__ */ new Map(),
34306
+ /* @__PURE__ */ new Map(),
34307
+ systemId,
34308
+ "currency definition"
34309
+ );
34171
34310
  const txb = new import_utxo_lib6.TransactionBuilder(verusNetwork);
34172
34311
  txb.setVersion(4);
34173
34312
  txb.setExpiryHeight(resolveExpiryHeight(params.expiryHeight));
@@ -34184,7 +34323,7 @@ function defineCurrency(params, network) {
34184
34323
  txb.addOutput(currencyDefScript, toSafeNumber(currencyDefValue));
34185
34324
  if (selection.nativeChange > 0n) {
34186
34325
  if (params.changeAddress.startsWith("i")) {
34187
- txb.addOutput(identityPaymentScript(params.changeAddress), toSafeNumber(selection.nativeChange));
34326
+ txb.addOutput(identityPaymentScript(parseIAddress(params.changeAddress, "changeAddress")), toSafeNumber(selection.nativeChange));
34188
34327
  } else {
34189
34328
  txb.addOutput(params.changeAddress, toSafeNumber(selection.nativeChange));
34190
34329
  }
@@ -34376,20 +34515,20 @@ var VerusSDK = class {
34376
34515
  var address_exports = {};
34377
34516
  __export(address_exports, {
34378
34517
  BASE58_RE: () => BASE58_RE,
34379
- isIAddress: () => isIAddress,
34518
+ isIAddress: () => isIAddress2,
34380
34519
  isIdentityName: () => isIdentityName,
34381
- isRAddress: () => isRAddress,
34520
+ isRAddress: () => isRAddress2,
34382
34521
  isVerusAddress: () => isVerusAddress
34383
34522
  });
34384
34523
  var BASE58_RE = /^[1-9A-HJ-NP-Za-km-z]+$/;
34385
- function isRAddress(input) {
34524
+ function isRAddress2(input) {
34386
34525
  return input.startsWith("R") && input.length >= 26 && input.length <= 36 && BASE58_RE.test(input);
34387
34526
  }
34388
- function isIAddress(input) {
34527
+ function isIAddress2(input) {
34389
34528
  return input.startsWith("i") && input.length >= 26 && input.length <= 36 && BASE58_RE.test(input);
34390
34529
  }
34391
34530
  function isVerusAddress(input) {
34392
- return isRAddress(input) || isIAddress(input);
34531
+ return isRAddress2(input) || isIAddress2(input);
34393
34532
  }
34394
34533
  function isIdentityName(input) {
34395
34534
  if (!input || isVerusAddress(input)) return false;