@chainvue/verus-sdk 0.7.0 → 0.9.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/VerusSDK.d.ts +4 -1
- package/dist/VerusSDK.d.ts.map +1 -1
- package/dist/VerusSDK.js +6 -2
- package/dist/VerusSDK.js.map +1 -1
- package/dist/bundle.js +495 -273
- package/dist/core/brands.d.ts +31 -0
- package/dist/core/brands.d.ts.map +1 -0
- package/dist/core/brands.js +82 -0
- package/dist/core/brands.js.map +1 -0
- package/dist/currency/index.d.ts.map +1 -1
- package/dist/currency/index.js +6 -1
- package/dist/currency/index.js.map +1 -1
- package/dist/identity/index.d.ts +46 -28
- package/dist/identity/index.d.ts.map +1 -1
- package/dist/identity/index.js +253 -78
- package/dist/identity/index.js.map +1 -1
- package/dist/keys/index.d.ts.map +1 -1
- package/dist/keys/index.js +9 -0
- package/dist/keys/index.js.map +1 -1
- package/dist/signing/index.d.ts +12 -3
- package/dist/signing/index.d.ts.map +1 -1
- package/dist/signing/index.js +17 -4
- package/dist/signing/index.js.map +1 -1
- package/dist/transfer/index.d.ts.map +1 -1
- package/dist/transfer/index.js +9 -2
- package/dist/transfer/index.js.map +1 -1
- package/dist/types/index.d.ts +26 -1
- package/dist/types/index.d.ts.map +1 -1
- package/dist/utxo/index.d.ts +14 -0
- package/dist/utxo/index.d.ts.map +1 -1
- package/dist/utxo/index.js +49 -0
- package/dist/utxo/index.js.map +1 -1
- package/package.json +1 -1
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
|
|
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
|
|
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
|
|
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
|
|
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 =
|
|
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(
|
|
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: [
|
|
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
|
|
1185
|
+
return bscript2.compile([].concat(OP_INT_BASE + m, pubKeys, OP_INT_BASE + n, OPS.OP_CHECKMULTISIG));
|
|
1186
1186
|
}
|
|
1187
|
-
function
|
|
1188
|
-
var chunks =
|
|
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
|
|
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 ||
|
|
1213
|
+
return value === OPS.OP_0 || bscript2.isCanonicalSignature(value);
|
|
1214
1214
|
}
|
|
1215
1215
|
function check(script, allowIncomplete) {
|
|
1216
|
-
var chunks =
|
|
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(
|
|
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
|
|
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
|
|
1256
|
-
var stack =
|
|
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
|
|
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 =
|
|
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
|
|
1297
|
+
return bscript2.compile([OPS.OP_RETURN].concat(data));
|
|
1298
1298
|
}
|
|
1299
|
-
function
|
|
1299
|
+
function decode2(buffer) {
|
|
1300
1300
|
typeforce(check, buffer);
|
|
1301
|
-
var chunks =
|
|
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
|
|
1319
|
+
var bscript2 = require_script();
|
|
1320
1320
|
var typeforce = require_typeforce();
|
|
1321
1321
|
function check(script) {
|
|
1322
|
-
var chunks =
|
|
1323
|
-
return chunks.length === 1 &&
|
|
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(
|
|
1329
|
+
typeforce(bscript2.isCanonicalSignature, signature);
|
|
1330
1330
|
return [signature];
|
|
1331
1331
|
}
|
|
1332
1332
|
function encode(signature) {
|
|
1333
|
-
return
|
|
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
|
|
1340
|
-
var stack =
|
|
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
|
|
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 =
|
|
1362
|
-
return chunks.length === 2 &&
|
|
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(
|
|
1369
|
-
return
|
|
1368
|
+
typeforce(bscript2.isCanonicalPubKey, pubKey);
|
|
1369
|
+
return bscript2.compile([pubKey, OPS.OP_CHECKSIG]);
|
|
1370
1370
|
}
|
|
1371
|
-
function
|
|
1372
|
-
var chunks =
|
|
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
|
|
1399
|
+
var bscript2 = require_script();
|
|
1400
1400
|
var typeforce = require_typeforce();
|
|
1401
1401
|
function check(script) {
|
|
1402
|
-
var chunks =
|
|
1403
|
-
return chunks.length === 2 &&
|
|
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:
|
|
1411
|
-
pubKey:
|
|
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
|
|
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
|
|
1429
|
-
var stack =
|
|
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
|
|
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 =
|
|
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
|
|
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
|
|
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
|
|
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 =
|
|
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
|
|
1507
|
+
return bscript2.compile([OPS.OP_0, pubKeyHash]);
|
|
1508
1508
|
}
|
|
1509
|
-
function
|
|
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
|
|
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 =
|
|
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
|
|
1538
|
+
return bscript2.compile([OPS.OP_0, scriptHash]);
|
|
1539
1539
|
}
|
|
1540
|
-
function
|
|
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
|
|
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 =
|
|
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 =
|
|
1572
|
-
var redeemScriptChunks =
|
|
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 (!
|
|
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 =
|
|
1592
|
+
var serializedScriptPubKey = bscript2.compile(redeemScript);
|
|
1593
1593
|
return [].concat(redeemScriptStack, serializedScriptPubKey);
|
|
1594
1594
|
}
|
|
1595
1595
|
function encode(redeemScriptSig, redeemScript) {
|
|
1596
|
-
var redeemScriptStack =
|
|
1597
|
-
return
|
|
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
|
|
1607
|
-
var stack =
|
|
1606
|
+
function decode2(buffer) {
|
|
1607
|
+
var stack = bscript2.decompile(buffer);
|
|
1608
1608
|
var result = decodeStack(stack);
|
|
1609
|
-
result.redeemScriptSig =
|
|
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
|
|
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 =
|
|
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
|
|
1640
|
+
return bscript2.compile([OPS.OP_HASH160, scriptHash, OPS.OP_EQUAL]);
|
|
1641
1641
|
}
|
|
1642
|
-
function
|
|
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
|
|
1669
|
+
var bscript2 = require_script();
|
|
1670
1670
|
var typeforce = require_typeforce();
|
|
1671
1671
|
function isCompressedCanonicalPubKey(pubKey) {
|
|
1672
|
-
return
|
|
1672
|
+
return bscript2.isCanonicalPubKey(pubKey) && pubKey.length === 33;
|
|
1673
1673
|
}
|
|
1674
1674
|
function check(script) {
|
|
1675
|
-
var chunks =
|
|
1676
|
-
return chunks.length === 2 &&
|
|
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:
|
|
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
|
|
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 =
|
|
1734
|
+
var witnessScriptChunks = bscript2.decompile(witnessScript);
|
|
1735
1735
|
if (witnessScriptChunks.length === 0)
|
|
1736
1736
|
return false;
|
|
1737
|
-
var witnessRawScriptSig =
|
|
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
|
|
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 =
|
|
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
|
|
1807
|
+
return bscript2.compile([OPS.OP_RETURN, buffer]);
|
|
1808
1808
|
}
|
|
1809
|
-
function
|
|
1809
|
+
function decode2(buffer) {
|
|
1810
1810
|
typeforce(check, buffer);
|
|
1811
|
-
return
|
|
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
|
|
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
|
-
|
|
1868
|
+
decode2.bytes = 1;
|
|
1869
1869
|
return first;
|
|
1870
1870
|
} else if (first === 253) {
|
|
1871
|
-
|
|
1871
|
+
decode2.bytes = 3;
|
|
1872
1872
|
return buffer.readUInt16LE(offset + 1);
|
|
1873
1873
|
} else if (first === 254) {
|
|
1874
|
-
|
|
1874
|
+
decode2.bytes = 5;
|
|
1875
1875
|
return buffer.readUInt32LE(offset + 1);
|
|
1876
1876
|
} else {
|
|
1877
|
-
|
|
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
|
|
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 &&
|
|
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 &&
|
|
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
|
|
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 ||
|
|
2099
|
+
return value === OPS.OP_0 || bscript2.isCanonicalSignature(value);
|
|
2100
2100
|
}
|
|
2101
2101
|
function check(script) {
|
|
2102
|
-
var chunks =
|
|
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
|
|
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
|
|
2125
|
-
var stack =
|
|
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
|
|
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 =
|
|
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(
|
|
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 =
|
|
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
|
|
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 =
|
|
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: [
|
|
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
|
|
2811
|
+
return bscript2.compile([].concat(OP_INT_BASE + m, pubKeys, OP_INT_BASE + n, OPS.OP_CHECKMULTISIG));
|
|
2812
2812
|
}
|
|
2813
|
-
function
|
|
2814
|
-
var chunks =
|
|
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
|
|
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
|
|
4815
|
-
var
|
|
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 =
|
|
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
|
|
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(
|
|
4859
|
+
return toBase58Check(bscript2.compile(outputScript).slice(3, 23), network.pubKeyHash);
|
|
4860
4860
|
if (btemplates.scriptHash.output.check(outputScript))
|
|
4861
|
-
return toBase58Check(
|
|
4861
|
+
return toBase58Check(bscript2.compile(outputScript).slice(2, 22), network.scriptHash);
|
|
4862
4862
|
if (btemplates.witnessPubKeyHash.output.check(outputScript))
|
|
4863
|
-
return toBech32(
|
|
4863
|
+
return toBech32(bscript2.compile(outputScript).slice(2, 22), 0, network.bech32);
|
|
4864
4864
|
if (btemplates.witnessScriptHash.output.check(outputScript))
|
|
4865
|
-
return toBech32(
|
|
4866
|
-
throw new Error(
|
|
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
|
|
4870
|
+
var decode2;
|
|
4871
4871
|
try {
|
|
4872
|
-
|
|
4872
|
+
decode2 = fromBase58Check3(address);
|
|
4873
4873
|
} catch (e) {
|
|
4874
4874
|
}
|
|
4875
|
-
if (
|
|
4876
|
-
if (
|
|
4877
|
-
return btemplates.pubKeyHash.output.encode(
|
|
4878
|
-
if (
|
|
4879
|
-
return btemplates.scriptHash.output.encode(
|
|
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
|
-
|
|
4882
|
+
decode2 = fromBech32(address);
|
|
4883
4883
|
} catch (e) {
|
|
4884
4884
|
}
|
|
4885
|
-
if (
|
|
4886
|
-
if (
|
|
4885
|
+
if (decode2) {
|
|
4886
|
+
if (decode2.prefix !== network.bech32)
|
|
4887
4887
|
throw new Error(address + " has an invalid prefix");
|
|
4888
|
-
if (
|
|
4889
|
-
if (
|
|
4890
|
-
return btemplates.witnessPubKeyHash.output.encode(
|
|
4891
|
-
if (
|
|
4892
|
-
return btemplates.witnessScriptHash.output.encode(
|
|
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
|
|
4988
|
-
var r = BigInteger.fromDERInteger(
|
|
4989
|
-
var s = BigInteger.fromDERInteger(
|
|
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
|
|
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
|
|
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 =
|
|
10670
|
-
return x !==
|
|
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
|
|
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 !==
|
|
11047
|
-
throw new Error("expected opcode #".concat(
|
|
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
|
|
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 =
|
|
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 =
|
|
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 =
|
|
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 =
|
|
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 "' +
|
|
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 "' +
|
|
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 "' +
|
|
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:
|
|
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(
|
|
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(
|
|
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
|
|
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 =
|
|
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
|
|
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 =
|
|
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
|
|
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
|
|
15387
|
+
var bs58check5 = require("bs58check");
|
|
15388
15388
|
var fromBase58Check3 = (address) => {
|
|
15389
|
-
var payload =
|
|
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
|
|
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
|
|
19834
|
+
var TransferDestination3 = 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 =
|
|
20036
|
+
exports2.TransferDestination = TransferDestination3;
|
|
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
|
|
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
|
|
23344
|
+
var ReserveTransfer2 = 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 =
|
|
23466
|
+
exports2.ReserveTransfer = ReserveTransfer2;
|
|
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 =
|
|
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
|
|
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
|
|
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 =
|
|
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 =
|
|
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 =
|
|
24209
|
-
const buf =
|
|
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
|
|
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
|
-
|
|
32118
|
+
opcodes2.OP_CHECKCRYPTOCONDITION,
|
|
32119
32119
|
outParams.toChunk(),
|
|
32120
|
-
|
|
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: () =>
|
|
32245
|
+
isIAddress: () => isIAddress2,
|
|
32246
32246
|
isIdentityName: () => isIdentityName,
|
|
32247
|
-
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
|
|
32274
|
+
var import_bs58check4 = __toESM(require("bs58check"));
|
|
32275
32275
|
|
|
32276
32276
|
// src/constants/index.ts
|
|
32277
32277
|
var NETWORK_CONFIG = {
|
|
@@ -32296,6 +32296,7 @@ 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";
|
|
32299
32300
|
var DEFAULT_EXPIRY_DELTA = 20;
|
|
32300
32301
|
var I_ADDR_VERSION = 102;
|
|
32301
32302
|
var PUBKEY_HASH_PREFIX = 60;
|
|
@@ -32604,10 +32605,10 @@ function signTransactionMultiKey(txHex, keys, utxos, network = import_utxo_lib.n
|
|
|
32604
32605
|
txid: signedTx.getId()
|
|
32605
32606
|
};
|
|
32606
32607
|
}
|
|
32607
|
-
function createTransactionBuilder(network
|
|
32608
|
+
function createTransactionBuilder(network, expiryHeight, version = 4, versionGroupId = VERSION_GROUP_ID) {
|
|
32608
32609
|
const txb = new import_utxo_lib.TransactionBuilder(network);
|
|
32609
32610
|
txb.setVersion(version);
|
|
32610
|
-
txb.setExpiryHeight(expiryHeight);
|
|
32611
|
+
txb.setExpiryHeight(resolveExpiryHeight(expiryHeight));
|
|
32611
32612
|
txb.setVersionGroupId(versionGroupId);
|
|
32612
32613
|
return txb;
|
|
32613
32614
|
}
|
|
@@ -32632,6 +32633,7 @@ function validateFundedTransaction(systemId, fundedTxHex, unfundedTxHex, changeA
|
|
|
32632
32633
|
// src/utxo/index.ts
|
|
32633
32634
|
var utxo_exports = {};
|
|
32634
32635
|
__export(utxo_exports, {
|
|
32636
|
+
assertTokenConservation: () => assertTokenConservation,
|
|
32635
32637
|
decodeUtxo: () => decodeUtxo,
|
|
32636
32638
|
estimateFee: () => estimateFee,
|
|
32637
32639
|
selectUtxos: () => selectUtxos
|
|
@@ -32678,6 +32680,29 @@ function decodeUtxo(utxo, systemId) {
|
|
|
32678
32680
|
}
|
|
32679
32681
|
return { ...utxo, currencyValues };
|
|
32680
32682
|
}
|
|
32683
|
+
function assertTokenConservation(selected, spentToOutputs, currencyChanges, systemId, label) {
|
|
32684
|
+
const inSums = /* @__PURE__ */ new Map();
|
|
32685
|
+
for (const u of selected) {
|
|
32686
|
+
const decoded = decodeUtxo(u, systemId);
|
|
32687
|
+
for (const [currency, amount] of decoded.currencyValues) {
|
|
32688
|
+
if (currency === systemId) continue;
|
|
32689
|
+
inSums.set(currency, (inSums.get(currency) || 0n) + amount);
|
|
32690
|
+
}
|
|
32691
|
+
}
|
|
32692
|
+
const currencies = /* @__PURE__ */ new Set();
|
|
32693
|
+
for (const c of inSums.keys()) currencies.add(c);
|
|
32694
|
+
for (const c of spentToOutputs.keys()) if (c !== systemId) currencies.add(c);
|
|
32695
|
+
for (const c of currencyChanges.keys()) if (c !== systemId) currencies.add(c);
|
|
32696
|
+
for (const currency of currencies) {
|
|
32697
|
+
const totalIn = inSums.get(currency) || 0n;
|
|
32698
|
+
const totalOut = (spentToOutputs.get(currency) || 0n) + (currencyChanges.get(currency) || 0n);
|
|
32699
|
+
if (totalIn !== totalOut) {
|
|
32700
|
+
throw new TransactionBuildError(
|
|
32701
|
+
`${label} token conservation failed for ${currency}: selected inputs ${totalIn} != fee+change ${totalOut}`
|
|
32702
|
+
);
|
|
32703
|
+
}
|
|
32704
|
+
}
|
|
32705
|
+
}
|
|
32681
32706
|
function estimateFee(numInputs, numOutputs, feePerKb = DEFAULT_FEE_PER_KB, hasSmartOutputs = false, extraBytes = 0) {
|
|
32682
32707
|
const outputSize = hasSmartOutputs ? SMART_OUTPUT_SIZE : P2PKH_OUTPUT_SIZE;
|
|
32683
32708
|
const txSize = TX_OVERHEAD + numInputs * INPUT_SIZE + numOutputs * outputSize + extraBytes;
|
|
@@ -32693,6 +32718,11 @@ function selectUtxos(utxos, requiredNative, requiredCurrencies = /* @__PURE__ */
|
|
|
32693
32718
|
}
|
|
32694
32719
|
seenOutpoints.add(outpoint);
|
|
32695
32720
|
}
|
|
32721
|
+
if (requiredCurrencies.has(systemId)) {
|
|
32722
|
+
throw new TransactionBuildError(
|
|
32723
|
+
`requiredCurrencies must not contain the native currency (systemId ${systemId}); pass the native amount as requiredNative instead.`
|
|
32724
|
+
);
|
|
32725
|
+
}
|
|
32696
32726
|
const decoded = utxos.map((u) => decodeUtxo(u, systemId));
|
|
32697
32727
|
const remaining = new Map(requiredCurrencies);
|
|
32698
32728
|
let remainingNative = requiredNative;
|
|
@@ -32838,6 +32868,55 @@ var import_verus_typescript_primitives3 = __toESM(require_dist2());
|
|
|
32838
32868
|
var import_verus_typescript_primitives4 = __toESM(require_dist2());
|
|
32839
32869
|
var import_utxo_lib3 = __toESM(require_src2());
|
|
32840
32870
|
|
|
32871
|
+
// src/core/brands.ts
|
|
32872
|
+
var import_bs58check2 = __toESM(require("bs58check"));
|
|
32873
|
+
var P2SH_VERSION = 85;
|
|
32874
|
+
function decode(s, label) {
|
|
32875
|
+
let decoded;
|
|
32876
|
+
try {
|
|
32877
|
+
decoded = import_bs58check2.default.decode(s);
|
|
32878
|
+
} catch (err) {
|
|
32879
|
+
throw new InvalidAddressError(String(s), `${label} is not valid base58check: ${err.message}`);
|
|
32880
|
+
}
|
|
32881
|
+
if (decoded.length !== 21) {
|
|
32882
|
+
throw new InvalidAddressError(String(s), `${label} must decode to a 1-byte version + 20-byte hash, got ${decoded.length} bytes`);
|
|
32883
|
+
}
|
|
32884
|
+
return { version: decoded[0] };
|
|
32885
|
+
}
|
|
32886
|
+
function parseRAddress(s, label = "address") {
|
|
32887
|
+
const { version } = decode(s, label);
|
|
32888
|
+
if (version !== PUBKEY_HASH_PREFIX) {
|
|
32889
|
+
throw new InvalidAddressError(s, `${label} must be an R-address (version ${PUBKEY_HASH_PREFIX}), got version ${version}`);
|
|
32890
|
+
}
|
|
32891
|
+
return s;
|
|
32892
|
+
}
|
|
32893
|
+
function parseIAddress(s, label = "address") {
|
|
32894
|
+
const { version } = decode(s, label);
|
|
32895
|
+
if (version !== I_ADDR_VERSION) {
|
|
32896
|
+
throw new InvalidAddressError(s, `${label} must be an identity i-address (version ${I_ADDR_VERSION}), got version ${version}`);
|
|
32897
|
+
}
|
|
32898
|
+
return s;
|
|
32899
|
+
}
|
|
32900
|
+
function parseAddress(s, label = "address") {
|
|
32901
|
+
const { version } = decode(s, label);
|
|
32902
|
+
switch (version) {
|
|
32903
|
+
case PUBKEY_HASH_PREFIX:
|
|
32904
|
+
return s;
|
|
32905
|
+
case I_ADDR_VERSION:
|
|
32906
|
+
return s;
|
|
32907
|
+
case P2SH_VERSION:
|
|
32908
|
+
return s;
|
|
32909
|
+
default:
|
|
32910
|
+
throw new InvalidAddressError(s, `${label} has unsupported version byte ${version}`);
|
|
32911
|
+
}
|
|
32912
|
+
}
|
|
32913
|
+
function isIAddress(a) {
|
|
32914
|
+
return decode(a, "address").version === I_ADDR_VERSION;
|
|
32915
|
+
}
|
|
32916
|
+
function isRAddress(a) {
|
|
32917
|
+
return decode(a, "address").version === PUBKEY_HASH_PREFIX;
|
|
32918
|
+
}
|
|
32919
|
+
|
|
32841
32920
|
// src/keys/index.ts
|
|
32842
32921
|
var keys_exports = {};
|
|
32843
32922
|
__export(keys_exports, {
|
|
@@ -32852,11 +32931,11 @@ __export(keys_exports, {
|
|
|
32852
32931
|
wifToPrivateKey: () => wifToPrivateKey
|
|
32853
32932
|
});
|
|
32854
32933
|
var crypto = __toESM(require("crypto"));
|
|
32855
|
-
var
|
|
32934
|
+
var import_bs58check3 = __toESM(require("bs58check"));
|
|
32856
32935
|
var import_create_hash = __toESM(require("create-hash"));
|
|
32857
32936
|
function validateWif(wif) {
|
|
32858
32937
|
try {
|
|
32859
|
-
const decoded =
|
|
32938
|
+
const decoded = import_bs58check3.default.decode(wif);
|
|
32860
32939
|
if (decoded.length !== 33 && decoded.length !== 34) {
|
|
32861
32940
|
return { valid: false, error: "Invalid WIF length" };
|
|
32862
32941
|
}
|
|
@@ -32873,7 +32952,9 @@ function validateWif(wif) {
|
|
|
32873
32952
|
}
|
|
32874
32953
|
}
|
|
32875
32954
|
function wifToPrivateKey(wif) {
|
|
32876
|
-
const
|
|
32955
|
+
const check = validateWif(wif);
|
|
32956
|
+
if (!check.valid) throw new InvalidWifError(check.error);
|
|
32957
|
+
const decoded = import_bs58check3.default.decode(wif);
|
|
32877
32958
|
if (decoded.length === 34) {
|
|
32878
32959
|
return Buffer.from(decoded.slice(1, 33));
|
|
32879
32960
|
} else {
|
|
@@ -32881,7 +32962,9 @@ function wifToPrivateKey(wif) {
|
|
|
32881
32962
|
}
|
|
32882
32963
|
}
|
|
32883
32964
|
function isCompressedWif(wif) {
|
|
32884
|
-
const
|
|
32965
|
+
const check = validateWif(wif);
|
|
32966
|
+
if (!check.valid) throw new InvalidWifError(check.error);
|
|
32967
|
+
const decoded = import_bs58check3.default.decode(wif);
|
|
32885
32968
|
return decoded.length === 34 && decoded[33] === 1;
|
|
32886
32969
|
}
|
|
32887
32970
|
async function privateKeyToPublicKey(privateKey, compressed = true) {
|
|
@@ -32902,7 +32985,7 @@ function hash160(data) {
|
|
|
32902
32985
|
function publicKeyToAddress(publicKey) {
|
|
32903
32986
|
const hash = hash160(publicKey);
|
|
32904
32987
|
const payload = Buffer.concat([Buffer.from([PUBKEY_HASH_PREFIX]), hash]);
|
|
32905
|
-
return
|
|
32988
|
+
return import_bs58check3.default.encode(payload);
|
|
32906
32989
|
}
|
|
32907
32990
|
async function wifToAddress(wif) {
|
|
32908
32991
|
const validation = validateWif(wif);
|
|
@@ -32917,11 +33000,11 @@ async function wifToAddress(wif) {
|
|
|
32917
33000
|
function generateWif(compressed = true) {
|
|
32918
33001
|
const privateKey = crypto.randomBytes(32);
|
|
32919
33002
|
const payload = compressed ? Buffer.concat([Buffer.from([WIF_PREFIX]), privateKey, Buffer.from([1])]) : Buffer.concat([Buffer.from([WIF_PREFIX]), privateKey]);
|
|
32920
|
-
return
|
|
33003
|
+
return import_bs58check3.default.encode(payload);
|
|
32921
33004
|
}
|
|
32922
33005
|
function validateAddress(address) {
|
|
32923
33006
|
try {
|
|
32924
|
-
const decoded =
|
|
33007
|
+
const decoded = import_bs58check3.default.decode(address);
|
|
32925
33008
|
if (decoded.length !== 21) {
|
|
32926
33009
|
return { valid: false, error: "Invalid address length" };
|
|
32927
33010
|
}
|
|
@@ -32941,6 +33024,8 @@ var HASH160_BYTE_LENGTH = 20;
|
|
|
32941
33024
|
var HASH256_BYTE_LENGTH = 32;
|
|
32942
33025
|
var NULL_ID_HASH = Buffer.alloc(HASH160_BYTE_LENGTH, 0);
|
|
32943
33026
|
var EVAL_IDENTITY_ADVANCEDRESERVATION = 10;
|
|
33027
|
+
var MAX_UNLOCK_DELAY = 11563200;
|
|
33028
|
+
var LOCK_DELAY_SANITY_BLOCKS = 525600;
|
|
32944
33029
|
function assertAddressVersion(address, expectedVersion, label) {
|
|
32945
33030
|
let version;
|
|
32946
33031
|
try {
|
|
@@ -33056,6 +33141,9 @@ function buildIdentityScript(identity) {
|
|
|
33056
33141
|
return identityScript.toBuffer();
|
|
33057
33142
|
}
|
|
33058
33143
|
function deriveIdentityAddress(name, parentIAddress) {
|
|
33144
|
+
if (parentIAddress) {
|
|
33145
|
+
assertAddressVersion(parentIAddress, I_ADDR_VERSION, "parent");
|
|
33146
|
+
}
|
|
33059
33147
|
return (0, import_verus_typescript_primitives4.nameAndParentAddrToIAddr)(name, parentIAddress || void 0);
|
|
33060
33148
|
}
|
|
33061
33149
|
function isVRSCParent(parentIAddress, network = "mainnet") {
|
|
@@ -33063,11 +33151,15 @@ function isVRSCParent(parentIAddress, network = "mainnet") {
|
|
|
33063
33151
|
const systemId = NETWORK_CONFIG[network].chainId;
|
|
33064
33152
|
return parentIAddress === systemId;
|
|
33065
33153
|
}
|
|
33066
|
-
function prepareNameCommitment(name, controlAddress, referralIAddress, parentIAddress, network = "mainnet") {
|
|
33067
|
-
const salt = generateSalt();
|
|
33154
|
+
function prepareNameCommitment(name, controlAddress, referralIAddress, parentIAddress, network = "mainnet", salt = generateSalt()) {
|
|
33068
33155
|
const systemId = NETWORK_CONFIG[network].chainId;
|
|
33069
33156
|
if (referralIAddress) {
|
|
33070
33157
|
assertAddressVersion(referralIAddress, I_ADDR_VERSION, "referral");
|
|
33158
|
+
if (!isVRSCParent(parentIAddress, network)) {
|
|
33159
|
+
throw new TransactionBuildError(
|
|
33160
|
+
"referrals are not supported for sub-ID (non-VRSC-parent) registrations in this SDK; omit the referral for a sub-ID name commitment."
|
|
33161
|
+
);
|
|
33162
|
+
}
|
|
33071
33163
|
}
|
|
33072
33164
|
const referralHash = referralIAddress ? iAddressToHash(referralIAddress) : NULL_ID_HASH;
|
|
33073
33165
|
const effectiveParent = parentIAddress && parentIAddress !== systemId ? parentIAddress : void 0;
|
|
@@ -33087,7 +33179,7 @@ function prepareNameCommitment(name, controlAddress, referralIAddress, parentIAd
|
|
|
33087
33179
|
}
|
|
33088
33180
|
const commitmentHash = calculateCommitmentHash(serializedReservation);
|
|
33089
33181
|
const serializedCommitmentHash = serializeCommitmentHash(commitmentHash);
|
|
33090
|
-
const commitmentScript = buildCommitmentScript(commitmentHash, controlAddress);
|
|
33182
|
+
const commitmentScript = buildCommitmentScript(commitmentHash, parseRAddress(controlAddress, "controlAddress"));
|
|
33091
33183
|
return {
|
|
33092
33184
|
salt,
|
|
33093
33185
|
serializedReservation,
|
|
@@ -33098,15 +33190,7 @@ function prepareNameCommitment(name, controlAddress, referralIAddress, parentIAd
|
|
|
33098
33190
|
};
|
|
33099
33191
|
}
|
|
33100
33192
|
function buildP2IDScript(iAddress) {
|
|
33101
|
-
|
|
33102
|
-
return import_utxo_lib3.script.compile([
|
|
33103
|
-
import_utxo_lib3.opcodes.OP_DUP,
|
|
33104
|
-
import_utxo_lib3.opcodes.OP_HASH160,
|
|
33105
|
-
idHash,
|
|
33106
|
-
import_utxo_lib3.opcodes.OP_EQUALVERIFY,
|
|
33107
|
-
import_utxo_lib3.opcodes.OP_CHECKSIG,
|
|
33108
|
-
import_utxo_lib3.opcodes.OP_CHECKCRYPTOCONDITION
|
|
33109
|
-
]);
|
|
33193
|
+
return identityPaymentScript(parseIAddress(iAddress, "iAddress"));
|
|
33110
33194
|
}
|
|
33111
33195
|
function identityPaymentScript(iAddress) {
|
|
33112
33196
|
return buildReferralPaymentScript(iAddress);
|
|
@@ -33142,11 +33226,6 @@ function calculateRegistrationFees(hasReferral, totalFee = DEFAULT_REGISTRATION_
|
|
|
33142
33226
|
return { issuerFee, referralAmount, totalRequired };
|
|
33143
33227
|
}
|
|
33144
33228
|
function createIdentityObject(params) {
|
|
33145
|
-
params.primaryAddresses.forEach(
|
|
33146
|
-
(addr, i) => assertAddressVersion(addr, PUBKEY_HASH_PREFIX, `primaryAddresses[${i}]`)
|
|
33147
|
-
);
|
|
33148
|
-
assertAddressVersion(params.revocationAuthority, I_ADDR_VERSION, "revocationAuthority");
|
|
33149
|
-
assertAddressVersion(params.recoveryAuthority, I_ADDR_VERSION, "recoveryAuthority");
|
|
33150
33229
|
validateMinSigs(params.minSigs ?? 1, params.primaryAddresses.length);
|
|
33151
33230
|
const primaryKeys = params.primaryAddresses.map((addr) => import_verus_typescript_primitives2.KeyID.fromAddress(addr));
|
|
33152
33231
|
const identity = new import_verus_typescript_primitives2.Identity({
|
|
@@ -33164,20 +33243,58 @@ function createIdentityObject(params) {
|
|
|
33164
33243
|
});
|
|
33165
33244
|
return identity;
|
|
33166
33245
|
}
|
|
33167
|
-
function buildRegistrationFeeOutput(parentCurrencyId, feeAmount, systemId, _controlAddress) {
|
|
33168
|
-
|
|
33169
|
-
|
|
33246
|
+
function buildRegistrationFeeOutput(parentCurrencyId, feeAmount, systemId, _controlAddress, parentProofProtocol = 2) {
|
|
33247
|
+
if (parentProofProtocol === 2) {
|
|
33248
|
+
return buildTokenChangeOutput(parseIAddress(parentCurrencyId, "parentCurrencyId"), /* @__PURE__ */ new Map([[parentCurrencyId, feeAmount]]));
|
|
33249
|
+
}
|
|
33250
|
+
return buildRegistrationFeeReserveTransfer(parentCurrencyId, feeAmount, systemId);
|
|
33251
|
+
}
|
|
33252
|
+
function buildRegistrationFeeReserveTransfer(parentCurrencyId, feeAmount, systemId) {
|
|
33253
|
+
const destination = new import_verus_typescript_primitives2.TxDestination(import_verus_typescript_primitives2.KeyID.fromAddress(RESERVE_TRANSFER_EVAL_PKH));
|
|
33254
|
+
const values = new import_verus_typescript_primitives2.CurrencyValueMap({
|
|
33255
|
+
value_map: /* @__PURE__ */ new Map([[parentCurrencyId, new import_bn.default(feeAmount.toString(10))]]),
|
|
33256
|
+
multivalue: false
|
|
33257
|
+
});
|
|
33258
|
+
const parentHash = (0, import_verus_typescript_primitives4.fromBase58Check)(parentCurrencyId).hash;
|
|
33259
|
+
const transferDest = new import_verus_typescript_primitives2.TransferDestination({ type: import_verus_typescript_primitives2.DEST_ID, destination_bytes: Buffer.from(parentHash) });
|
|
33260
|
+
const flags = import_verus_typescript_primitives2.RESERVE_TRANSFER_VALID.or(import_verus_typescript_primitives2.RESERVE_TRANSFER_BURN_CHANGE_PRICE);
|
|
33261
|
+
const resTransfer = new import_verus_typescript_primitives2.ReserveTransfer({
|
|
33262
|
+
values,
|
|
33263
|
+
version: new import_bn.default(1),
|
|
33264
|
+
flags,
|
|
33265
|
+
fee_currency_id: systemId,
|
|
33266
|
+
fee_amount: new import_bn.default(RESERVE_TRANSFER_FEE.toString(10)),
|
|
33267
|
+
transfer_destination: transferDest,
|
|
33268
|
+
dest_currency_id: parentCurrencyId
|
|
33269
|
+
});
|
|
33270
|
+
const master = new import_verus_typescript_primitives2.OptCCParams({
|
|
33271
|
+
version: new import_bn.default(3),
|
|
33272
|
+
eval_code: new import_bn.default(import_verus_typescript_primitives3.EVALS.EVAL_NONE),
|
|
33273
|
+
m: new import_bn.default(1),
|
|
33274
|
+
n: new import_bn.default(1),
|
|
33275
|
+
destinations: [destination],
|
|
33276
|
+
vdata: []
|
|
33277
|
+
});
|
|
33278
|
+
const params = new import_verus_typescript_primitives2.OptCCParams({
|
|
33279
|
+
version: new import_bn.default(3),
|
|
33280
|
+
eval_code: new import_bn.default(import_verus_typescript_primitives3.EVALS.EVAL_RESERVE_TRANSFER),
|
|
33281
|
+
m: new import_bn.default(1),
|
|
33282
|
+
n: new import_bn.default(1),
|
|
33283
|
+
destinations: [destination],
|
|
33284
|
+
vdata: [resTransfer.toBuffer()]
|
|
33285
|
+
});
|
|
33286
|
+
const script = new import_verus_typescript_primitives2.SmartTransactionScript(master, params);
|
|
33287
|
+
return { script: script.toBuffer(), nativeValue: RESERVE_TRANSFER_FEE };
|
|
33170
33288
|
}
|
|
33171
33289
|
function buildTokenChangeOutput(changeAddress, currencyChanges) {
|
|
33172
|
-
const version = (0, import_verus_typescript_primitives4.fromBase58Check)(changeAddress).version;
|
|
33173
33290
|
let destination;
|
|
33174
|
-
if (
|
|
33291
|
+
if (isIAddress(changeAddress)) {
|
|
33175
33292
|
destination = new import_verus_typescript_primitives2.TxDestination(import_verus_typescript_primitives2.IdentityID.fromAddress(changeAddress));
|
|
33176
|
-
} else if (
|
|
33293
|
+
} else if (isRAddress(changeAddress)) {
|
|
33177
33294
|
destination = new import_verus_typescript_primitives2.TxDestination(import_verus_typescript_primitives2.KeyID.fromAddress(changeAddress));
|
|
33178
33295
|
} else {
|
|
33179
33296
|
throw new TransactionBuildError(
|
|
33180
|
-
`token change address must be an R-address or identity i-address, got
|
|
33297
|
+
`token change address must be an R-address or identity i-address, got: ${changeAddress}`
|
|
33181
33298
|
);
|
|
33182
33299
|
}
|
|
33183
33300
|
const valueMap = /* @__PURE__ */ new Map();
|
|
@@ -33242,7 +33359,8 @@ function buildAndSignCommitment(params, network) {
|
|
|
33242
33359
|
controlAddress,
|
|
33243
33360
|
params.referral,
|
|
33244
33361
|
params.parent,
|
|
33245
|
-
network
|
|
33362
|
+
network,
|
|
33363
|
+
params.salt
|
|
33246
33364
|
);
|
|
33247
33365
|
const utxos = params.utxos;
|
|
33248
33366
|
const selection = selectUtxos(
|
|
@@ -33267,14 +33385,26 @@ function buildAndSignCommitment(params, network) {
|
|
|
33267
33385
|
);
|
|
33268
33386
|
}
|
|
33269
33387
|
txb.addOutput(commitment.commitmentScript, 0);
|
|
33270
|
-
|
|
33271
|
-
|
|
33272
|
-
|
|
33388
|
+
const hasTokenChange = selection.currencyChanges.size > 0;
|
|
33389
|
+
if (hasTokenChange || selection.nativeChange > 0n) {
|
|
33390
|
+
if (hasTokenChange) {
|
|
33391
|
+
const tokenChangeScript = buildTokenChangeOutput(parseAddress(params.changeAddress, "changeAddress"), selection.currencyChanges);
|
|
33392
|
+
txb.addOutput(tokenChangeScript.script, toSafeNumber(selection.nativeChange));
|
|
33393
|
+
} else if (params.changeAddress.startsWith("i")) {
|
|
33394
|
+
txb.addOutput(identityPaymentScript(parseIAddress(params.changeAddress, "changeAddress")), toSafeNumber(selection.nativeChange));
|
|
33273
33395
|
} else {
|
|
33274
33396
|
txb.addOutput(params.changeAddress, toSafeNumber(selection.nativeChange));
|
|
33275
33397
|
}
|
|
33276
33398
|
}
|
|
33399
|
+
assertTokenConservation(
|
|
33400
|
+
selection.selected,
|
|
33401
|
+
/* @__PURE__ */ new Map(),
|
|
33402
|
+
selection.currencyChanges,
|
|
33403
|
+
networkConfig.chainId,
|
|
33404
|
+
"name commitment"
|
|
33405
|
+
);
|
|
33277
33406
|
const unsignedTx = txb.buildIncomplete();
|
|
33407
|
+
assertNativeConservation(selection.selected, unsignedTx.outs, selection.fee, "name commitment");
|
|
33278
33408
|
const { signedTx, txid } = signTransactionSmart(
|
|
33279
33409
|
unsignedTx.toHex(),
|
|
33280
33410
|
params.wif,
|
|
@@ -33307,6 +33437,13 @@ function buildAndSignRegistration(params, network) {
|
|
|
33307
33437
|
const verusNetwork = getNetwork(network === "testnet");
|
|
33308
33438
|
const networkConfig = NETWORK_CONFIG[network];
|
|
33309
33439
|
const systemId = networkConfig.chainId;
|
|
33440
|
+
const signerAddr = import_utxo_lib3.ECPair.fromWIF(params.wif, verusNetwork).getAddress();
|
|
33441
|
+
const signerHash = addressToScriptPubKey(signerAddr).subarray(3, 23).toString("hex");
|
|
33442
|
+
if (!params.commitmentUtxo.script.toLowerCase().includes(signerHash)) {
|
|
33443
|
+
throw new TransactionBuildError(
|
|
33444
|
+
`the provided WIF (${signerAddr}) does not control the name-commitment output; step 2 must be signed by the same key that created the commitment in step 1.`
|
|
33445
|
+
);
|
|
33446
|
+
}
|
|
33310
33447
|
const commitData = params.commitmentData;
|
|
33311
33448
|
const parentIAddress = commitData.parent || systemId;
|
|
33312
33449
|
const isSubId = !isVRSCParent(commitData.parent || void 0, network);
|
|
@@ -33314,16 +33451,16 @@ function buildAndSignRegistration(params, network) {
|
|
|
33314
33451
|
const identityAddress = deriveIdentityAddress(commitData.name, effectiveParent);
|
|
33315
33452
|
const identity = createIdentityObject({
|
|
33316
33453
|
name: commitData.name,
|
|
33317
|
-
primaryAddresses: params.primaryAddresses,
|
|
33454
|
+
primaryAddresses: params.primaryAddresses.map((a, i) => parseRAddress(a, `primaryAddresses[${i}]`)),
|
|
33318
33455
|
...params.minSigs !== void 0 ? { minSigs: params.minSigs } : {},
|
|
33319
|
-
revocationAuthority: params.revocationAuthority || identityAddress,
|
|
33320
|
-
recoveryAuthority: params.recoveryAuthority || identityAddress,
|
|
33321
|
-
parentIAddress,
|
|
33322
|
-
systemId
|
|
33456
|
+
revocationAuthority: parseIAddress(params.revocationAuthority || identityAddress, "revocationAuthority"),
|
|
33457
|
+
recoveryAuthority: parseIAddress(params.recoveryAuthority || identityAddress, "recoveryAuthority"),
|
|
33458
|
+
parentIAddress: parseIAddress(parentIAddress, "parentIAddress"),
|
|
33459
|
+
systemId: parseIAddress(systemId, "systemId")
|
|
33323
33460
|
});
|
|
33324
33461
|
const identityScript = buildIdentityScript(identity);
|
|
33325
33462
|
const reservationScript = buildReservationScript(
|
|
33326
|
-
identityAddress,
|
|
33463
|
+
parseIAddress(identityAddress, "identityAddress"),
|
|
33327
33464
|
Buffer.from(commitData.namereservationHex, "hex"),
|
|
33328
33465
|
isSubId
|
|
33329
33466
|
);
|
|
@@ -33352,7 +33489,7 @@ function _buildVrscRegistration(params, identityScript, reservationScript, ident
|
|
|
33352
33489
|
}
|
|
33353
33490
|
for (const referrerAddr of chain) {
|
|
33354
33491
|
referralOutputs.push({
|
|
33355
|
-
script: buildReferralPaymentScript(referrerAddr),
|
|
33492
|
+
script: buildReferralPaymentScript(parseIAddress(referrerAddr, "referralChain entry")),
|
|
33356
33493
|
value: fees.referralAmount
|
|
33357
33494
|
});
|
|
33358
33495
|
}
|
|
@@ -33394,13 +33531,24 @@ function _buildVrscRegistration(params, identityScript, reservationScript, ident
|
|
|
33394
33531
|
txb.addOutput(referralOut.script, toSafeNumber(referralOut.value));
|
|
33395
33532
|
}
|
|
33396
33533
|
txb.addOutput(reservationScript, 0);
|
|
33397
|
-
|
|
33398
|
-
|
|
33399
|
-
|
|
33534
|
+
const hasTokenChange = selection.currencyChanges.size > 0;
|
|
33535
|
+
if (hasTokenChange || selection.nativeChange > 0n) {
|
|
33536
|
+
if (hasTokenChange) {
|
|
33537
|
+
const tokenChangeScript = buildTokenChangeOutput(parseAddress(params.changeAddress, "changeAddress"), selection.currencyChanges);
|
|
33538
|
+
txb.addOutput(tokenChangeScript.script, toSafeNumber(selection.nativeChange));
|
|
33539
|
+
} else if (params.changeAddress.startsWith("i")) {
|
|
33540
|
+
txb.addOutput(identityPaymentScript(parseIAddress(params.changeAddress, "changeAddress")), toSafeNumber(selection.nativeChange));
|
|
33400
33541
|
} else {
|
|
33401
33542
|
txb.addOutput(params.changeAddress, toSafeNumber(selection.nativeChange));
|
|
33402
33543
|
}
|
|
33403
33544
|
}
|
|
33545
|
+
assertTokenConservation(
|
|
33546
|
+
selection.selected,
|
|
33547
|
+
/* @__PURE__ */ new Map(),
|
|
33548
|
+
selection.currencyChanges,
|
|
33549
|
+
systemId,
|
|
33550
|
+
"identity registration"
|
|
33551
|
+
);
|
|
33404
33552
|
const unsignedTx = txb.buildIncomplete();
|
|
33405
33553
|
const allUtxos = [commitUtxo, ...selection.selected];
|
|
33406
33554
|
const expectedImplicitFee = commitUtxo.satoshis + requiredNative - totalReferralPayments + selection.fee;
|
|
@@ -33439,16 +33587,27 @@ function _buildSubIdRegistration(params, identity, identityScript, reservationSc
|
|
|
33439
33587
|
"registrationFeeAmount is required for sub-ID registration. Specify the fee in parent currency satoshis."
|
|
33440
33588
|
);
|
|
33441
33589
|
}
|
|
33590
|
+
if (params.parentProofProtocol === void 0) {
|
|
33591
|
+
throw new TransactionBuildError(
|
|
33592
|
+
"parentProofProtocol is required for sub-ID registration: pass the parent currency's proofprotocol (from `getcurrency <parent>`) \u2014 2 for a centralized/token currency, 1 for a PBaaS/fractional one."
|
|
33593
|
+
);
|
|
33594
|
+
}
|
|
33442
33595
|
const feeOutput = buildRegistrationFeeOutput(
|
|
33443
33596
|
parentIAddress,
|
|
33444
33597
|
registrationFeeAmount,
|
|
33445
33598
|
systemId,
|
|
33446
|
-
params.changeAddress
|
|
33599
|
+
params.changeAddress,
|
|
33600
|
+
params.parentProofProtocol
|
|
33447
33601
|
);
|
|
33448
33602
|
const requiredCurrencies = /* @__PURE__ */ new Map([
|
|
33449
33603
|
[parentIAddress, registrationFeeAmount]
|
|
33450
33604
|
]);
|
|
33451
|
-
|
|
33605
|
+
if (params.nativeImportFee === void 0) {
|
|
33606
|
+
throw new TransactionBuildError(
|
|
33607
|
+
"nativeImportFee is required for sub-ID registration: pass the parent currency's idimportfees (from `getcurrency <parent>`), or 0n if it charges none."
|
|
33608
|
+
);
|
|
33609
|
+
}
|
|
33610
|
+
const nativeImportFee = params.nativeImportFee;
|
|
33452
33611
|
const nativeTarget = feeOutput.nativeValue + nativeImportFee;
|
|
33453
33612
|
const numOutputs = 4;
|
|
33454
33613
|
const selection = selectUtxos(
|
|
@@ -33458,7 +33617,20 @@ function _buildSubIdRegistration(params, identity, identityScript, reservationSc
|
|
|
33458
33617
|
numOutputs,
|
|
33459
33618
|
systemId,
|
|
33460
33619
|
void 0,
|
|
33461
|
-
true
|
|
33620
|
+
true,
|
|
33621
|
+
// The identity and reservation outputs embed the full serialized identity /
|
|
33622
|
+
// advanced name reservation (a large contentMultimap can make them
|
|
33623
|
+
// multi-KB); size the fee from their real bytes, matching the VRSC
|
|
33624
|
+
// registration / update / define paths, so a big sub-ID isn't fee-estimated
|
|
33625
|
+
// below the relay minimum and rejected.
|
|
33626
|
+
identityScript.length + reservationScript.length + feeOutput.script.length
|
|
33627
|
+
);
|
|
33628
|
+
assertTokenConservation(
|
|
33629
|
+
selection.selected,
|
|
33630
|
+
requiredCurrencies,
|
|
33631
|
+
selection.currencyChanges,
|
|
33632
|
+
systemId,
|
|
33633
|
+
"sub-ID registration"
|
|
33462
33634
|
);
|
|
33463
33635
|
const txb = new import_utxo_lib3.TransactionBuilder(network);
|
|
33464
33636
|
txb.setVersion(4);
|
|
@@ -33486,13 +33658,13 @@ function _buildSubIdRegistration(params, identity, identityScript, reservationSc
|
|
|
33486
33658
|
if (hasTokenChange || selection.nativeChange > 0n) {
|
|
33487
33659
|
if (hasTokenChange) {
|
|
33488
33660
|
const tokenChangeScript = buildTokenChangeOutput(
|
|
33489
|
-
params.changeAddress,
|
|
33661
|
+
parseAddress(params.changeAddress, "changeAddress"),
|
|
33490
33662
|
selection.currencyChanges
|
|
33491
33663
|
);
|
|
33492
33664
|
txb.addOutput(tokenChangeScript.script, toSafeNumber(selection.nativeChange));
|
|
33493
33665
|
} else {
|
|
33494
33666
|
if (params.changeAddress.startsWith("i")) {
|
|
33495
|
-
txb.addOutput(identityPaymentScript(params.changeAddress), toSafeNumber(selection.nativeChange));
|
|
33667
|
+
txb.addOutput(identityPaymentScript(parseIAddress(params.changeAddress, "changeAddress")), toSafeNumber(selection.nativeChange));
|
|
33496
33668
|
} else {
|
|
33497
33669
|
txb.addOutput(params.changeAddress, toSafeNumber(selection.nativeChange));
|
|
33498
33670
|
}
|
|
@@ -33551,6 +33723,12 @@ function buildAndSignIdentityUpdate(params, network, operation = "update", lockU
|
|
|
33551
33723
|
`the provided WIF (${signerAddress}) is not among the identity's primary addresses [${currentPrimaries.join(", ")}]; it cannot authorize a ${operation}.`
|
|
33552
33724
|
);
|
|
33553
33725
|
}
|
|
33726
|
+
const currentMinSigs = identity.min_sigs?.toNumber?.() ?? 1;
|
|
33727
|
+
if (currentMinSigs > 1) {
|
|
33728
|
+
throw new TransactionBuildError(
|
|
33729
|
+
`this identity requires ${currentMinSigs} signatures (min_sigs > 1); the SDK signs with a single WIF and the bundled fork cannot multi-sign a CryptoCondition input, so a valid ${operation} transaction cannot be produced. Use the daemon for multisig identities.`
|
|
33730
|
+
);
|
|
33731
|
+
}
|
|
33554
33732
|
}
|
|
33555
33733
|
switch (operation) {
|
|
33556
33734
|
case "update": {
|
|
@@ -33569,10 +33747,12 @@ function buildAndSignIdentityUpdate(params, network, operation = "update", lockU
|
|
|
33569
33747
|
identity.setRecovery(params.recoveryAuthority);
|
|
33570
33748
|
}
|
|
33571
33749
|
if (params.contentMap) {
|
|
33750
|
+
identity.content_map.clear();
|
|
33572
33751
|
for (const [key, value] of Object.entries(params.contentMap)) {
|
|
33573
|
-
|
|
33752
|
+
assertAddressVersion(key, I_ADDR_VERSION, `contentMap key "${key}"`);
|
|
33753
|
+
if (!/^[0-9a-fA-F]{64}$/.test(value)) {
|
|
33574
33754
|
throw new TransactionBuildError(
|
|
33575
|
-
`contentMap["${key}"] must be
|
|
33755
|
+
`contentMap["${key}"] must be a 32-byte (64-hex-char) value (got ${JSON.stringify(value)})`
|
|
33576
33756
|
);
|
|
33577
33757
|
}
|
|
33578
33758
|
identity.content_map.set(key, Buffer.from(value, "hex"));
|
|
@@ -33608,6 +33788,10 @@ function buildAndSignIdentityUpdate(params, network, operation = "update", lockU
|
|
|
33608
33788
|
if (params.primaryAddresses) {
|
|
33609
33789
|
identity.setPrimaryAddresses(params.primaryAddresses);
|
|
33610
33790
|
}
|
|
33791
|
+
if (params.minSigs !== void 0) {
|
|
33792
|
+
validateMinSigs(params.minSigs, identity.primary_addresses?.length ?? 0);
|
|
33793
|
+
identity.min_sigs = new import_bn.default(params.minSigs);
|
|
33794
|
+
}
|
|
33611
33795
|
if (params.revocationAuthority) {
|
|
33612
33796
|
identity.setRevocation(params.revocationAuthority);
|
|
33613
33797
|
}
|
|
@@ -33617,11 +33801,23 @@ function buildAndSignIdentityUpdate(params, network, operation = "update", lockU
|
|
|
33617
33801
|
break;
|
|
33618
33802
|
}
|
|
33619
33803
|
case "lock": {
|
|
33620
|
-
const
|
|
33621
|
-
if (!
|
|
33622
|
-
throw new TransactionBuildError(
|
|
33804
|
+
const delay = lockUnlockParams?.unlockDelayBlocks;
|
|
33805
|
+
if (delay === void 0 || !Number.isInteger(delay) || delay <= 0) {
|
|
33806
|
+
throw new TransactionBuildError(
|
|
33807
|
+
"unlockDelayBlocks (a positive integer RELATIVE delay in blocks, not a block height) is required for lock"
|
|
33808
|
+
);
|
|
33809
|
+
}
|
|
33810
|
+
if (delay > MAX_UNLOCK_DELAY) {
|
|
33811
|
+
throw new TransactionBuildError(
|
|
33812
|
+
`unlockDelayBlocks ${delay} exceeds the consensus maximum ${MAX_UNLOCK_DELAY} (~22 years)`
|
|
33813
|
+
);
|
|
33814
|
+
}
|
|
33815
|
+
if (delay > LOCK_DELAY_SANITY_BLOCKS && !lockUnlockParams?.sanityOverride) {
|
|
33816
|
+
throw new TransactionBuildError(
|
|
33817
|
+
`unlockDelayBlocks ${delay} is over ~1 year (${LOCK_DELAY_SANITY_BLOCKS} blocks) \u2014 this is a RELATIVE delay, not a block height; pass sanityOverride: true if that long a lock is intended.`
|
|
33818
|
+
);
|
|
33623
33819
|
}
|
|
33624
|
-
identity.lock(new import_bn.default(
|
|
33820
|
+
identity.lock(new import_bn.default(delay));
|
|
33625
33821
|
break;
|
|
33626
33822
|
}
|
|
33627
33823
|
case "unlock": {
|
|
@@ -33635,6 +33831,13 @@ function buildAndSignIdentityUpdate(params, network, operation = "update", lockU
|
|
|
33635
33831
|
break;
|
|
33636
33832
|
}
|
|
33637
33833
|
}
|
|
33834
|
+
const finalPrimaries = identity.primary_addresses?.length ?? 0;
|
|
33835
|
+
const finalMinSigs = identity.min_sigs?.toNumber?.() ?? 1;
|
|
33836
|
+
if (finalMinSigs > finalPrimaries) {
|
|
33837
|
+
throw new TransactionBuildError(
|
|
33838
|
+
`resulting identity has min_sigs ${finalMinSigs} but only ${finalPrimaries} primary address(es); pass minSigs to lower it when reducing the primary set.`
|
|
33839
|
+
);
|
|
33840
|
+
}
|
|
33638
33841
|
const identityBuf = identity.toBuffer();
|
|
33639
33842
|
const unfundedHex = createUnfundedIdentityUpdate(
|
|
33640
33843
|
identityBuf.toString("hex"),
|
|
@@ -33654,6 +33857,13 @@ function buildAndSignIdentityUpdate(params, network, operation = "update", lockU
|
|
|
33654
33857
|
// so a big update isn't fee-estimated below the relay minimum.
|
|
33655
33858
|
unfundedHex.length / 2
|
|
33656
33859
|
);
|
|
33860
|
+
assertTokenConservation(
|
|
33861
|
+
selection.selected,
|
|
33862
|
+
/* @__PURE__ */ new Map(),
|
|
33863
|
+
/* @__PURE__ */ new Map(),
|
|
33864
|
+
systemId,
|
|
33865
|
+
"identity update"
|
|
33866
|
+
);
|
|
33657
33867
|
const txb = new import_utxo_lib3.TransactionBuilder(verusNetwork);
|
|
33658
33868
|
txb.setVersion(4);
|
|
33659
33869
|
txb.setExpiryHeight(resolveExpiryHeight(params.expiryHeight));
|
|
@@ -33672,7 +33882,7 @@ function buildAndSignIdentityUpdate(params, network, operation = "update", lockU
|
|
|
33672
33882
|
}
|
|
33673
33883
|
if (selection.nativeChange > 0n) {
|
|
33674
33884
|
if (params.changeAddress.startsWith("i")) {
|
|
33675
|
-
txb.addOutput(identityPaymentScript(params.changeAddress), toSafeNumber(selection.nativeChange));
|
|
33885
|
+
txb.addOutput(identityPaymentScript(parseIAddress(params.changeAddress, "changeAddress")), toSafeNumber(selection.nativeChange));
|
|
33676
33886
|
} else {
|
|
33677
33887
|
txb.addOutput(params.changeAddress, toSafeNumber(selection.nativeChange));
|
|
33678
33888
|
}
|
|
@@ -33742,12 +33952,12 @@ function validateAmount(amount, label = "amount") {
|
|
|
33742
33952
|
}
|
|
33743
33953
|
function decodeBase58Address(address) {
|
|
33744
33954
|
try {
|
|
33745
|
-
return Buffer.from(
|
|
33955
|
+
return Buffer.from(import_bs58check4.default.decode(address));
|
|
33746
33956
|
} catch (err) {
|
|
33747
33957
|
throw new InvalidAddressError(address, err.message);
|
|
33748
33958
|
}
|
|
33749
33959
|
}
|
|
33750
|
-
function
|
|
33960
|
+
function parseAddress2(address, addressType) {
|
|
33751
33961
|
let type;
|
|
33752
33962
|
let destinationBytes;
|
|
33753
33963
|
switch (addressType) {
|
|
@@ -33814,7 +34024,7 @@ function sendCurrency(params, network) {
|
|
|
33814
34024
|
const txOutputs = params.outputs.map((out) => ({
|
|
33815
34025
|
currency: out.currency,
|
|
33816
34026
|
satoshis: out.satoshis.toString(10),
|
|
33817
|
-
address:
|
|
34027
|
+
address: parseAddress2(out.address, out.addressType || "PKH"),
|
|
33818
34028
|
...out.convertTo !== void 0 ? { convertto: out.convertTo } : {},
|
|
33819
34029
|
...out.exportTo !== void 0 ? { exportto: out.exportTo } : {},
|
|
33820
34030
|
...out.via !== void 0 ? { via: out.via } : {},
|
|
@@ -33878,19 +34088,20 @@ function sendCurrency(params, network) {
|
|
|
33878
34088
|
}
|
|
33879
34089
|
if (selection.currencyChanges.size > 0) {
|
|
33880
34090
|
const tokenChange = buildTokenChangeOutput(
|
|
33881
|
-
params.changeAddress,
|
|
34091
|
+
parseAddress(params.changeAddress, "changeAddress"),
|
|
33882
34092
|
selection.currencyChanges
|
|
33883
34093
|
);
|
|
33884
34094
|
txb.addOutput(tokenChange.script, toSafeNumber(tokenChange.nativeValue));
|
|
33885
34095
|
}
|
|
33886
34096
|
if (selection.nativeChange > 0n) {
|
|
33887
34097
|
if (params.changeAddress.startsWith("i")) {
|
|
33888
|
-
txb.addOutput(identityPaymentScript(params.changeAddress), toSafeNumber(selection.nativeChange));
|
|
34098
|
+
txb.addOutput(identityPaymentScript(parseIAddress(params.changeAddress, "changeAddress")), toSafeNumber(selection.nativeChange));
|
|
33889
34099
|
} else {
|
|
33890
34100
|
txb.addOutput(params.changeAddress, toSafeNumber(selection.nativeChange));
|
|
33891
34101
|
}
|
|
33892
34102
|
}
|
|
33893
34103
|
const unsignedTx = txb.buildIncomplete();
|
|
34104
|
+
assertNativeConservation(selection.selected, unsignedTx.outs, selection.fee, "sendCurrency");
|
|
33894
34105
|
const { signedTx, txid } = signTransactionSmart(
|
|
33895
34106
|
unsignedTx.toHex(),
|
|
33896
34107
|
params.wif,
|
|
@@ -34196,6 +34407,13 @@ function defineCurrency(params, network) {
|
|
|
34196
34407
|
true,
|
|
34197
34408
|
identityOutputScript.length + currencyDefScript.length
|
|
34198
34409
|
);
|
|
34410
|
+
assertTokenConservation(
|
|
34411
|
+
selection.selected,
|
|
34412
|
+
/* @__PURE__ */ new Map(),
|
|
34413
|
+
/* @__PURE__ */ new Map(),
|
|
34414
|
+
systemId,
|
|
34415
|
+
"currency definition"
|
|
34416
|
+
);
|
|
34199
34417
|
const txb = new import_utxo_lib6.TransactionBuilder(verusNetwork);
|
|
34200
34418
|
txb.setVersion(4);
|
|
34201
34419
|
txb.setExpiryHeight(resolveExpiryHeight(params.expiryHeight));
|
|
@@ -34212,7 +34430,7 @@ function defineCurrency(params, network) {
|
|
|
34212
34430
|
txb.addOutput(currencyDefScript, toSafeNumber(currencyDefValue));
|
|
34213
34431
|
if (selection.nativeChange > 0n) {
|
|
34214
34432
|
if (params.changeAddress.startsWith("i")) {
|
|
34215
|
-
txb.addOutput(identityPaymentScript(params.changeAddress), toSafeNumber(selection.nativeChange));
|
|
34433
|
+
txb.addOutput(identityPaymentScript(parseIAddress(params.changeAddress, "changeAddress")), toSafeNumber(selection.nativeChange));
|
|
34216
34434
|
} else {
|
|
34217
34435
|
txb.addOutput(params.changeAddress, toSafeNumber(selection.nativeChange));
|
|
34218
34436
|
}
|
|
@@ -34299,7 +34517,10 @@ var VerusSDK = class {
|
|
|
34299
34517
|
updateIdentity(params) {
|
|
34300
34518
|
return buildAndSignIdentityUpdate(params, this.network, "update");
|
|
34301
34519
|
}
|
|
34302
|
-
/**
|
|
34520
|
+
/**
|
|
34521
|
+
* Lock an identity for a RELATIVE delay of `unlockDelayBlocks` blocks (NOT an
|
|
34522
|
+
* absolute block height — passing a height locks the identity for years).
|
|
34523
|
+
*/
|
|
34303
34524
|
lockIdentity(params) {
|
|
34304
34525
|
return buildAndSignIdentityUpdate(
|
|
34305
34526
|
{
|
|
@@ -34312,7 +34533,7 @@ var VerusSDK = class {
|
|
|
34312
34533
|
},
|
|
34313
34534
|
this.network,
|
|
34314
34535
|
"lock",
|
|
34315
|
-
{
|
|
34536
|
+
{ unlockDelayBlocks: params.unlockDelayBlocks, sanityOverride: params.sanityOverride ?? false }
|
|
34316
34537
|
);
|
|
34317
34538
|
}
|
|
34318
34539
|
/** Initiate identity unlock */
|
|
@@ -34355,6 +34576,7 @@ var VerusSDK = class {
|
|
|
34355
34576
|
utxos: params.utxos,
|
|
34356
34577
|
changeAddress: params.changeAddress,
|
|
34357
34578
|
...params.primaryAddresses !== void 0 ? { primaryAddresses: params.primaryAddresses } : {},
|
|
34579
|
+
...params.minSigs !== void 0 ? { minSigs: params.minSigs } : {},
|
|
34358
34580
|
...params.revocationAuthority !== void 0 ? { revocationAuthority: params.revocationAuthority } : {},
|
|
34359
34581
|
...params.recoveryAuthority !== void 0 ? { recoveryAuthority: params.recoveryAuthority } : {},
|
|
34360
34582
|
expiryHeight: params.expiryHeight
|
|
@@ -34404,20 +34626,20 @@ var VerusSDK = class {
|
|
|
34404
34626
|
var address_exports = {};
|
|
34405
34627
|
__export(address_exports, {
|
|
34406
34628
|
BASE58_RE: () => BASE58_RE,
|
|
34407
|
-
isIAddress: () =>
|
|
34629
|
+
isIAddress: () => isIAddress2,
|
|
34408
34630
|
isIdentityName: () => isIdentityName,
|
|
34409
|
-
isRAddress: () =>
|
|
34631
|
+
isRAddress: () => isRAddress2,
|
|
34410
34632
|
isVerusAddress: () => isVerusAddress
|
|
34411
34633
|
});
|
|
34412
34634
|
var BASE58_RE = /^[1-9A-HJ-NP-Za-km-z]+$/;
|
|
34413
|
-
function
|
|
34635
|
+
function isRAddress2(input) {
|
|
34414
34636
|
return input.startsWith("R") && input.length >= 26 && input.length <= 36 && BASE58_RE.test(input);
|
|
34415
34637
|
}
|
|
34416
|
-
function
|
|
34638
|
+
function isIAddress2(input) {
|
|
34417
34639
|
return input.startsWith("i") && input.length >= 26 && input.length <= 36 && BASE58_RE.test(input);
|
|
34418
34640
|
}
|
|
34419
34641
|
function isVerusAddress(input) {
|
|
34420
|
-
return
|
|
34642
|
+
return isRAddress2(input) || isIAddress2(input);
|
|
34421
34643
|
}
|
|
34422
34644
|
function isIdentityName(input) {
|
|
34423
34645
|
if (!input || isVerusAddress(input)) return false;
|