@chainvue/verus-sdk 0.11.0 → 0.13.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/README.md +4 -2
- package/dist/VerusSDK.d.ts +16 -1
- package/dist/VerusSDK.d.ts.map +1 -1
- package/dist/VerusSDK.js +21 -0
- package/dist/VerusSDK.js.map +1 -1
- package/dist/bundle.js +261 -18
- package/dist/identity/index.js +3 -3
- package/dist/identity/index.js.map +1 -1
- package/dist/identity/multisig.d.ts +101 -0
- package/dist/identity/multisig.d.ts.map +1 -0
- package/dist/identity/multisig.js +176 -0
- package/dist/identity/multisig.js.map +1 -0
- package/dist/index.d.ts +3 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +3 -1
- package/dist/index.js.map +1 -1
- package/dist/offers/identity.d.ts.map +1 -1
- package/dist/offers/identity.js +7 -4
- package/dist/offers/identity.js.map +1 -1
- package/dist/offers/public.d.ts +2 -0
- package/dist/offers/public.d.ts.map +1 -1
- package/dist/offers/public.js +4 -1
- package/dist/offers/public.js.map +1 -1
- package/dist/offers/reclaim.d.ts +39 -0
- package/dist/offers/reclaim.d.ts.map +1 -0
- package/dist/offers/reclaim.js +112 -0
- package/dist/offers/reclaim.js.map +1 -0
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -34,11 +34,13 @@ const { signedTx, txid, fee } = sdk.transfer({
|
|
|
34
34
|
(full control over multi-output / cross-chain sends).
|
|
35
35
|
- **VerusID** — `createCommitment` → `registerIdentity` (incl. sub-IDs), then
|
|
36
36
|
`updateIdentity` / `lockIdentity` / `unlockIdentity` / `revokeIdentity` /
|
|
37
|
-
`recoverIdentity`, plus `signMessage` / `verifyMessage`.
|
|
37
|
+
`recoverIdentity`, plus `signMessage` / `verifyMessage`. Multisig (m-of-n)
|
|
38
|
+
identities update via `buildMultisigIdentityUpdate` + `addIdentitySignature`.
|
|
38
39
|
- **Marketplace offers** — build and complete fully on-chain atomic swaps:
|
|
39
40
|
currency↔currency (`buildOfferFunding` → `buildOffer` → `completeOffer`), and
|
|
40
41
|
VerusID sell / buy / swap (`build*IdentityOffer` / `complete*IdentityOffer`).
|
|
41
|
-
Native coin, tokens, and identities, in every combination
|
|
42
|
+
Native coin, tokens, and identities, in every combination — plus
|
|
43
|
+
`buildReclaimOffer` to cancel an unaccepted offer and reclaim the funds.
|
|
42
44
|
- **Helpers** — `VerusSDK.generateWif()`, `deriveAddress(wif)`,
|
|
43
45
|
`deriveIdentityAddress(name, parent?)`, `validateAddress`, `validateWif`;
|
|
44
46
|
`utils.summarizeSignedTransaction(hex)` decodes a signed tx (txid, spent
|
package/dist/VerusSDK.d.ts
CHANGED
|
@@ -6,7 +6,8 @@
|
|
|
6
6
|
*/
|
|
7
7
|
import type { Network } from './constants/index.js';
|
|
8
8
|
import type { VerusSDKConfig, TransferParams, TransferTokenParams, ConvertParams, SendCurrencyParams, SendCurrencyResult, BuildAndSignParams, SignedTxResult, CreateCommitmentParams, CreateCommitmentResult, RegisterIdentityParams, RegisterIdentityResult, UpdateIdentityParams, UpdateIdentityResult, LockIdentityParams, UnlockIdentityParams, RevokeIdentityParams, RecoverIdentityParams, DefineCurrencyParams, DefineCurrencyResult, SignMessageParams, SignMessageResult, VerifyMessageParams, VerifyMessageResult } from './types/index.js';
|
|
9
|
-
import type { BuildOfferFundingParams, BuildOfferFundingResult, BuildOfferParams, BuildOfferResult, CompleteOfferParams, CompleteOfferResult, BuildSellIdentityOfferParams, CompleteSellIdentityOfferParams, CompleteSellIdentityOfferResult, BuildBuyIdentityOfferParams, CompleteBuyIdentityOfferParams, CompleteBuyIdentityOfferResult, BuildSwapIdentityOfferParams, CompleteSwapIdentityOfferParams, CompleteSwapIdentityOfferResult } from './offers/public.js';
|
|
9
|
+
import type { BuildOfferFundingParams, BuildOfferFundingResult, BuildOfferParams, BuildOfferResult, CompleteOfferParams, CompleteOfferResult, ReclaimOfferParams, ReclaimOfferResult, BuildSellIdentityOfferParams, CompleteSellIdentityOfferParams, CompleteSellIdentityOfferResult, BuildBuyIdentityOfferParams, CompleteBuyIdentityOfferParams, CompleteBuyIdentityOfferResult, BuildSwapIdentityOfferParams, CompleteSwapIdentityOfferParams, CompleteSwapIdentityOfferResult } from './offers/public.js';
|
|
10
|
+
import type { MultisigIdentityUpdateParams, MultisigIdentityUpdateResult, AddIdentitySignatureParams, AddIdentitySignatureResult } from './identity/multisig.js';
|
|
10
11
|
export declare class VerusSDK {
|
|
11
12
|
readonly network: Network;
|
|
12
13
|
constructor(config: VerusSDKConfig);
|
|
@@ -35,6 +36,14 @@ export declare class VerusSDK {
|
|
|
35
36
|
unlockIdentity(params: UnlockIdentityParams): UpdateIdentityResult;
|
|
36
37
|
/** Revoke an identity (requires revocation authority key) */
|
|
37
38
|
revokeIdentity(params: RevokeIdentityParams): UpdateIdentityResult;
|
|
39
|
+
/**
|
|
40
|
+
* Build the funded half of an m-of-n (multisig) identity update: funding inputs
|
|
41
|
+
* signed by the funder, the identity CC input left open. Pass the result to
|
|
42
|
+
* `addIdentitySignature` for each authority until `minSignatures` are collected.
|
|
43
|
+
*/
|
|
44
|
+
buildMultisigIdentityUpdate(params: MultisigIdentityUpdateParams): MultisigIdentityUpdateResult;
|
|
45
|
+
/** Add one authority signature to a multisig identity update (see buildMultisigIdentityUpdate). */
|
|
46
|
+
addIdentitySignature(params: AddIdentitySignatureParams): AddIdentitySignatureResult;
|
|
38
47
|
/** Recover an identity (requires recovery authority key) */
|
|
39
48
|
recoverIdentity(params: RecoverIdentityParams): UpdateIdentityResult;
|
|
40
49
|
/** Define a new currency (manual mode — pre-built script) */
|
|
@@ -58,6 +67,12 @@ export declare class VerusSDK {
|
|
|
58
67
|
* receive the offered asset, and sign the taker's side into an atomic swap.
|
|
59
68
|
*/
|
|
60
69
|
completeOffer(params: CompleteOfferParams): CompleteOfferResult;
|
|
70
|
+
/**
|
|
71
|
+
* Maker: cancel an unaccepted offer — spend the funding commitment back to the
|
|
72
|
+
* maker (SIGHASH_ALL). Native: the fee comes out of the reclaimed value; token:
|
|
73
|
+
* pass native `feeUtxos` controlled by the same key.
|
|
74
|
+
*/
|
|
75
|
+
buildReclaimOffer(params: ReclaimOfferParams): ReclaimOfferResult;
|
|
61
76
|
/** Maker: offer a VerusID for a currency (spends the identity's on-chain output). */
|
|
62
77
|
buildSellIdentityOffer(params: BuildSellIdentityOfferParams): BuildOfferResult;
|
|
63
78
|
/** Taker: complete a sell-identity offer — pay the currency, receive the identity. */
|
package/dist/VerusSDK.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"VerusSDK.d.ts","sourceRoot":"","sources":["../src/VerusSDK.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,sBAAsB,CAAC;AACpD,OAAO,KAAK,EACV,cAAc,EACd,cAAc,EACd,mBAAmB,EACnB,aAAa,EACb,kBAAkB,EAClB,kBAAkB,EAClB,kBAAkB,EAClB,cAAc,EACd,sBAAsB,EACtB,sBAAsB,EACtB,sBAAsB,EACtB,sBAAsB,EACtB,oBAAoB,EACpB,oBAAoB,EACpB,kBAAkB,EAClB,oBAAoB,EACpB,oBAAoB,EACpB,qBAAqB,EACrB,oBAAoB,EACpB,oBAAoB,EACpB,iBAAiB,EACjB,iBAAiB,EACjB,mBAAmB,EACnB,mBAAmB,EACpB,MAAM,kBAAkB,CAAC;AAE1B,OAAO,KAAK,EACV,uBAAuB,EACvB,uBAAuB,EACvB,gBAAgB,EAChB,gBAAgB,EAChB,mBAAmB,EACnB,mBAAmB,EACnB,4BAA4B,EAC5B,+BAA+B,EAC/B,+BAA+B,EAC/B,2BAA2B,EAC3B,8BAA8B,EAC9B,8BAA8B,EAC9B,4BAA4B,EAC5B,+BAA+B,EAC/B,+BAA+B,EAChC,MAAM,oBAAoB,CAAC;AAS5B,qBAAa,QAAQ;IACnB,QAAQ,CAAC,OAAO,EAAE,OAAO,CAAC;gBAEd,MAAM,EAAE,cA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CAAC,MAAM,EAAE,8BAA8B,GAAG,8BAA8B;IAIhG,sEAAsE;IACtE,sBAAsB,CAAC,MAAM,EAAE,4BAA4B,GAAG,gBAAgB;IAI9E,8FAA8F;IAC9F,yBAAyB,CAAC,MAAM,EAAE,+BAA+B,GAAG,+BAA+B;IAMnG,4CAA4C;WAC/B,aAAa,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC;IAIxD,gEAAgE;IAChE,MAAM,CAAC,qBAAqB,CAAC,IAAI,EAAE,MAAM,EAAE,cAAc,CAAC,EAAE,MAAM,GAAG,MAAM;IAI3E,4CAA4C;IAC5C,MAAM,CAAC,WAAW,IAAI,MAAM;IAI5B,iCAAiC;IACjC,MAAM,CAAC,eAAe,CAAC,OAAO,EAAE,MAAM,GAAG;QAAE,KAAK,EAAE,OAAO,CAAC;QAAC,KAAK,CAAC,EAAE,MAAM,CAAA;KAAE;IAI3E,iCAAiC;IACjC,MAAM,CAAC,WAAW,CAAC,GAAG,EAAE,MAAM,GAAG;QAAE,KAAK,EAAE,OAAO,CAAC;QAAC,KAAK,CAAC,EAAE,MAAM,CAAA;KAAE;CAGpE"}
|
package/dist/VerusSDK.js
CHANGED
|
@@ -46,6 +46,7 @@ const messageModule = __importStar(require("./message/index.js"));
|
|
|
46
46
|
const currencyModule = __importStar(require("./currency/index.js"));
|
|
47
47
|
const keysModule = __importStar(require("./keys/index.js"));
|
|
48
48
|
const offersModule = __importStar(require("./offers/public.js"));
|
|
49
|
+
const multisigModule = __importStar(require("./identity/multisig.js"));
|
|
49
50
|
class VerusSDK {
|
|
50
51
|
constructor(config) {
|
|
51
52
|
this.network = config.network;
|
|
@@ -120,6 +121,18 @@ class VerusSDK {
|
|
|
120
121
|
expiryHeight: params.expiryHeight,
|
|
121
122
|
}, this.network, 'revoke');
|
|
122
123
|
}
|
|
124
|
+
/**
|
|
125
|
+
* Build the funded half of an m-of-n (multisig) identity update: funding inputs
|
|
126
|
+
* signed by the funder, the identity CC input left open. Pass the result to
|
|
127
|
+
* `addIdentitySignature` for each authority until `minSignatures` are collected.
|
|
128
|
+
*/
|
|
129
|
+
buildMultisigIdentityUpdate(params) {
|
|
130
|
+
return multisigModule.buildMultisigIdentityUpdate(params, this.network);
|
|
131
|
+
}
|
|
132
|
+
/** Add one authority signature to a multisig identity update (see buildMultisigIdentityUpdate). */
|
|
133
|
+
addIdentitySignature(params) {
|
|
134
|
+
return multisigModule.addIdentitySignature(params, this.network);
|
|
135
|
+
}
|
|
123
136
|
/** Recover an identity (requires recovery authority key) */
|
|
124
137
|
recoverIdentity(params) {
|
|
125
138
|
return identityModule.buildAndSignIdentityUpdate({
|
|
@@ -171,6 +184,14 @@ class VerusSDK {
|
|
|
171
184
|
completeOffer(params) {
|
|
172
185
|
return offersModule.completeOffer(params, this.network);
|
|
173
186
|
}
|
|
187
|
+
/**
|
|
188
|
+
* Maker: cancel an unaccepted offer — spend the funding commitment back to the
|
|
189
|
+
* maker (SIGHASH_ALL). Native: the fee comes out of the reclaimed value; token:
|
|
190
|
+
* pass native `feeUtxos` controlled by the same key.
|
|
191
|
+
*/
|
|
192
|
+
buildReclaimOffer(params) {
|
|
193
|
+
return offersModule.buildReclaimOffer(params, this.network);
|
|
194
|
+
}
|
|
174
195
|
/** Maker: offer a VerusID for a currency (spends the identity's on-chain output). */
|
|
175
196
|
buildSellIdentityOffer(params) {
|
|
176
197
|
return offersModule.buildSellIdentityOffer(params, this.network);
|
package/dist/VerusSDK.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"VerusSDK.js","sourceRoot":"","sources":["../src/VerusSDK.ts"],"names":[],"mappings":";AAAA;;;;;GAKG;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
|
1
|
+
{"version":3,"file":"VerusSDK.js","sourceRoot":"","sources":["../src/VerusSDK.ts"],"names":[],"mappings":";AAAA;;;;;GAKG;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAkDH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
|
|
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 Identity5 = 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 = Identity5;
|
|
9963
|
+
Identity5.VERSION_INVALID = new bn_js_1.BN(0);
|
|
9964
|
+
Identity5.VERSION_VERUSID = new bn_js_1.BN(1);
|
|
9965
|
+
Identity5.VERSION_VAULT = new bn_js_1.BN(2);
|
|
9966
|
+
Identity5.VERSION_PBAAS = new bn_js_1.BN(3);
|
|
9967
|
+
Identity5.VERSION_CURRENT = Identity5.VERSION_PBAAS;
|
|
9968
|
+
Identity5.VERSION_FIRSTVALID = new bn_js_1.BN(1);
|
|
9969
|
+
Identity5.VERSION_LASTVALID = new bn_js_1.BN(3);
|
|
9970
9970
|
}
|
|
9971
9971
|
});
|
|
9972
9972
|
|
|
@@ -32147,12 +32147,12 @@ var require_smart_transactions = __commonJS({
|
|
|
32147
32147
|
return txb.buildIncomplete().toHex();
|
|
32148
32148
|
};
|
|
32149
32149
|
exports2.createUnfundedIdentityUpdate = createUnfundedIdentityUpdate2;
|
|
32150
|
-
var
|
|
32150
|
+
var completeFundedIdentityUpdate3 = function(fundedTxHex, network, prevOutScripts, prevIdentityOutput) {
|
|
32151
32151
|
var txb = (0, exports2.getFundedTxBuilder)(fundedTxHex, network, prevOutScripts);
|
|
32152
32152
|
txb.addInput(prevIdentityOutput.hash, prevIdentityOutput.index, prevIdentityOutput.sequence, prevIdentityOutput.script);
|
|
32153
32153
|
return txb.buildIncomplete().toHex();
|
|
32154
32154
|
};
|
|
32155
|
-
exports2.completeFundedIdentityUpdate =
|
|
32155
|
+
exports2.completeFundedIdentityUpdate = completeFundedIdentityUpdate3;
|
|
32156
32156
|
var getFundedTxBuilder2 = function(fundedTxHex, network, prevOutScripts) {
|
|
32157
32157
|
var tx = Transaction2.fromHex(fundedTxHex, network);
|
|
32158
32158
|
var inputs = tx.ins;
|
|
@@ -32243,6 +32243,7 @@ __export(src_exports, {
|
|
|
32243
32243
|
classifyCurrency: () => classifyCurrency,
|
|
32244
32244
|
currency: () => currency_exports,
|
|
32245
32245
|
identity: () => public_exports2,
|
|
32246
|
+
identityMultisig: () => multisig_exports,
|
|
32246
32247
|
isIAddress: () => isIAddress2,
|
|
32247
32248
|
isIdentityName: () => isIdentityName,
|
|
32248
32249
|
isRAddress: () => isRAddress2,
|
|
@@ -33671,7 +33672,7 @@ function buildAndSignIdentityUpdate(params, network, operation = "update", lockU
|
|
|
33671
33672
|
const currentMinSigs = identity.min_sigs?.toNumber?.() ?? 1;
|
|
33672
33673
|
if (currentMinSigs > 1) {
|
|
33673
33674
|
throw new TransactionBuildError(
|
|
33674
|
-
`this identity requires ${currentMinSigs} signatures (min_sigs > 1);
|
|
33675
|
+
`this identity requires ${currentMinSigs} signatures (min_sigs > 1); this single-key path signs with one WIF. Use the multisig flow (buildMultisigIdentityUpdate + addIdentitySignature, the \`identityMultisig\` namespace) to collect m-of-n signatures for a ${operation}.`
|
|
33675
33676
|
);
|
|
33676
33677
|
}
|
|
33677
33678
|
}
|
|
@@ -34370,6 +34371,7 @@ __export(public_exports, {
|
|
|
34370
34371
|
buildBuyIdentityOffer: () => buildBuyIdentityOffer,
|
|
34371
34372
|
buildOffer: () => buildOffer,
|
|
34372
34373
|
buildOfferFunding: () => buildOfferFunding,
|
|
34374
|
+
buildReclaimOffer: () => buildReclaimOffer,
|
|
34373
34375
|
buildSellIdentityOffer: () => buildSellIdentityOffer,
|
|
34374
34376
|
buildSwapIdentityOffer: () => buildSwapIdentityOffer,
|
|
34375
34377
|
completeBuyIdentityOffer: () => completeBuyIdentityOffer,
|
|
@@ -34580,10 +34582,94 @@ function completeOffer(params, network) {
|
|
|
34580
34582
|
return { swapTx: signedTx, txid };
|
|
34581
34583
|
}
|
|
34582
34584
|
|
|
34583
|
-
// src/offers/
|
|
34585
|
+
// src/offers/reclaim.ts
|
|
34584
34586
|
function nativePaymentScript2(address2) {
|
|
34585
34587
|
return address2.startsWith("i") ? identityPaymentScript(parseIAddress(address2, "address")) : addressToScriptPubKey(address2);
|
|
34586
34588
|
}
|
|
34589
|
+
function buildReclaimOffer(params, network) {
|
|
34590
|
+
const verusNetwork = getNetwork(network === "testnet");
|
|
34591
|
+
const systemId = NETWORK_CONFIG[network].chainId;
|
|
34592
|
+
const offeringNative = params.offered.currency === systemId;
|
|
34593
|
+
if (params.offered.amount <= 0n) {
|
|
34594
|
+
throw new TransactionBuildError("buildReclaimOffer: offered.amount must be positive");
|
|
34595
|
+
}
|
|
34596
|
+
if (!Number.isInteger(params.expiryHeight) || params.expiryHeight <= 0) {
|
|
34597
|
+
throw new TransactionBuildError("buildReclaimOffer: expiryHeight must be a positive block height");
|
|
34598
|
+
}
|
|
34599
|
+
const commitmentScript = Buffer.from(params.commitment.script, "hex");
|
|
34600
|
+
const txb = new import_utxo_lib.TransactionBuilder(verusNetwork);
|
|
34601
|
+
txb.setVersion(4);
|
|
34602
|
+
txb.setExpiryHeight(resolveExpiryHeight(params.expiryHeight));
|
|
34603
|
+
txb.setVersionGroupId(VERSION_GROUP_ID);
|
|
34604
|
+
txb.addInput(
|
|
34605
|
+
Buffer.from(params.commitment.txid, "hex").reverse(),
|
|
34606
|
+
params.commitment.vout,
|
|
34607
|
+
4294967295,
|
|
34608
|
+
commitmentScript
|
|
34609
|
+
);
|
|
34610
|
+
if (offeringNative) {
|
|
34611
|
+
const fee = estimateFee(1, 1, DEFAULT_FEE_PER_KB, false, 100);
|
|
34612
|
+
const outAmount = params.offered.amount - fee;
|
|
34613
|
+
if (outAmount <= DUST_THRESHOLD) {
|
|
34614
|
+
throw new TransactionBuildError(
|
|
34615
|
+
`buildReclaimOffer: reclaimed native value ${params.offered.amount} is too small to cover the fee ${fee} above dust`
|
|
34616
|
+
);
|
|
34617
|
+
}
|
|
34618
|
+
txb.addOutput(nativePaymentScript2(params.makerAddress), toSafeNumber(outAmount));
|
|
34619
|
+
const tx2 = import_utxo_lib.Transaction.fromHex(txb.buildIncomplete().toHex(), verusNetwork);
|
|
34620
|
+
const takerInputs2 = [
|
|
34621
|
+
{ index: 0, prevOutScript: commitmentScript, value: params.commitment.value }
|
|
34622
|
+
];
|
|
34623
|
+
assertNativeConservation([{ satoshis: params.commitment.value }], tx2.outs, fee, "reclaimOffer");
|
|
34624
|
+
const { signedTx: signedTx2, txid: txid2 } = signTakerInputs(tx2.toHex(), takerInputs2, params.wif, network);
|
|
34625
|
+
return { reclaimTx: signedTx2, txid: txid2 };
|
|
34626
|
+
}
|
|
34627
|
+
const feeUtxos = params.feeUtxos ?? [];
|
|
34628
|
+
if (feeUtxos.length === 0) {
|
|
34629
|
+
throw new TransactionBuildError(
|
|
34630
|
+
"buildReclaimOffer: reclaiming a token requires feeUtxos (native UTXOs) \u2014 the token commitment carries no native coin for the fee"
|
|
34631
|
+
);
|
|
34632
|
+
}
|
|
34633
|
+
const tokenOut = buildTokenChangeOutput(
|
|
34634
|
+
parseAddress(params.makerAddress, "makerAddress"),
|
|
34635
|
+
/* @__PURE__ */ new Map([[params.offered.currency, params.offered.amount]])
|
|
34636
|
+
);
|
|
34637
|
+
txb.addOutput(tokenOut.script, 0);
|
|
34638
|
+
const tx = import_utxo_lib.Transaction.fromHex(txb.buildIncomplete().toHex(), verusNetwork);
|
|
34639
|
+
const takerInputs = [
|
|
34640
|
+
{ index: 0, prevOutScript: commitmentScript, value: 0n }
|
|
34641
|
+
];
|
|
34642
|
+
const selection = selectUtxos(feeUtxos, 0n, /* @__PURE__ */ new Map(), 2, systemId, void 0, true, 200);
|
|
34643
|
+
if (selection.currencyChanges.size > 0) {
|
|
34644
|
+
throw new TransactionBuildError(
|
|
34645
|
+
"buildReclaimOffer: feeUtxos must carry only the native coin; a token-bearing UTXO was selected and its reserve value would be lost."
|
|
34646
|
+
);
|
|
34647
|
+
}
|
|
34648
|
+
const expectedFeeScript = addressToScriptPubKey(
|
|
34649
|
+
import_utxo_lib.ECPair.fromWIF(params.wif, verusNetwork).getAddress()
|
|
34650
|
+
).toString("hex");
|
|
34651
|
+
for (const u of selection.selected) {
|
|
34652
|
+
if (u.script !== expectedFeeScript) {
|
|
34653
|
+
throw new TransactionBuildError(
|
|
34654
|
+
`buildReclaimOffer: fee UTXO ${u.txid}:${u.outputIndex} must be a native P2PKH output controlled by the provided wif.`
|
|
34655
|
+
);
|
|
34656
|
+
}
|
|
34657
|
+
const idx = tx.addInput(Buffer.from(u.txid, "hex").reverse(), u.outputIndex, 4294967295);
|
|
34658
|
+
takerInputs.push({ index: idx, prevOutScript: Buffer.from(u.script, "hex"), value: u.satoshis });
|
|
34659
|
+
}
|
|
34660
|
+
if (selection.nativeChange > 0n) {
|
|
34661
|
+
tx.addOutput(nativePaymentScript2(params.changeAddress ?? params.makerAddress), toSafeNumber(selection.nativeChange));
|
|
34662
|
+
}
|
|
34663
|
+
const feeNativeIn = selection.selected.reduce((s, u) => s + u.satoshis, 0n);
|
|
34664
|
+
assertNativeConservation([{ satoshis: feeNativeIn }], tx.outs, selection.fee, "reclaimOffer");
|
|
34665
|
+
const { signedTx, txid } = signTakerInputs(tx.toHex(), takerInputs, params.wif, network);
|
|
34666
|
+
return { reclaimTx: signedTx, txid };
|
|
34667
|
+
}
|
|
34668
|
+
|
|
34669
|
+
// src/offers/identity.ts
|
|
34670
|
+
function nativePaymentScript3(address2) {
|
|
34671
|
+
return address2.startsWith("i") ? identityPaymentScript(parseIAddress(address2, "address")) : addressToScriptPubKey(address2);
|
|
34672
|
+
}
|
|
34587
34673
|
function buildTransferredIdentity(identityJson, newPrimaryAddresses) {
|
|
34588
34674
|
const identity = boundary_exports.Identity.fromJson(identityJson);
|
|
34589
34675
|
identity.setPrimaryAddresses(newPrimaryAddresses);
|
|
@@ -34610,16 +34696,16 @@ function fundFeeAndSignIdentityTaker(args) {
|
|
|
34610
34696
|
).toString("hex");
|
|
34611
34697
|
const takerInputs = [...args.priorInputs];
|
|
34612
34698
|
for (const u of selection.selected) {
|
|
34613
|
-
if (
|
|
34699
|
+
if (u.script !== expectedScript) {
|
|
34614
34700
|
throw new TransactionBuildError(
|
|
34615
|
-
`${args.label}: fee UTXO ${u.txid}:${u.outputIndex}
|
|
34701
|
+
`${args.label}: fee UTXO ${u.txid}:${u.outputIndex} must be a native P2PKH output controlled by the provided wif.`
|
|
34616
34702
|
);
|
|
34617
34703
|
}
|
|
34618
34704
|
const idx = args.tx.addInput(Buffer.from(u.txid, "hex").reverse(), u.outputIndex, 4294967295);
|
|
34619
34705
|
takerInputs.push({ index: idx, prevOutScript: Buffer.from(u.script, "hex"), value: u.satoshis });
|
|
34620
34706
|
}
|
|
34621
34707
|
if (selection.nativeChange > 0n) {
|
|
34622
|
-
args.tx.addOutput(
|
|
34708
|
+
args.tx.addOutput(nativePaymentScript3(args.changeAddress), toSafeNumber(selection.nativeChange));
|
|
34623
34709
|
}
|
|
34624
34710
|
const feeNativeIn = selection.selected.reduce((s, u) => s + u.satoshis, 0n);
|
|
34625
34711
|
assertNativeConservation(
|
|
@@ -34679,7 +34765,7 @@ function completeSellIdentityOffer(params, network) {
|
|
|
34679
34765
|
const change = buildTokenChangeOutput(parseAddress(params.changeAddress, "changeAddress"), selection.currencyChanges);
|
|
34680
34766
|
tx.addOutput(change.script, toSafeNumber(selection.nativeChange));
|
|
34681
34767
|
} else {
|
|
34682
|
-
tx.addOutput(
|
|
34768
|
+
tx.addOutput(nativePaymentScript3(params.changeAddress), toSafeNumber(selection.nativeChange));
|
|
34683
34769
|
}
|
|
34684
34770
|
}
|
|
34685
34771
|
assertTokenConservation(selection.selected, wantedTokenReq, selection.currencyChanges, systemId, "takeSellIdentityOffer");
|
|
@@ -34737,7 +34823,7 @@ function completeBuyIdentityOffer(params, network) {
|
|
|
34737
34823
|
{ index: idIdx, prevOutScript: Buffer.from(params.identityOutput.script, "hex"), value: 0n }
|
|
34738
34824
|
];
|
|
34739
34825
|
if (offeringNative) {
|
|
34740
|
-
tx.addOutput(
|
|
34826
|
+
tx.addOutput(nativePaymentScript3(params.sellerReceiveAddress), toSafeNumber(params.offered.amount));
|
|
34741
34827
|
} else {
|
|
34742
34828
|
const out = buildTokenChangeOutput(
|
|
34743
34829
|
parseAddress(params.sellerReceiveAddress, "sellerReceiveAddress"),
|
|
@@ -34809,6 +34895,142 @@ function completeSwapIdentityOffer(params, network) {
|
|
|
34809
34895
|
});
|
|
34810
34896
|
}
|
|
34811
34897
|
|
|
34898
|
+
// src/identity/multisig.ts
|
|
34899
|
+
var multisig_exports = {};
|
|
34900
|
+
__export(multisig_exports, {
|
|
34901
|
+
addIdentitySignature: () => addIdentitySignature,
|
|
34902
|
+
buildMultisigIdentityUpdate: () => buildMultisigIdentityUpdate
|
|
34903
|
+
});
|
|
34904
|
+
var { completeFundedIdentityUpdate: completeFundedIdentityUpdate2 } = import_utxo_lib.smarttxs;
|
|
34905
|
+
var SIGHASH_ALL = import_utxo_lib.Transaction.SIGHASH_ALL;
|
|
34906
|
+
function nativePaymentScript4(address2) {
|
|
34907
|
+
return address2.startsWith("i") ? identityPaymentScript(parseIAddress(address2, "address")) : addressToScriptPubKey(address2);
|
|
34908
|
+
}
|
|
34909
|
+
function addressOfPubkey(pubkey, verusNetwork) {
|
|
34910
|
+
return import_utxo_lib.ECPair.fromPublicKeyBuffer(pubkey, verusNetwork).getAddress();
|
|
34911
|
+
}
|
|
34912
|
+
function buildMultisigIdentityUpdate(params, network) {
|
|
34913
|
+
const verusNetwork = getNetwork(network === "testnet");
|
|
34914
|
+
const systemId = NETWORK_CONFIG[network].chainId;
|
|
34915
|
+
if (!Number.isInteger(params.expiryHeight) || params.expiryHeight <= 0) {
|
|
34916
|
+
throw new TransactionBuildError("buildMultisigIdentityUpdate: expiryHeight must be a positive block height");
|
|
34917
|
+
}
|
|
34918
|
+
if (params.minSignatures < 1) {
|
|
34919
|
+
throw new TransactionBuildError("buildMultisigIdentityUpdate: minSignatures must be >= 1");
|
|
34920
|
+
}
|
|
34921
|
+
if (params.currentPrimaryAddresses.length < params.minSignatures) {
|
|
34922
|
+
throw new TransactionBuildError(
|
|
34923
|
+
`buildMultisigIdentityUpdate: minSignatures ${params.minSignatures} exceeds the ${params.currentPrimaryAddresses.length} current primary address(es)`
|
|
34924
|
+
);
|
|
34925
|
+
}
|
|
34926
|
+
if (params.funding.length === 0) {
|
|
34927
|
+
throw new TransactionBuildError("buildMultisigIdentityUpdate: funding must include native UTXOs for the fee");
|
|
34928
|
+
}
|
|
34929
|
+
const newIdScript = buildIdentityScript(boundary_exports.Identity.fromJson(params.newIdentity));
|
|
34930
|
+
const selection = selectUtxos(params.funding, 0n, /* @__PURE__ */ new Map(), 2, systemId, void 0, true, newIdScript.length + 100);
|
|
34931
|
+
if (selection.currencyChanges.size > 0) {
|
|
34932
|
+
throw new TransactionBuildError(
|
|
34933
|
+
"buildMultisigIdentityUpdate: funding must carry only the native coin; a token-bearing UTXO was selected and its reserve value would be lost."
|
|
34934
|
+
);
|
|
34935
|
+
}
|
|
34936
|
+
const funderScript = addressToScriptPubKey(
|
|
34937
|
+
import_utxo_lib.ECPair.fromWIF(params.funderWif, verusNetwork).getAddress()
|
|
34938
|
+
).toString("hex");
|
|
34939
|
+
for (const u of selection.selected) {
|
|
34940
|
+
if (u.script !== funderScript) {
|
|
34941
|
+
throw new TransactionBuildError(
|
|
34942
|
+
`buildMultisigIdentityUpdate: funding UTXO ${u.txid}:${u.outputIndex} must be a native P2PKH output controlled by funderWif.`
|
|
34943
|
+
);
|
|
34944
|
+
}
|
|
34945
|
+
}
|
|
34946
|
+
const txb = new import_utxo_lib.TransactionBuilder(verusNetwork);
|
|
34947
|
+
txb.setVersion(4);
|
|
34948
|
+
txb.setExpiryHeight(resolveExpiryHeight(params.expiryHeight));
|
|
34949
|
+
txb.setVersionGroupId(VERSION_GROUP_ID);
|
|
34950
|
+
for (const u of selection.selected) {
|
|
34951
|
+
txb.addInput(Buffer.from(u.txid, "hex").reverse(), u.outputIndex, 4294967295, Buffer.from(u.script, "hex"));
|
|
34952
|
+
}
|
|
34953
|
+
txb.addOutput(newIdScript, 0);
|
|
34954
|
+
if (selection.nativeChange > 0n) {
|
|
34955
|
+
txb.addOutput(nativePaymentScript4(params.changeAddress), toSafeNumber(selection.nativeChange));
|
|
34956
|
+
}
|
|
34957
|
+
const prevOutScripts = selection.selected.map((u) => Buffer.from(u.script, "hex"));
|
|
34958
|
+
const identityIndex = selection.selected.length;
|
|
34959
|
+
const completedHex = completeFundedIdentityUpdate2(txb.buildIncomplete().toHex(), verusNetwork, prevOutScripts, {
|
|
34960
|
+
hash: Buffer.from(params.identityUtxo.txid, "hex").reverse(),
|
|
34961
|
+
index: params.identityUtxo.vout,
|
|
34962
|
+
sequence: 4294967295,
|
|
34963
|
+
script: Buffer.from(params.identityUtxo.script, "hex")
|
|
34964
|
+
});
|
|
34965
|
+
const tx = import_utxo_lib.Transaction.fromHex(completedHex, verusNetwork);
|
|
34966
|
+
const funderNativeIn = selection.selected.reduce((s, u) => s + u.satoshis, 0n);
|
|
34967
|
+
assertNativeConservation([{ satoshis: funderNativeIn }], tx.outs, selection.fee, "multisigIdentityUpdate");
|
|
34968
|
+
const funderKey = import_utxo_lib.ECPair.fromWIF(params.funderWif, verusNetwork);
|
|
34969
|
+
for (let i = 0; i < selection.selected.length; i++) {
|
|
34970
|
+
const u = selection.selected[i];
|
|
34971
|
+
const sighash = tx.hashForSignatureByNetwork(i, Buffer.from(u.script, "hex"), toSafeNumber(u.satoshis), SIGHASH_ALL, false);
|
|
34972
|
+
const sig = funderKey.sign(sighash);
|
|
34973
|
+
tx.ins[i].script = import_utxo_lib.script.compile([sig.toScriptSignature(SIGHASH_ALL), funderKey.getPublicKeyBuffer()]);
|
|
34974
|
+
}
|
|
34975
|
+
return {
|
|
34976
|
+
partialTx: tx.toHex(),
|
|
34977
|
+
identityInput: { index: identityIndex, script: params.identityUtxo.script },
|
|
34978
|
+
currentPrimaryAddresses: params.currentPrimaryAddresses,
|
|
34979
|
+
minSignatures: params.minSignatures,
|
|
34980
|
+
collected: 0
|
|
34981
|
+
};
|
|
34982
|
+
}
|
|
34983
|
+
function addIdentitySignature(params, network) {
|
|
34984
|
+
const verusNetwork = getNetwork(network === "testnet");
|
|
34985
|
+
const keyPair = import_utxo_lib.ECPair.fromWIF(params.wif, verusNetwork);
|
|
34986
|
+
const signerAddress = keyPair.getAddress();
|
|
34987
|
+
const order = params.currentPrimaryAddresses.indexOf(signerAddress);
|
|
34988
|
+
if (order < 0) {
|
|
34989
|
+
throw new TransactionBuildError(
|
|
34990
|
+
`addIdentitySignature: the provided wif (${signerAddress}) is not one of the identity's primary addresses`
|
|
34991
|
+
);
|
|
34992
|
+
}
|
|
34993
|
+
const tx = import_utxo_lib.Transaction.fromHex(params.partialTx, verusNetwork);
|
|
34994
|
+
const input = tx.ins[params.identityInput.index];
|
|
34995
|
+
if (!input) {
|
|
34996
|
+
throw new TransactionBuildError(`addIdentitySignature: no input at index ${params.identityInput.index}`);
|
|
34997
|
+
}
|
|
34998
|
+
const sighash = tx.hashForSignatureByNetwork(
|
|
34999
|
+
params.identityInput.index,
|
|
35000
|
+
Buffer.from(params.identityInput.script, "hex"),
|
|
35001
|
+
0,
|
|
35002
|
+
SIGHASH_ALL,
|
|
35003
|
+
false
|
|
35004
|
+
);
|
|
35005
|
+
const sig = keyPair.sign(sighash).toCompact().slice(1);
|
|
35006
|
+
const entry = new import_utxo_lib.SmartTransactionSignature(1, 1, keyPair.getPublicKeyBuffer(), sig);
|
|
35007
|
+
const existing = [];
|
|
35008
|
+
if (input.script.length > 0) {
|
|
35009
|
+
const chunk = (import_utxo_lib.script.decompile(input.script) ?? []).find((c) => Buffer.isBuffer(c));
|
|
35010
|
+
if (chunk) {
|
|
35011
|
+
const parsed = import_utxo_lib.SmartTransactionSignatures.fromChunk(chunk);
|
|
35012
|
+
for (const s of parsed.signatures ?? []) existing.push(s);
|
|
35013
|
+
}
|
|
35014
|
+
}
|
|
35015
|
+
const merged = existing.filter((s) => {
|
|
35016
|
+
const addr = addressOfPubkey(s.pubKeyData, verusNetwork);
|
|
35017
|
+
return addr !== signerAddress && params.currentPrimaryAddresses.indexOf(addr) >= 0;
|
|
35018
|
+
});
|
|
35019
|
+
merged.push(entry);
|
|
35020
|
+
merged.sort(
|
|
35021
|
+
(a, b) => params.currentPrimaryAddresses.indexOf(addressOfPubkey(a.pubKeyData, verusNetwork)) - params.currentPrimaryAddresses.indexOf(addressOfPubkey(b.pubKeyData, verusNetwork))
|
|
35022
|
+
);
|
|
35023
|
+
const fulfillment = new import_utxo_lib.SmartTransactionSignatures(1, SIGHASH_ALL, merged).toChunk();
|
|
35024
|
+
input.script = import_utxo_lib.script.compile([fulfillment]);
|
|
35025
|
+
const collected = merged.length;
|
|
35026
|
+
return {
|
|
35027
|
+
partialTx: tx.toHex(),
|
|
35028
|
+
collected,
|
|
35029
|
+
minSignatures: params.minSignatures,
|
|
35030
|
+
complete: collected >= params.minSignatures
|
|
35031
|
+
};
|
|
35032
|
+
}
|
|
35033
|
+
|
|
34812
35034
|
// src/VerusSDK.ts
|
|
34813
35035
|
var VerusSDK = class {
|
|
34814
35036
|
constructor(config) {
|
|
@@ -34897,6 +35119,18 @@ var VerusSDK = class {
|
|
|
34897
35119
|
"revoke"
|
|
34898
35120
|
);
|
|
34899
35121
|
}
|
|
35122
|
+
/**
|
|
35123
|
+
* Build the funded half of an m-of-n (multisig) identity update: funding inputs
|
|
35124
|
+
* signed by the funder, the identity CC input left open. Pass the result to
|
|
35125
|
+
* `addIdentitySignature` for each authority until `minSignatures` are collected.
|
|
35126
|
+
*/
|
|
35127
|
+
buildMultisigIdentityUpdate(params) {
|
|
35128
|
+
return buildMultisigIdentityUpdate(params, this.network);
|
|
35129
|
+
}
|
|
35130
|
+
/** Add one authority signature to a multisig identity update (see buildMultisigIdentityUpdate). */
|
|
35131
|
+
addIdentitySignature(params) {
|
|
35132
|
+
return addIdentitySignature(params, this.network);
|
|
35133
|
+
}
|
|
34900
35134
|
/** Recover an identity (requires recovery authority key) */
|
|
34901
35135
|
recoverIdentity(params) {
|
|
34902
35136
|
return buildAndSignIdentityUpdate(
|
|
@@ -34952,6 +35186,14 @@ var VerusSDK = class {
|
|
|
34952
35186
|
completeOffer(params) {
|
|
34953
35187
|
return completeOffer(params, this.network);
|
|
34954
35188
|
}
|
|
35189
|
+
/**
|
|
35190
|
+
* Maker: cancel an unaccepted offer — spend the funding commitment back to the
|
|
35191
|
+
* maker (SIGHASH_ALL). Native: the fee comes out of the reclaimed value; token:
|
|
35192
|
+
* pass native `feeUtxos` controlled by the same key.
|
|
35193
|
+
*/
|
|
35194
|
+
buildReclaimOffer(params) {
|
|
35195
|
+
return buildReclaimOffer(params, this.network);
|
|
35196
|
+
}
|
|
34955
35197
|
/** Maker: offer a VerusID for a currency (spends the identity's on-chain output). */
|
|
34956
35198
|
buildSellIdentityOffer(params) {
|
|
34957
35199
|
return buildSellIdentityOffer(params, this.network);
|
|
@@ -35070,6 +35312,7 @@ __export(public_exports2, {
|
|
|
35070
35312
|
classifyCurrency,
|
|
35071
35313
|
currency,
|
|
35072
35314
|
identity,
|
|
35315
|
+
identityMultisig,
|
|
35073
35316
|
isIAddress,
|
|
35074
35317
|
isIdentityName,
|
|
35075
35318
|
isRAddress,
|
package/dist/identity/index.js
CHANGED
|
@@ -826,9 +826,9 @@ function buildAndSignIdentityUpdate(params, network, operation = 'update', lockU
|
|
|
826
826
|
// at broadcast; fail closed instead.
|
|
827
827
|
const currentMinSigs = identity.min_sigs?.toNumber?.() ?? 1;
|
|
828
828
|
if (currentMinSigs > 1) {
|
|
829
|
-
throw new errors_js_1.TransactionBuildError(`this identity requires ${currentMinSigs} signatures (min_sigs > 1);
|
|
830
|
-
`WIF
|
|
831
|
-
|
|
829
|
+
throw new errors_js_1.TransactionBuildError(`this identity requires ${currentMinSigs} signatures (min_sigs > 1); this single-key path signs ` +
|
|
830
|
+
`with one WIF. Use the multisig flow (buildMultisigIdentityUpdate + addIdentitySignature, the ` +
|
|
831
|
+
`\`identityMultisig\` namespace) to collect m-of-n signatures for a ${operation}.`);
|
|
832
832
|
}
|
|
833
833
|
}
|
|
834
834
|
switch (operation) {
|