@chainvue/verus-sdk 0.14.1 → 0.16.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/LICENSE +1 -1
- package/README.md +15 -0
- package/dist/VerusSDK.d.ts +7 -0
- package/dist/VerusSDK.d.ts.map +1 -1
- package/dist/VerusSDK.js +11 -0
- package/dist/VerusSDK.js.map +1 -1
- package/dist/assemble/assembler.d.ts +2 -8
- package/dist/assemble/assembler.d.ts.map +1 -1
- package/dist/assemble/assembler.js +30 -20
- package/dist/assemble/assembler.js.map +1 -1
- package/dist/assemble/fundedIdentityUpdate.d.ts +0 -3
- package/dist/assemble/fundedIdentityUpdate.d.ts.map +1 -1
- package/dist/assemble/fundedIdentityUpdate.js +22 -14
- package/dist/assemble/fundedIdentityUpdate.js.map +1 -1
- package/dist/bundle.js +232 -159
- package/dist/constants/index.d.ts +8 -2
- package/dist/constants/index.d.ts.map +1 -1
- package/dist/constants/index.js +9 -3
- package/dist/constants/index.js.map +1 -1
- package/dist/currency/index.d.ts.map +1 -1
- package/dist/currency/index.js +0 -3
- package/dist/currency/index.js.map +1 -1
- package/dist/currency/launch.d.ts.map +1 -1
- package/dist/currency/launch.js +0 -2
- package/dist/currency/launch.js.map +1 -1
- package/dist/errors.d.ts +4 -0
- package/dist/errors.d.ts.map +1 -1
- package/dist/errors.js +9 -1
- package/dist/errors.js.map +1 -1
- package/dist/fee/index.d.ts +116 -0
- package/dist/fee/index.d.ts.map +1 -0
- package/dist/fee/index.js +228 -0
- package/dist/fee/index.js.map +1 -0
- package/dist/identity/index.d.ts.map +1 -1
- package/dist/identity/index.js +2 -16
- package/dist/identity/index.js.map +1 -1
- package/dist/identity/multisig.d.ts.map +1 -1
- package/dist/identity/multisig.js +23 -18
- package/dist/identity/multisig.js.map +1 -1
- package/dist/index.d.ts +4 -2
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +42 -33
- package/dist/index.js.map +1 -1
- package/dist/keys/index.d.ts +22 -0
- package/dist/keys/index.d.ts.map +1 -1
- package/dist/keys/index.js +91 -0
- package/dist/keys/index.js.map +1 -1
- package/dist/offers/identity.d.ts.map +1 -1
- package/dist/offers/identity.js +40 -32
- package/dist/offers/identity.js.map +1 -1
- package/dist/offers/reclaim.d.ts.map +1 -1
- package/dist/offers/reclaim.js +29 -21
- package/dist/offers/reclaim.js.map +1 -1
- package/dist/offers/taker.d.ts.map +1 -1
- package/dist/offers/taker.js +22 -17
- package/dist/offers/taker.js.map +1 -1
- package/dist/transfer/index.d.ts.map +1 -1
- package/dist/transfer/index.js +0 -2
- package/dist/transfer/index.js.map +1 -1
- package/dist/utxo/index.d.ts +11 -8
- package/dist/utxo/index.d.ts.map +1 -1
- package/dist/utxo/index.js +20 -37
- package/dist/utxo/index.js.map +1 -1
- package/package.json +1 -1
package/dist/bundle.js
CHANGED
|
@@ -9592,7 +9592,7 @@ var require_Identity = __commonJS({
|
|
|
9592
9592
|
exports2.IDENTITY_MAX_UNLOCK_DELAY = new bn_js_1.BN(60).mul(new bn_js_1.BN(24)).mul(new bn_js_1.BN(22)).mul(new bn_js_1.BN(365));
|
|
9593
9593
|
exports2.IDENTITY_MAX_NAME_LEN = new bn_js_1.BN(64);
|
|
9594
9594
|
var { BufferReader, BufferWriter } = bufferutils_1.default;
|
|
9595
|
-
var
|
|
9595
|
+
var Identity8 = class _Identity extends Principal_1.Principal {
|
|
9596
9596
|
constructor(data) {
|
|
9597
9597
|
super(data);
|
|
9598
9598
|
if (data === null || data === void 0 ? void 0 : data.version)
|
|
@@ -9959,14 +9959,14 @@ var require_Identity = __commonJS({
|
|
|
9959
9959
|
return _Identity.internalFromJson(json, _Identity);
|
|
9960
9960
|
}
|
|
9961
9961
|
};
|
|
9962
|
-
exports2.Identity =
|
|
9963
|
-
|
|
9964
|
-
|
|
9965
|
-
|
|
9966
|
-
|
|
9967
|
-
|
|
9968
|
-
|
|
9969
|
-
|
|
9962
|
+
exports2.Identity = Identity8;
|
|
9963
|
+
Identity8.VERSION_INVALID = new bn_js_1.BN(0);
|
|
9964
|
+
Identity8.VERSION_VERUSID = new bn_js_1.BN(1);
|
|
9965
|
+
Identity8.VERSION_VAULT = new bn_js_1.BN(2);
|
|
9966
|
+
Identity8.VERSION_PBAAS = new bn_js_1.BN(3);
|
|
9967
|
+
Identity8.VERSION_CURRENT = Identity8.VERSION_PBAAS;
|
|
9968
|
+
Identity8.VERSION_FIRSTVALID = new bn_js_1.BN(1);
|
|
9969
|
+
Identity8.VERSION_LASTVALID = new bn_js_1.BN(3);
|
|
9970
9970
|
}
|
|
9971
9971
|
});
|
|
9972
9972
|
|
|
@@ -11091,7 +11091,7 @@ var require_IdentityScript = __commonJS({
|
|
|
11091
11091
|
var IdentityID_1 = require_IdentityID();
|
|
11092
11092
|
var cccustom_1 = require_cccustom();
|
|
11093
11093
|
var KeyID_1 = require_KeyID();
|
|
11094
|
-
var
|
|
11094
|
+
var IdentityScript4 = class _IdentityScript extends SmartTransactionScript_1.SmartTransactionScript {
|
|
11095
11095
|
constructor(master, params) {
|
|
11096
11096
|
super(master, params);
|
|
11097
11097
|
}
|
|
@@ -11171,7 +11171,7 @@ var require_IdentityScript = __commonJS({
|
|
|
11171
11171
|
return identity;
|
|
11172
11172
|
}
|
|
11173
11173
|
};
|
|
11174
|
-
exports2.IdentityScript =
|
|
11174
|
+
exports2.IdentityScript = IdentityScript4;
|
|
11175
11175
|
}
|
|
11176
11176
|
});
|
|
11177
11177
|
|
|
@@ -20877,7 +20877,7 @@ var require_optccparams = __commonJS({
|
|
|
20877
20877
|
"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) {
|
|
20878
20878
|
"use strict";
|
|
20879
20879
|
var bscript = require_script2();
|
|
20880
|
-
var
|
|
20880
|
+
var EVALS3 = require_evals2();
|
|
20881
20881
|
var varuint = require_varuint_bitcoin();
|
|
20882
20882
|
var TxDestination3 = require_tx_destination();
|
|
20883
20883
|
var bufferutils = require_bufferutils2();
|
|
@@ -20917,27 +20917,27 @@ var require_optccparams = __commonJS({
|
|
|
20917
20917
|
}
|
|
20918
20918
|
OptCCParams4.prototype.getParamObject = function() {
|
|
20919
20919
|
switch (this.evalCode) {
|
|
20920
|
-
case
|
|
20920
|
+
case EVALS3.EVAL_NONE: {
|
|
20921
20921
|
return null;
|
|
20922
20922
|
}
|
|
20923
|
-
case
|
|
20924
|
-
case
|
|
20925
|
-
case
|
|
20926
|
-
case
|
|
20927
|
-
case
|
|
20928
|
-
case
|
|
20929
|
-
case
|
|
20930
|
-
case
|
|
20931
|
-
case
|
|
20932
|
-
case
|
|
20933
|
-
case
|
|
20934
|
-
case
|
|
20935
|
-
case
|
|
20936
|
-
case
|
|
20937
|
-
case
|
|
20938
|
-
case
|
|
20939
|
-
case
|
|
20940
|
-
case
|
|
20923
|
+
case EVALS3.EVAL_STAKEGUARD:
|
|
20924
|
+
case EVALS3.EVAL_CURRENCY_DEFINITION:
|
|
20925
|
+
case EVALS3.EVAL_NOTARY_EVIDENCE:
|
|
20926
|
+
case EVALS3.EVAL_EARNEDNOTARIZATION:
|
|
20927
|
+
case EVALS3.EVAL_ACCEPTEDNOTARIZATION:
|
|
20928
|
+
case EVALS3.EVAL_FINALIZE_NOTARIZATION:
|
|
20929
|
+
case EVALS3.EVAL_CURRENCYSTATE:
|
|
20930
|
+
case EVALS3.EVAL_RESERVE_TRANSFER:
|
|
20931
|
+
case EVALS3.EVAL_RESERVE_OUTPUT:
|
|
20932
|
+
case EVALS3.EVAL_RESERVE_DEPOSIT:
|
|
20933
|
+
case EVALS3.EVAL_CROSSCHAIN_EXPORT:
|
|
20934
|
+
case EVALS3.EVAL_CROSSCHAIN_IMPORT:
|
|
20935
|
+
case EVALS3.EVAL_IDENTITY_PRIMARY:
|
|
20936
|
+
case EVALS3.EVAL_IDENTITY_COMMITMENT:
|
|
20937
|
+
case EVALS3.EVAL_IDENTITY_RESERVATION:
|
|
20938
|
+
case EVALS3.EVAL_FINALIZE_EXPORT:
|
|
20939
|
+
case EVALS3.EVAL_FEE_POOL:
|
|
20940
|
+
case EVALS3.EVAL_NOTARY_SIGNATURE: {
|
|
20941
20941
|
if (this.vData.length) {
|
|
20942
20942
|
return this.vData[0];
|
|
20943
20943
|
} else {
|
|
@@ -20952,28 +20952,28 @@ var require_optccparams = __commonJS({
|
|
|
20952
20952
|
OptCCParams4.prototype.isValid = function() {
|
|
20953
20953
|
var validEval = false;
|
|
20954
20954
|
switch (this.evalCode) {
|
|
20955
|
-
case
|
|
20955
|
+
case EVALS3.EVAL_NONE: {
|
|
20956
20956
|
validEval = true;
|
|
20957
20957
|
break;
|
|
20958
20958
|
}
|
|
20959
|
-
case
|
|
20960
|
-
case
|
|
20961
|
-
case
|
|
20962
|
-
case
|
|
20963
|
-
case
|
|
20964
|
-
case
|
|
20965
|
-
case
|
|
20966
|
-
case
|
|
20967
|
-
case
|
|
20968
|
-
case
|
|
20969
|
-
case
|
|
20970
|
-
case
|
|
20971
|
-
case
|
|
20972
|
-
case
|
|
20973
|
-
case
|
|
20974
|
-
case
|
|
20975
|
-
case
|
|
20976
|
-
case
|
|
20959
|
+
case EVALS3.EVAL_STAKEGUARD:
|
|
20960
|
+
case EVALS3.EVAL_CURRENCY_DEFINITION:
|
|
20961
|
+
case EVALS3.EVAL_NOTARY_EVIDENCE:
|
|
20962
|
+
case EVALS3.EVAL_EARNEDNOTARIZATION:
|
|
20963
|
+
case EVALS3.EVAL_ACCEPTEDNOTARIZATION:
|
|
20964
|
+
case EVALS3.EVAL_FINALIZE_NOTARIZATION:
|
|
20965
|
+
case EVALS3.EVAL_CURRENCYSTATE:
|
|
20966
|
+
case EVALS3.EVAL_RESERVE_TRANSFER:
|
|
20967
|
+
case EVALS3.EVAL_RESERVE_OUTPUT:
|
|
20968
|
+
case EVALS3.EVAL_RESERVE_DEPOSIT:
|
|
20969
|
+
case EVALS3.EVAL_CROSSCHAIN_EXPORT:
|
|
20970
|
+
case EVALS3.EVAL_CROSSCHAIN_IMPORT:
|
|
20971
|
+
case EVALS3.EVAL_IDENTITY_PRIMARY:
|
|
20972
|
+
case EVALS3.EVAL_IDENTITY_COMMITMENT:
|
|
20973
|
+
case EVALS3.EVAL_IDENTITY_RESERVATION:
|
|
20974
|
+
case EVALS3.EVAL_FINALIZE_EXPORT:
|
|
20975
|
+
case EVALS3.EVAL_FEE_POOL:
|
|
20976
|
+
case EVALS3.EVAL_NOTARY_SIGNATURE: {
|
|
20977
20977
|
validEval = this.vData && this.vData.length > 0;
|
|
20978
20978
|
}
|
|
20979
20979
|
}
|
|
@@ -32216,9 +32216,9 @@ __export(src_exports, {
|
|
|
32216
32216
|
CURRENCY_OPTION: () => CURRENCY_OPTION,
|
|
32217
32217
|
CURRENCY_TYPE_ORDER: () => CURRENCY_TYPE_ORDER,
|
|
32218
32218
|
DEFAULT_EXPIRY_DELTA: () => DEFAULT_EXPIRY_DELTA,
|
|
32219
|
-
DEFAULT_FEE_PER_KB: () => DEFAULT_FEE_PER_KB,
|
|
32220
32219
|
DEFAULT_REFERRAL_LEVELS: () => DEFAULT_REFERRAL_LEVELS,
|
|
32221
32220
|
DEFAULT_REGISTRATION_FEE: () => DEFAULT_REGISTRATION_FEE,
|
|
32221
|
+
DEFAULT_TRANSACTION_FEE: () => DEFAULT_TRANSACTION_FEE,
|
|
32222
32222
|
DUST_THRESHOLD: () => DUST_THRESHOLD,
|
|
32223
32223
|
HASH_SHA256: () => HASH_SHA256,
|
|
32224
32224
|
IDENTITY_FLAG_ACTIVECURRENCY: () => IDENTITY_FLAG_ACTIVECURRENCY,
|
|
@@ -32228,7 +32228,9 @@ __export(src_exports, {
|
|
|
32228
32228
|
InvalidAddressError: () => InvalidAddressError,
|
|
32229
32229
|
InvalidAmountError: () => InvalidAmountError,
|
|
32230
32230
|
InvalidNameError: () => InvalidNameError,
|
|
32231
|
+
InvalidSeedError: () => InvalidSeedError,
|
|
32231
32232
|
InvalidWifError: () => InvalidWifError,
|
|
32233
|
+
LARGE_SCRIPT_FEE_THRESHOLD: () => LARGE_SCRIPT_FEE_THRESHOLD,
|
|
32232
32234
|
NETWORK_CONFIG: () => NETWORK_CONFIG,
|
|
32233
32235
|
NOTARIZATION_PROTOCOL: () => NOTARIZATION_PROTOCOL,
|
|
32234
32236
|
PROOF_PROTOCOL: () => PROOF_PROTOCOL,
|
|
@@ -32243,12 +32245,16 @@ __export(src_exports, {
|
|
|
32243
32245
|
VerusSDK: () => VerusSDK,
|
|
32244
32246
|
WIF_PREFIX: () => WIF_PREFIX,
|
|
32245
32247
|
address: () => address_exports,
|
|
32248
|
+
assertFeeMeetsRelayMinimum: () => assertFeeMeetsRelayMinimum,
|
|
32246
32249
|
buildCurrencyDefinitionScript: () => buildCurrencyDefinitionScript,
|
|
32247
32250
|
buildCurrencyLaunchOutputs: () => buildCurrencyLaunchOutputs,
|
|
32248
32251
|
buildCurrencyLaunchTransaction: () => buildCurrencyLaunchTransaction,
|
|
32249
32252
|
buildReserveTransferOutput: () => buildReserveTransferOutput,
|
|
32250
32253
|
classifyCurrency: () => classifyCurrency,
|
|
32254
|
+
computeIdentityFeeFactor: () => computeIdentityFeeFactor,
|
|
32251
32255
|
currency: () => currency_exports,
|
|
32256
|
+
estimateMinerFee: () => estimateMinerFee,
|
|
32257
|
+
fee: () => fee_exports,
|
|
32252
32258
|
identity: () => public_exports2,
|
|
32253
32259
|
identityMultisig: () => multisig_exports,
|
|
32254
32260
|
isIAddress: () => isIAddress2,
|
|
@@ -32259,6 +32265,7 @@ __export(src_exports, {
|
|
|
32259
32265
|
message: () => message_exports,
|
|
32260
32266
|
offers: () => public_exports,
|
|
32261
32267
|
parseSats: () => parseSats,
|
|
32268
|
+
relayMinimumFee: () => relayMinimumFee,
|
|
32262
32269
|
serializeCurrencyDefinition: () => serializeCurrencyDefinition,
|
|
32263
32270
|
signing: () => signing_exports,
|
|
32264
32271
|
toCoins: () => toCoins,
|
|
@@ -32320,7 +32327,7 @@ var NETWORK_CONFIG = {
|
|
|
32320
32327
|
var CONSENSUS_BRANCH_ID = 1991772603;
|
|
32321
32328
|
var VERSION_GROUP_ID = 2301567109;
|
|
32322
32329
|
var TX_VERSION = 4;
|
|
32323
|
-
var
|
|
32330
|
+
var DEFAULT_TRANSACTION_FEE = 10000n;
|
|
32324
32331
|
var DUST_THRESHOLD = 546n;
|
|
32325
32332
|
var DEFAULT_REGISTRATION_FEE = 10000000000n;
|
|
32326
32333
|
var DEFAULT_REFERRAL_LEVELS = 3;
|
|
@@ -32392,6 +32399,12 @@ var InvalidWifError = class extends VerusError {
|
|
|
32392
32399
|
this.name = "InvalidWifError";
|
|
32393
32400
|
}
|
|
32394
32401
|
};
|
|
32402
|
+
var InvalidSeedError = class extends VerusError {
|
|
32403
|
+
constructor(detail) {
|
|
32404
|
+
super("INVALID_SEED", `Invalid seed: ${detail}`);
|
|
32405
|
+
this.name = "InvalidSeedError";
|
|
32406
|
+
}
|
|
32407
|
+
};
|
|
32395
32408
|
var InvalidAddressError = class extends VerusError {
|
|
32396
32409
|
constructor(address2, detail) {
|
|
32397
32410
|
super(
|
|
@@ -32660,16 +32673,10 @@ var utxo_exports = {};
|
|
|
32660
32673
|
__export(utxo_exports, {
|
|
32661
32674
|
assertTokenConservation: () => assertTokenConservation,
|
|
32662
32675
|
decodeUtxo: () => decodeUtxo,
|
|
32663
|
-
estimateFee: () => estimateFee,
|
|
32664
32676
|
isSmartTransactionScript: () => isSmartTransactionScript,
|
|
32665
32677
|
selectUtxos: () => selectUtxos
|
|
32666
32678
|
});
|
|
32667
32679
|
var { unpackOutput } = import_utxo_lib.smarttxs;
|
|
32668
|
-
var INPUT_SIZE = 180;
|
|
32669
|
-
var P2PKH_OUTPUT_SIZE = 34;
|
|
32670
|
-
var SMART_OUTPUT_SIZE = 200;
|
|
32671
|
-
var TX_OVERHEAD = 60;
|
|
32672
|
-
var MIN_FEE = 10000n;
|
|
32673
32680
|
function isSmartTransactionScript(script2) {
|
|
32674
32681
|
try {
|
|
32675
32682
|
const chunks = import_utxo_lib.script.decompile(script2);
|
|
@@ -32728,13 +32735,12 @@ function assertTokenConservation(selected, spentToOutputs, currencyChanges, syst
|
|
|
32728
32735
|
}
|
|
32729
32736
|
}
|
|
32730
32737
|
}
|
|
32731
|
-
function
|
|
32732
|
-
|
|
32733
|
-
|
|
32734
|
-
|
|
32735
|
-
|
|
32736
|
-
}
|
|
32737
|
-
function selectUtxos(utxos, requiredNative, requiredCurrencies = /* @__PURE__ */ new Map(), numOutputs = 2, systemId = NETWORK_CONFIG.mainnet.chainId, feePerKb = DEFAULT_FEE_PER_KB, hasSmartOutputs = false, extraOutputBytes = 0) {
|
|
32738
|
+
function selectUtxos(utxos, requiredNative, requiredCurrencies, fee, systemId = NETWORK_CONFIG.mainnet.chainId) {
|
|
32739
|
+
if (typeof fee !== "bigint" || fee < DEFAULT_TRANSACTION_FEE) {
|
|
32740
|
+
throw new TransactionBuildError(
|
|
32741
|
+
`selectUtxos: fee must be a bigint of at least ${DEFAULT_TRANSACTION_FEE} satoshis (compute it with estimateMinerFee), got ${String(fee)}`
|
|
32742
|
+
);
|
|
32743
|
+
}
|
|
32738
32744
|
const seenOutpoints = /* @__PURE__ */ new Set();
|
|
32739
32745
|
for (const u of utxos) {
|
|
32740
32746
|
const outpoint = `${u.txid}:${u.outputIndex}`;
|
|
@@ -32800,21 +32806,6 @@ function selectUtxos(utxos, requiredNative, requiredCurrencies = /* @__PURE__ */
|
|
|
32800
32806
|
if (at !== bt) return at - bt;
|
|
32801
32807
|
return b.satoshis > a.satoshis ? 1 : b.satoshis < a.satoshis ? -1 : 0;
|
|
32802
32808
|
});
|
|
32803
|
-
const countCurrencyChanges = () => {
|
|
32804
|
-
let n = 0;
|
|
32805
|
-
for (const [currency, needed] of remaining) {
|
|
32806
|
-
if (currency !== systemId && needed < 0n) n++;
|
|
32807
|
-
}
|
|
32808
|
-
return n;
|
|
32809
|
-
};
|
|
32810
|
-
let changeOutputCount = countCurrencyChanges();
|
|
32811
|
-
let fee = estimateFee(
|
|
32812
|
-
selected.length + 1,
|
|
32813
|
-
numOutputs + 1 + changeOutputCount,
|
|
32814
|
-
feePerKb,
|
|
32815
|
-
hasSmartOutputs,
|
|
32816
|
-
extraOutputBytes
|
|
32817
|
-
);
|
|
32818
32809
|
while (remainingNative + fee > 0n) {
|
|
32819
32810
|
const next = nativeOnly.shift();
|
|
32820
32811
|
if (!next) {
|
|
@@ -32831,14 +32822,6 @@ function selectUtxos(utxos, requiredNative, requiredCurrencies = /* @__PURE__ */
|
|
|
32831
32822
|
if (currency === systemId || amount <= 0n) continue;
|
|
32832
32823
|
remaining.set(currency, (remaining.get(currency) || 0n) - amount);
|
|
32833
32824
|
}
|
|
32834
|
-
changeOutputCount = countCurrencyChanges();
|
|
32835
|
-
fee = estimateFee(
|
|
32836
|
-
selected.length,
|
|
32837
|
-
numOutputs + 1 + changeOutputCount,
|
|
32838
|
-
feePerKb,
|
|
32839
|
-
hasSmartOutputs,
|
|
32840
|
-
extraOutputBytes
|
|
32841
|
-
);
|
|
32842
32825
|
}
|
|
32843
32826
|
const totalNativeIn = selected.reduce((sum, u) => sum + u.satoshis, 0n);
|
|
32844
32827
|
const actualNativeChange = totalNativeIn - requiredNative - fee;
|
|
@@ -32858,6 +32841,78 @@ function selectUtxos(utxos, requiredNative, requiredCurrencies = /* @__PURE__ */
|
|
|
32858
32841
|
};
|
|
32859
32842
|
}
|
|
32860
32843
|
|
|
32844
|
+
// src/fee/index.ts
|
|
32845
|
+
var fee_exports = {};
|
|
32846
|
+
__export(fee_exports, {
|
|
32847
|
+
LARGE_SCRIPT_FEE_THRESHOLD: () => LARGE_SCRIPT_FEE_THRESHOLD,
|
|
32848
|
+
assertFeeMeetsRelayMinimum: () => assertFeeMeetsRelayMinimum,
|
|
32849
|
+
computeIdentityFeeFactor: () => computeIdentityFeeFactor,
|
|
32850
|
+
estimateMinerFee: () => estimateMinerFee,
|
|
32851
|
+
relayMinimumFee: () => relayMinimumFee
|
|
32852
|
+
});
|
|
32853
|
+
var LARGE_SCRIPT_FEE_THRESHOLD = 2e3;
|
|
32854
|
+
var ID_EXTRA_LIMIT = 0;
|
|
32855
|
+
function largeScriptSurcharge(scriptLength) {
|
|
32856
|
+
if (scriptLength > 2 * LARGE_SCRIPT_FEE_THRESHOLD) return 2n * DEFAULT_TRANSACTION_FEE;
|
|
32857
|
+
if (scriptLength > LARGE_SCRIPT_FEE_THRESHOLD) return DEFAULT_TRANSACTION_FEE;
|
|
32858
|
+
return 0n;
|
|
32859
|
+
}
|
|
32860
|
+
function parseIdentityOutput(script2) {
|
|
32861
|
+
try {
|
|
32862
|
+
const parsed = new boundary_exports.IdentityScript();
|
|
32863
|
+
parsed.fromBuffer(script2);
|
|
32864
|
+
if (parsed.paramsOptCC.eval_code.toNumber() !== boundary_exports.EVALS.EVAL_IDENTITY_PRIMARY) return null;
|
|
32865
|
+
return parsed.getIdentity();
|
|
32866
|
+
} catch {
|
|
32867
|
+
return null;
|
|
32868
|
+
}
|
|
32869
|
+
}
|
|
32870
|
+
function computeIdentityFeeFactor(outputScripts) {
|
|
32871
|
+
let factor = 0;
|
|
32872
|
+
for (const script2 of outputScripts) {
|
|
32873
|
+
const identity = parseIdentityOutput(script2);
|
|
32874
|
+
if (identity === null) continue;
|
|
32875
|
+
factor += identity.content_map?.size ?? 0;
|
|
32876
|
+
factor += Math.max((identity.primary_addresses?.length ?? 0) - 1, 0);
|
|
32877
|
+
factor += Math.max((identity.private_addresses?.length ?? 0) - 1, 0);
|
|
32878
|
+
if ((identity.content_multimap?.kv_content?.size ?? 0) > 0) {
|
|
32879
|
+
const withContent = identity.getByteLength();
|
|
32880
|
+
identity.clearContentMultiMap();
|
|
32881
|
+
const serSize = withContent - identity.getByteLength();
|
|
32882
|
+
factor += Math.ceil(serSize / 128);
|
|
32883
|
+
}
|
|
32884
|
+
}
|
|
32885
|
+
return factor;
|
|
32886
|
+
}
|
|
32887
|
+
function estimateMinerFee(outputScripts) {
|
|
32888
|
+
const factor = BigInt(computeIdentityFeeFactor(outputScripts));
|
|
32889
|
+
const count = outputScripts.length;
|
|
32890
|
+
let fee = factor > 0n ? factor * DEFAULT_TRANSACTION_FEE : DEFAULT_TRANSACTION_FEE;
|
|
32891
|
+
fee += BigInt(Math.max(count - (1 + ID_EXTRA_LIMIT), 0)) * DEFAULT_TRANSACTION_FEE;
|
|
32892
|
+
if (!(factor > 0n && count <= 1 + ID_EXTRA_LIMIT)) {
|
|
32893
|
+
for (const script2 of outputScripts) fee += largeScriptSurcharge(script2.length);
|
|
32894
|
+
}
|
|
32895
|
+
return fee;
|
|
32896
|
+
}
|
|
32897
|
+
function relayMinimumFee(outputScripts) {
|
|
32898
|
+
const factor = BigInt(computeIdentityFeeFactor(outputScripts));
|
|
32899
|
+
const count = outputScripts.length;
|
|
32900
|
+
let fee = factor > 0n ? factor * DEFAULT_TRANSACTION_FEE : DEFAULT_TRANSACTION_FEE;
|
|
32901
|
+
fee += BigInt(Math.max(count - (3 + ID_EXTRA_LIMIT), 0)) * DEFAULT_TRANSACTION_FEE;
|
|
32902
|
+
if (!(factor > 0n && count <= 3 + ID_EXTRA_LIMIT)) {
|
|
32903
|
+
for (const script2 of outputScripts) fee += largeScriptSurcharge(script2.length);
|
|
32904
|
+
}
|
|
32905
|
+
return fee;
|
|
32906
|
+
}
|
|
32907
|
+
function assertFeeMeetsRelayMinimum(fee, outputScripts, label) {
|
|
32908
|
+
const minimum = relayMinimumFee(outputScripts);
|
|
32909
|
+
if (fee < minimum) {
|
|
32910
|
+
throw new TransactionBuildError(
|
|
32911
|
+
`${label}: miner fee ${fee} is below the daemon's relay minimum ${minimum} for this transaction's ${outputScripts.length} output(s); it would not reliably relay.`
|
|
32912
|
+
);
|
|
32913
|
+
}
|
|
32914
|
+
}
|
|
32915
|
+
|
|
32861
32916
|
// src/identity/index.ts
|
|
32862
32917
|
var import_crypto2 = require("crypto");
|
|
32863
32918
|
var import_bn = __toESM(require("bn.js"));
|
|
@@ -32917,16 +32972,8 @@ function assembleFundedIdentityUpdate(intent) {
|
|
|
32917
32972
|
const verusNetwork = getNetwork(intent.network === "testnet");
|
|
32918
32973
|
const systemId = NETWORK_CONFIG[intent.network].chainId;
|
|
32919
32974
|
const requiredNative = intent.outputs.reduce((sum, o) => sum + o.nativeSat, 0n);
|
|
32920
|
-
const
|
|
32921
|
-
|
|
32922
|
-
requiredNative,
|
|
32923
|
-
/* @__PURE__ */ new Map(),
|
|
32924
|
-
intent.outputs.length,
|
|
32925
|
-
systemId,
|
|
32926
|
-
void 0,
|
|
32927
|
-
true,
|
|
32928
|
-
intent.extraOutputBytes
|
|
32929
|
-
);
|
|
32975
|
+
const minerFee = estimateMinerFee(intent.outputs.map((o) => o.script));
|
|
32976
|
+
const selection = selectUtxos(intent.funding, requiredNative, /* @__PURE__ */ new Map(), minerFee, systemId);
|
|
32930
32977
|
assertTokenConservation(selection.selected, /* @__PURE__ */ new Map(), /* @__PURE__ */ new Map(), systemId, intent.label);
|
|
32931
32978
|
const txb = new import_utxo_lib.TransactionBuilder(verusNetwork);
|
|
32932
32979
|
txb.setVersion(4);
|
|
@@ -32983,12 +33030,9 @@ function assembleFundedIdentityUpdate(intent) {
|
|
|
32983
33030
|
}
|
|
32984
33031
|
);
|
|
32985
33032
|
const allUtxos = [...selection.selected, idUtxo];
|
|
32986
|
-
|
|
32987
|
-
|
|
32988
|
-
|
|
32989
|
-
selection.fee,
|
|
32990
|
-
intent.label
|
|
32991
|
-
);
|
|
33033
|
+
const completedOuts = import_utxo_lib.Transaction.fromHex(completedHex, verusNetwork).outs;
|
|
33034
|
+
assertNativeConservation(allUtxos, completedOuts, selection.fee, intent.label);
|
|
33035
|
+
assertFeeMeetsRelayMinimum(selection.fee, completedOuts.map((o) => o.script), intent.label);
|
|
32992
33036
|
const { signedTx, txid } = signTransactionSmart(completedHex, intent.wif, allUtxos, verusNetwork);
|
|
32993
33037
|
return {
|
|
32994
33038
|
signedTx,
|
|
@@ -33008,6 +33052,9 @@ __export(keys_exports, {
|
|
|
33008
33052
|
isCompressedWif: () => isCompressedWif,
|
|
33009
33053
|
privateKeyToPublicKey: () => privateKeyToPublicKey,
|
|
33010
33054
|
publicKeyToAddress: () => publicKeyToAddress,
|
|
33055
|
+
seedToAddress: () => seedToAddress,
|
|
33056
|
+
seedToPrivateKey: () => seedToPrivateKey,
|
|
33057
|
+
seedToWif: () => seedToWif,
|
|
33011
33058
|
validateAddress: () => validateAddress,
|
|
33012
33059
|
validateWif: () => validateWif,
|
|
33013
33060
|
wifToAddress: () => wifToAddress,
|
|
@@ -33085,6 +33132,43 @@ function generateWif(compressed = true) {
|
|
|
33085
33132
|
const payload = compressed ? Buffer.concat([Buffer.from([WIF_PREFIX]), privateKey, Buffer.from([1])]) : Buffer.concat([Buffer.from([WIF_PREFIX]), privateKey]);
|
|
33086
33133
|
return import_bs58check3.default.encode(payload);
|
|
33087
33134
|
}
|
|
33135
|
+
function seedBytes(seed) {
|
|
33136
|
+
if (typeof seed !== "string" || seed.trim().length === 0) {
|
|
33137
|
+
throw new InvalidSeedError("seed phrase is empty");
|
|
33138
|
+
}
|
|
33139
|
+
let isWif = false;
|
|
33140
|
+
try {
|
|
33141
|
+
import_bs58check3.default.decode(seed);
|
|
33142
|
+
isWif = true;
|
|
33143
|
+
} catch {
|
|
33144
|
+
}
|
|
33145
|
+
if (isWif) {
|
|
33146
|
+
throw new InvalidSeedError(
|
|
33147
|
+
"input is a WIF private key, not a seed phrase \u2014 use wifToPrivateKey / wifToAddress"
|
|
33148
|
+
);
|
|
33149
|
+
}
|
|
33150
|
+
const bytes = (0, import_create_hash.default)("sha256").update(Buffer.from(seed, "utf8")).digest();
|
|
33151
|
+
bytes.writeUInt8(bytes.readUInt8(0) & 248, 0);
|
|
33152
|
+
bytes.writeUInt8(bytes.readUInt8(31) & 127 | 64, 31);
|
|
33153
|
+
return bytes;
|
|
33154
|
+
}
|
|
33155
|
+
function seedToPrivateKey(seed) {
|
|
33156
|
+
return seedBytes(seed);
|
|
33157
|
+
}
|
|
33158
|
+
function seedToWif(seed) {
|
|
33159
|
+
const privateKey = seedBytes(seed);
|
|
33160
|
+
const payload = Buffer.concat([
|
|
33161
|
+
Buffer.from([WIF_PREFIX]),
|
|
33162
|
+
privateKey,
|
|
33163
|
+
Buffer.from([1])
|
|
33164
|
+
// Verus wallets always derive a compressed key here
|
|
33165
|
+
]);
|
|
33166
|
+
return import_bs58check3.default.encode(payload);
|
|
33167
|
+
}
|
|
33168
|
+
async function seedToAddress(seed) {
|
|
33169
|
+
const publicKey = await privateKeyToPublicKey(seedBytes(seed), true);
|
|
33170
|
+
return publicKeyToAddress(publicKey);
|
|
33171
|
+
}
|
|
33088
33172
|
function validateAddress(address2) {
|
|
33089
33173
|
try {
|
|
33090
33174
|
const decoded = import_bs58check3.default.decode(address2);
|
|
@@ -33563,9 +33647,6 @@ function _buildVrscRegistration(params, identityScript, reservationScript, ident
|
|
|
33563
33647
|
{ script: reservationScript, nativeSat: 0n }
|
|
33564
33648
|
],
|
|
33565
33649
|
changeAddress: params.changeAddress,
|
|
33566
|
-
// Legacy fee estimate: identity + referrals + reservation, plus the one extra
|
|
33567
|
-
// change slot the original path counted on top of selectUtxos' own reserve.
|
|
33568
|
-
feeOutputCount: 2 + referralOutputs.length + 1,
|
|
33569
33650
|
fee: {
|
|
33570
33651
|
policy: "declared",
|
|
33571
33652
|
burnSat: registrationOutlay - totalReferralPayments,
|
|
@@ -33629,10 +33710,6 @@ function _buildSubIdRegistration(params, identityScript, reservationScript, iden
|
|
|
33629
33710
|
{ script: reservationScript, nativeSat: 0n }
|
|
33630
33711
|
],
|
|
33631
33712
|
changeAddress: params.changeAddress,
|
|
33632
|
-
// Legacy fee estimate: identity + fee + reservation, plus the one extra change
|
|
33633
|
-
// slot the original path counted on top of selectUtxos' own reserve.
|
|
33634
|
-
feeOutputCount: 4,
|
|
33635
|
-
extraOutputBytes: identityScript.length + reservationScript.length + feeOutput.script.length,
|
|
33636
33713
|
fee: {
|
|
33637
33714
|
policy: "declared",
|
|
33638
33715
|
burnSat: nativeImportFee,
|
|
@@ -33807,10 +33884,6 @@ function buildAndSignIdentityUpdate(params, network, operation = "update", lockU
|
|
|
33807
33884
|
identityUtxo: params.identityUtxo,
|
|
33808
33885
|
outputs: unfundedTx.outs.map((o) => ({ script: o.script, nativeSat: BigInt(o.value) })),
|
|
33809
33886
|
changeAddress: params.changeAddress,
|
|
33810
|
-
// The identity output embeds the full serialized identity (a large
|
|
33811
|
-
// contentMultimap can make it multi-KB); size the fee from the unfunded tx's
|
|
33812
|
-
// real bytes so a big update isn't fee-estimated below the relay minimum.
|
|
33813
|
-
extraOutputBytes: unfundedHex.length / 2,
|
|
33814
33887
|
label: `identity ${operation}`
|
|
33815
33888
|
});
|
|
33816
33889
|
return {
|
|
@@ -33857,15 +33930,13 @@ function assembleAndSign(intent) {
|
|
|
33857
33930
|
for (const [c, v] of o.carries) requiredCurrencies.set(c, (requiredCurrencies.get(c) ?? 0n) + v);
|
|
33858
33931
|
}
|
|
33859
33932
|
}
|
|
33933
|
+
const minerFee = estimateMinerFee(intent.outputs.map((o) => o.script));
|
|
33860
33934
|
const selection = selectUtxos(
|
|
33861
33935
|
intent.funding,
|
|
33862
33936
|
requiredNative,
|
|
33863
33937
|
requiredCurrencies,
|
|
33864
|
-
|
|
33865
|
-
systemId
|
|
33866
|
-
void 0,
|
|
33867
|
-
intent.hasSmartOutputs ?? true,
|
|
33868
|
-
intent.extraOutputBytes ?? 0
|
|
33938
|
+
minerFee,
|
|
33939
|
+
systemId
|
|
33869
33940
|
);
|
|
33870
33941
|
const txb = new import_utxo_lib.TransactionBuilder(verusNetwork);
|
|
33871
33942
|
txb.setVersion(4);
|
|
@@ -33911,6 +33982,7 @@ function assembleAndSign(intent) {
|
|
|
33911
33982
|
const leadingNative = leading.reduce((sum, u) => sum + u.satoshis, 0n);
|
|
33912
33983
|
const expectedFee = selection.fee + burnSat + leadingNative;
|
|
33913
33984
|
assertNativeConservation(allUtxos, unsignedTx.outs, expectedFee, intent.label);
|
|
33985
|
+
assertFeeMeetsRelayMinimum(selection.fee, unsignedTx.outs.map((o) => o.script), intent.label);
|
|
33914
33986
|
const maxFeeSats = intent.fee.policy === "declared" ? expectedFee : void 0;
|
|
33915
33987
|
const { signedTx, txid } = signTransactionSmart(unsignedTx.toHex(), intent.wif, allUtxos, verusNetwork, maxFeeSats);
|
|
33916
33988
|
return {
|
|
@@ -34048,9 +34120,6 @@ function sendCurrency(params, network) {
|
|
|
34048
34120
|
expiryHeight
|
|
34049
34121
|
);
|
|
34050
34122
|
const unfundedTx = import_utxo_lib.Transaction.fromHex(unfundedTxHex, verusNetwork);
|
|
34051
|
-
const hasSmartOutputs = params.outputs.some(
|
|
34052
|
-
(o) => o.convertTo || o.exportTo || o.via || o.mintnew || o.burn || o.burnweight || o.currency !== systemId
|
|
34053
|
-
);
|
|
34054
34123
|
const requiredCurrencies = /* @__PURE__ */ new Map();
|
|
34055
34124
|
for (const out of params.outputs) {
|
|
34056
34125
|
if (out.currency !== systemId && !out.mintnew) {
|
|
@@ -34073,7 +34142,6 @@ function sendCurrency(params, network) {
|
|
|
34073
34142
|
funding: params.utxos,
|
|
34074
34143
|
outputs: unfundedTx.outs.map((o) => ({ script: o.script, nativeSat: BigInt(o.value) })),
|
|
34075
34144
|
changeAddress: params.changeAddress,
|
|
34076
|
-
hasSmartOutputs,
|
|
34077
34145
|
requiredCurrencies,
|
|
34078
34146
|
changeStrategy: "separate",
|
|
34079
34147
|
fee: { policy: "estimate" },
|
|
@@ -35076,7 +35144,6 @@ function buildCurrencyLaunchTransaction(params, network) {
|
|
|
35076
35144
|
script: Buffer.from(o.script, "hex"),
|
|
35077
35145
|
nativeSat: o.value
|
|
35078
35146
|
}));
|
|
35079
|
-
const extraOutputBytes = consensusOutputs.reduce((sum, o) => sum + o.script.length, 0);
|
|
35080
35147
|
const assembled = assembleFundedIdentityUpdate({
|
|
35081
35148
|
network,
|
|
35082
35149
|
wif: params.wif,
|
|
@@ -35088,7 +35155,6 @@ function buildCurrencyLaunchTransaction(params, network) {
|
|
|
35088
35155
|
identityUtxo: params.identityUtxo,
|
|
35089
35156
|
outputs: consensusOutputs,
|
|
35090
35157
|
changeAddress: params.changeAddress ?? identityAddress,
|
|
35091
|
-
extraOutputBytes,
|
|
35092
35158
|
label: "currency launch"
|
|
35093
35159
|
});
|
|
35094
35160
|
return {
|
|
@@ -35195,9 +35261,6 @@ function defineCurrency(params, network) {
|
|
|
35195
35261
|
{ script: currencyDefScript, nativeSat: currencyDefValue }
|
|
35196
35262
|
],
|
|
35197
35263
|
changeAddress: params.changeAddress,
|
|
35198
|
-
// The identity + currency-definition outputs can be large; size the fee from
|
|
35199
|
-
// their real byte length so the tx isn't estimated below the relay minimum.
|
|
35200
|
-
extraOutputBytes: identityOutputScript.length + currencyDefScript.length,
|
|
35201
35264
|
label: "currency definition"
|
|
35202
35265
|
});
|
|
35203
35266
|
return {
|
|
@@ -35389,16 +35452,8 @@ function completeOffer(params, network) {
|
|
|
35389
35452
|
}
|
|
35390
35453
|
const wantedTokenReq = wantingNative ? /* @__PURE__ */ new Map() : /* @__PURE__ */ new Map([[params.want.currency, params.want.amount]]);
|
|
35391
35454
|
const requiredNative = wantingNative ? params.want.amount : 0n;
|
|
35392
|
-
const
|
|
35393
|
-
|
|
35394
|
-
requiredNative,
|
|
35395
|
-
wantedTokenReq,
|
|
35396
|
-
3,
|
|
35397
|
-
systemId,
|
|
35398
|
-
void 0,
|
|
35399
|
-
true,
|
|
35400
|
-
150
|
|
35401
|
-
);
|
|
35455
|
+
const minerFee = estimateMinerFee(tx.outs.map((o) => o.script));
|
|
35456
|
+
const selection = selectUtxos(params.takerUtxos, requiredNative, wantedTokenReq, minerFee, systemId);
|
|
35402
35457
|
const takerInputs = [];
|
|
35403
35458
|
for (const u of selection.selected) {
|
|
35404
35459
|
const idx = tx.addInput(Buffer.from(u.txid, "hex").reverse(), u.outputIndex, 4294967295);
|
|
@@ -35423,6 +35478,7 @@ function completeOffer(params, network) {
|
|
|
35423
35478
|
const takerNativeIn = selection.selected.reduce((s, u) => s + u.satoshis, 0n);
|
|
35424
35479
|
const allInputsNative = commitmentNative + takerNativeIn;
|
|
35425
35480
|
assertNativeConservation([{ satoshis: allInputsNative }], tx.outs, selection.fee, "takeOffer");
|
|
35481
|
+
assertFeeMeetsRelayMinimum(selection.fee, tx.outs.map((o) => o.script), "takeOffer");
|
|
35426
35482
|
const { signedTx, txid } = signTakerInputs(tx.toHex(), takerInputs, params.wif, network);
|
|
35427
35483
|
return { swapTx: signedTx, txid };
|
|
35428
35484
|
}
|
|
@@ -35453,19 +35509,21 @@ function buildReclaimOffer(params, network) {
|
|
|
35453
35509
|
commitmentScript
|
|
35454
35510
|
);
|
|
35455
35511
|
if (offeringNative) {
|
|
35456
|
-
const
|
|
35512
|
+
const payScript = nativePaymentScript2(params.makerAddress);
|
|
35513
|
+
const fee = estimateMinerFee([payScript]);
|
|
35457
35514
|
const outAmount = params.offered.amount - fee;
|
|
35458
35515
|
if (outAmount <= DUST_THRESHOLD) {
|
|
35459
35516
|
throw new TransactionBuildError(
|
|
35460
35517
|
`buildReclaimOffer: reclaimed native value ${params.offered.amount} is too small to cover the fee ${fee} above dust`
|
|
35461
35518
|
);
|
|
35462
35519
|
}
|
|
35463
|
-
txb.addOutput(
|
|
35520
|
+
txb.addOutput(payScript, toSafeNumber(outAmount));
|
|
35464
35521
|
const tx2 = import_utxo_lib.Transaction.fromHex(txb.buildIncomplete().toHex(), verusNetwork);
|
|
35465
35522
|
const takerInputs2 = [
|
|
35466
35523
|
{ index: 0, prevOutScript: commitmentScript, value: params.commitment.value }
|
|
35467
35524
|
];
|
|
35468
35525
|
assertNativeConservation([{ satoshis: params.commitment.value }], tx2.outs, fee, "reclaimOffer");
|
|
35526
|
+
assertFeeMeetsRelayMinimum(fee, tx2.outs.map((o) => o.script), "reclaimOffer");
|
|
35469
35527
|
const { signedTx: signedTx2, txid: txid2 } = signTakerInputs(tx2.toHex(), takerInputs2, params.wif, network);
|
|
35470
35528
|
return { reclaimTx: signedTx2, txid: txid2 };
|
|
35471
35529
|
}
|
|
@@ -35484,7 +35542,8 @@ function buildReclaimOffer(params, network) {
|
|
|
35484
35542
|
const takerInputs = [
|
|
35485
35543
|
{ index: 0, prevOutScript: commitmentScript, value: 0n }
|
|
35486
35544
|
];
|
|
35487
|
-
const
|
|
35545
|
+
const minerFee = estimateMinerFee([tokenOut.script]);
|
|
35546
|
+
const selection = selectUtxos(feeUtxos, 0n, /* @__PURE__ */ new Map(), minerFee, systemId);
|
|
35488
35547
|
if (selection.currencyChanges.size > 0) {
|
|
35489
35548
|
throw new TransactionBuildError(
|
|
35490
35549
|
"buildReclaimOffer: feeUtxos must carry only the native coin; a token-bearing UTXO was selected and its reserve value would be lost."
|
|
@@ -35507,6 +35566,7 @@ function buildReclaimOffer(params, network) {
|
|
|
35507
35566
|
}
|
|
35508
35567
|
const feeNativeIn = selection.selected.reduce((s, u) => s + u.satoshis, 0n);
|
|
35509
35568
|
assertNativeConservation([{ satoshis: feeNativeIn }], tx.outs, selection.fee, "reclaimOffer");
|
|
35569
|
+
assertFeeMeetsRelayMinimum(selection.fee, tx.outs.map((o) => o.script), "reclaimOffer");
|
|
35510
35570
|
const { signedTx, txid } = signTakerInputs(tx.toHex(), takerInputs, params.wif, network);
|
|
35511
35571
|
return { reclaimTx: signedTx, txid };
|
|
35512
35572
|
}
|
|
@@ -35530,7 +35590,8 @@ function assertExpiryHeight(expiryHeight) {
|
|
|
35530
35590
|
function fundFeeAndSignIdentityTaker(args) {
|
|
35531
35591
|
const systemId = NETWORK_CONFIG[args.network].chainId;
|
|
35532
35592
|
const verusNetwork = getNetwork(args.network === "testnet");
|
|
35533
|
-
const
|
|
35593
|
+
const minerFee = estimateMinerFee(args.tx.outs.map((o) => o.script));
|
|
35594
|
+
const selection = selectUtxos(args.takerUtxos, 0n, /* @__PURE__ */ new Map(), minerFee, systemId);
|
|
35534
35595
|
if (selection.currencyChanges.size > 0) {
|
|
35535
35596
|
throw new TransactionBuildError(
|
|
35536
35597
|
`${args.label}: the fee UTXOs must carry only the native coin; a token-bearing UTXO was selected and its reserve value would be lost.`
|
|
@@ -35559,6 +35620,7 @@ function fundFeeAndSignIdentityTaker(args) {
|
|
|
35559
35620
|
selection.fee,
|
|
35560
35621
|
args.label
|
|
35561
35622
|
);
|
|
35623
|
+
assertFeeMeetsRelayMinimum(selection.fee, args.tx.outs.map((o) => o.script), args.label);
|
|
35562
35624
|
const { signedTx, txid } = signTakerInputs(args.tx.toHex(), takerInputs, args.wif, args.network);
|
|
35563
35625
|
return { swapTx: signedTx, txid };
|
|
35564
35626
|
}
|
|
@@ -35589,16 +35651,8 @@ function completeSellIdentityOffer(params, network) {
|
|
|
35589
35651
|
tx.addOutput(buildTransferredIdentity(params.identityJson, params.newPrimaryAddresses), 0);
|
|
35590
35652
|
const wantedTokenReq = wantingNative ? /* @__PURE__ */ new Map() : /* @__PURE__ */ new Map([[params.want.currency, params.want.amount]]);
|
|
35591
35653
|
const requiredNative = wantingNative ? params.want.amount : 0n;
|
|
35592
|
-
const
|
|
35593
|
-
|
|
35594
|
-
requiredNative,
|
|
35595
|
-
wantedTokenReq,
|
|
35596
|
-
3,
|
|
35597
|
-
systemId,
|
|
35598
|
-
void 0,
|
|
35599
|
-
true,
|
|
35600
|
-
150
|
|
35601
|
-
);
|
|
35654
|
+
const minerFee = estimateMinerFee(tx.outs.map((o) => o.script));
|
|
35655
|
+
const selection = selectUtxos(params.takerUtxos, requiredNative, wantedTokenReq, minerFee, systemId);
|
|
35602
35656
|
const takerInputs = [];
|
|
35603
35657
|
for (const u of selection.selected) {
|
|
35604
35658
|
const idx = tx.addInput(Buffer.from(u.txid, "hex").reverse(), u.outputIndex, 4294967295);
|
|
@@ -35616,6 +35670,7 @@ function completeSellIdentityOffer(params, network) {
|
|
|
35616
35670
|
assertTokenConservation(selection.selected, wantedTokenReq, selection.currencyChanges, systemId, "takeSellIdentityOffer");
|
|
35617
35671
|
const takerNativeIn = selection.selected.reduce((s, u) => s + u.satoshis, 0n);
|
|
35618
35672
|
assertNativeConservation([{ satoshis: takerNativeIn }], tx.outs, selection.fee, "takeSellIdentityOffer");
|
|
35673
|
+
assertFeeMeetsRelayMinimum(selection.fee, tx.outs.map((o) => o.script), "takeSellIdentityOffer");
|
|
35619
35674
|
const { signedTx, txid } = signTakerInputs(tx.toHex(), takerInputs, params.wif, network);
|
|
35620
35675
|
return { swapTx: signedTx, txid };
|
|
35621
35676
|
}
|
|
@@ -35684,8 +35739,7 @@ function completeBuyIdentityOffer(params, network) {
|
|
|
35684
35739
|
changeAddress: params.changeAddress,
|
|
35685
35740
|
wif: params.wif,
|
|
35686
35741
|
network,
|
|
35687
|
-
label: "takeBuyIdentityOffer"
|
|
35688
|
-
extraOutputBytes: 300
|
|
35742
|
+
label: "takeBuyIdentityOffer"
|
|
35689
35743
|
});
|
|
35690
35744
|
}
|
|
35691
35745
|
function buildSwapIdentityOffer(params, network) {
|
|
@@ -35735,8 +35789,7 @@ function completeSwapIdentityOffer(params, network) {
|
|
|
35735
35789
|
changeAddress: params.changeAddress,
|
|
35736
35790
|
wif: params.wif,
|
|
35737
35791
|
network,
|
|
35738
|
-
label: "takeSwapIdentityOffer"
|
|
35739
|
-
extraOutputBytes: 500
|
|
35792
|
+
label: "takeSwapIdentityOffer"
|
|
35740
35793
|
});
|
|
35741
35794
|
}
|
|
35742
35795
|
|
|
@@ -35772,7 +35825,8 @@ function buildMultisigIdentityUpdate(params, network) {
|
|
|
35772
35825
|
throw new TransactionBuildError("buildMultisigIdentityUpdate: funding must include native UTXOs for the fee");
|
|
35773
35826
|
}
|
|
35774
35827
|
const newIdScript = buildIdentityScript(boundary_exports.Identity.fromJson(params.newIdentity));
|
|
35775
|
-
const
|
|
35828
|
+
const minerFee = estimateMinerFee([newIdScript]);
|
|
35829
|
+
const selection = selectUtxos(params.funding, 0n, /* @__PURE__ */ new Map(), minerFee, systemId);
|
|
35776
35830
|
if (selection.currencyChanges.size > 0) {
|
|
35777
35831
|
throw new TransactionBuildError(
|
|
35778
35832
|
"buildMultisigIdentityUpdate: funding must carry only the native coin; a token-bearing UTXO was selected and its reserve value would be lost."
|
|
@@ -35810,6 +35864,7 @@ function buildMultisigIdentityUpdate(params, network) {
|
|
|
35810
35864
|
const tx = import_utxo_lib.Transaction.fromHex(completedHex, verusNetwork);
|
|
35811
35865
|
const funderNativeIn = selection.selected.reduce((s, u) => s + u.satoshis, 0n);
|
|
35812
35866
|
assertNativeConservation([{ satoshis: funderNativeIn }], tx.outs, selection.fee, "multisigIdentityUpdate");
|
|
35867
|
+
assertFeeMeetsRelayMinimum(selection.fee, tx.outs.map((o) => o.script), "multisigIdentityUpdate");
|
|
35813
35868
|
const funderKey = import_utxo_lib.ECPair.fromWIF(params.funderWif, verusNetwork);
|
|
35814
35869
|
for (let i = 0; i < selection.selected.length; i++) {
|
|
35815
35870
|
const u = selection.selected[i];
|
|
@@ -36113,6 +36168,17 @@ var VerusSDK = class {
|
|
|
36113
36168
|
static generateWif() {
|
|
36114
36169
|
return generateWif();
|
|
36115
36170
|
}
|
|
36171
|
+
/**
|
|
36172
|
+
* Derive the WIF a Verus Mobile / Verus Desktop seed phrase maps to.
|
|
36173
|
+
* One seed = one key: Verus wallets are not HD. See docs/seeds.md.
|
|
36174
|
+
*/
|
|
36175
|
+
static seedToWif(seed) {
|
|
36176
|
+
return seedToWif(seed);
|
|
36177
|
+
}
|
|
36178
|
+
/** Derive the R-address a Verus Mobile / Verus Desktop seed phrase maps to */
|
|
36179
|
+
static async deriveAddressFromSeed(seed) {
|
|
36180
|
+
return seedToAddress(seed);
|
|
36181
|
+
}
|
|
36116
36182
|
/** Validate a Verus R-address */
|
|
36117
36183
|
static validateAddress(address2) {
|
|
36118
36184
|
return validateAddress(address2);
|
|
@@ -36167,9 +36233,9 @@ __export(public_exports2, {
|
|
|
36167
36233
|
CURRENCY_OPTION,
|
|
36168
36234
|
CURRENCY_TYPE_ORDER,
|
|
36169
36235
|
DEFAULT_EXPIRY_DELTA,
|
|
36170
|
-
DEFAULT_FEE_PER_KB,
|
|
36171
36236
|
DEFAULT_REFERRAL_LEVELS,
|
|
36172
36237
|
DEFAULT_REGISTRATION_FEE,
|
|
36238
|
+
DEFAULT_TRANSACTION_FEE,
|
|
36173
36239
|
DUST_THRESHOLD,
|
|
36174
36240
|
HASH_SHA256,
|
|
36175
36241
|
IDENTITY_FLAG_ACTIVECURRENCY,
|
|
@@ -36179,7 +36245,9 @@ __export(public_exports2, {
|
|
|
36179
36245
|
InvalidAddressError,
|
|
36180
36246
|
InvalidAmountError,
|
|
36181
36247
|
InvalidNameError,
|
|
36248
|
+
InvalidSeedError,
|
|
36182
36249
|
InvalidWifError,
|
|
36250
|
+
LARGE_SCRIPT_FEE_THRESHOLD,
|
|
36183
36251
|
NETWORK_CONFIG,
|
|
36184
36252
|
NOTARIZATION_PROTOCOL,
|
|
36185
36253
|
PROOF_PROTOCOL,
|
|
@@ -36194,12 +36262,16 @@ __export(public_exports2, {
|
|
|
36194
36262
|
VerusSDK,
|
|
36195
36263
|
WIF_PREFIX,
|
|
36196
36264
|
address,
|
|
36265
|
+
assertFeeMeetsRelayMinimum,
|
|
36197
36266
|
buildCurrencyDefinitionScript,
|
|
36198
36267
|
buildCurrencyLaunchOutputs,
|
|
36199
36268
|
buildCurrencyLaunchTransaction,
|
|
36200
36269
|
buildReserveTransferOutput,
|
|
36201
36270
|
classifyCurrency,
|
|
36271
|
+
computeIdentityFeeFactor,
|
|
36202
36272
|
currency,
|
|
36273
|
+
estimateMinerFee,
|
|
36274
|
+
fee,
|
|
36203
36275
|
identity,
|
|
36204
36276
|
identityMultisig,
|
|
36205
36277
|
isIAddress,
|
|
@@ -36210,6 +36282,7 @@ __export(public_exports2, {
|
|
|
36210
36282
|
message,
|
|
36211
36283
|
offers,
|
|
36212
36284
|
parseSats,
|
|
36285
|
+
relayMinimumFee,
|
|
36213
36286
|
serializeCurrencyDefinition,
|
|
36214
36287
|
signing,
|
|
36215
36288
|
toCoins,
|