@chainvue/verus-sdk 0.13.0 → 0.14.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.
Files changed (41) hide show
  1. package/README.md +21 -8
  2. package/dist/VerusSDK.d.ts +34 -1
  3. package/dist/VerusSDK.d.ts.map +1 -1
  4. package/dist/VerusSDK.js +38 -1
  5. package/dist/VerusSDK.js.map +1 -1
  6. package/dist/bundle.js +1009 -122
  7. package/dist/currency/definition.d.ts +181 -0
  8. package/dist/currency/definition.d.ts.map +1 -0
  9. package/dist/currency/definition.js +396 -0
  10. package/dist/currency/definition.js.map +1 -0
  11. package/dist/currency/index.d.ts +17 -7
  12. package/dist/currency/index.d.ts.map +1 -1
  13. package/dist/currency/index.js +32 -9
  14. package/dist/currency/index.js.map +1 -1
  15. package/dist/currency/launch.d.ts +43 -0
  16. package/dist/currency/launch.d.ts.map +1 -0
  17. package/dist/currency/launch.js +96 -0
  18. package/dist/currency/launch.js.map +1 -0
  19. package/dist/currency/outputs.d.ts +40 -0
  20. package/dist/currency/outputs.d.ts.map +1 -0
  21. package/dist/currency/outputs.js +296 -0
  22. package/dist/currency/outputs.js.map +1 -0
  23. package/dist/currency/reserveTransfer.d.ts +36 -0
  24. package/dist/currency/reserveTransfer.d.ts.map +1 -0
  25. package/dist/currency/reserveTransfer.js +104 -0
  26. package/dist/currency/reserveTransfer.js.map +1 -0
  27. package/dist/currency/wire.d.ts +76 -0
  28. package/dist/currency/wire.d.ts.map +1 -0
  29. package/dist/currency/wire.js +252 -0
  30. package/dist/currency/wire.js.map +1 -0
  31. package/dist/index.d.ts +8 -0
  32. package/dist/index.d.ts.map +1 -1
  33. package/dist/index.js +16 -1
  34. package/dist/index.js.map +1 -1
  35. package/dist/transfer/index.d.ts.map +1 -1
  36. package/dist/transfer/index.js +38 -14
  37. package/dist/transfer/index.js.map +1 -1
  38. package/dist/types/index.d.ts +27 -1
  39. package/dist/types/index.d.ts.map +1 -1
  40. package/dist/types/index.js.map +1 -1
  41. package/package.json +1 -1
@@ -1,25 +1,47 @@
1
1
  "use strict";
2
2
  /**
3
- * Currency definition (manual mode only offline)
3
+ * Currency helpers all offline, byte-equivalent to the daemon.
4
4
  *
5
- * Creates a currency definition transaction. Requires a pre-built
6
- * currency definition script hex (obtained externally).
5
+ * - `buildCurrencyDefinitionScript` / `serializeCurrencyDefinition`: the
6
+ * EVAL_CURRENCY_DEFINITION output script (token, fractional basket, or NFT).
7
+ * - `buildCurrencyLaunchOutputs`: all seven outputs of a currency-definition tx.
8
+ * - `buildCurrencyLaunchTransaction`: a complete, signed, broadcastable launch.
9
+ * - `buildReserveTransferOutput`: the (pre)convert output for investing in a
10
+ * launching currency.
7
11
  *
8
- * Currency creation requires:
9
- * 1. An existing identity with the same name
10
- * 2. The identity's FLAG_ACTIVECURRENCY must be set
11
- * 3. A currency definition output (EVAL_CURRENCY_DEFINITION)
12
+ * `defineCurrency` is a narrower helper (identity-spend + a pre-built definition
13
+ * output + change); prefer `buildCurrencyLaunchTransaction` for a full launch.
12
14
  */
13
15
  var __importDefault = (this && this.__importDefault) || function (mod) {
14
16
  return (mod && mod.__esModule) ? mod : { "default": mod };
15
17
  };
16
18
  Object.defineProperty(exports, "__esModule", { value: true });
17
- exports.CURRENCY_TYPE_ORDER = exports.classifyCurrency = void 0;
19
+ exports.buildReserveTransferOutput = exports.buildCurrencyLaunchTransaction = exports.buildCurrencyLaunchOutputs = exports.PROOF_PROTOCOL = exports.NOTARIZATION_PROTOCOL = exports.CURRENCY_DEFINITION_VERSION = exports.CURRENCY_OPTION = exports.buildCurrencyDefinitionScript = exports.serializeCurrencyDefinition = exports.CURRENCY_TYPE_ORDER = exports.classifyCurrency = void 0;
18
20
  exports.defineCurrency = defineCurrency;
19
21
  // Re-export classification utilities
20
22
  var classify_js_1 = require("./classify.js");
21
23
  Object.defineProperty(exports, "classifyCurrency", { enumerable: true, get: function () { return classify_js_1.classifyCurrency; } });
22
24
  Object.defineProperty(exports, "CURRENCY_TYPE_ORDER", { enumerable: true, get: function () { return classify_js_1.CURRENCY_TYPE_ORDER; } });
25
+ // Structured currency-definition builder (token / fractional basket)
26
+ var definition_js_1 = require("./definition.js");
27
+ Object.defineProperty(exports, "serializeCurrencyDefinition", { enumerable: true, get: function () { return definition_js_1.serializeCurrencyDefinition; } });
28
+ Object.defineProperty(exports, "buildCurrencyDefinitionScript", { enumerable: true, get: function () { return definition_js_1.buildCurrencyDefinitionScript; } });
29
+ Object.defineProperty(exports, "CURRENCY_OPTION", { enumerable: true, get: function () { return definition_js_1.CURRENCY_OPTION; } });
30
+ Object.defineProperty(exports, "CURRENCY_DEFINITION_VERSION", { enumerable: true, get: function () { return definition_js_1.CURRENCY_DEFINITION_VERSION; } });
31
+ Object.defineProperty(exports, "NOTARIZATION_PROTOCOL", { enumerable: true, get: function () { return definition_js_1.NOTARIZATION_PROTOCOL; } });
32
+ Object.defineProperty(exports, "PROOF_PROTOCOL", { enumerable: true, get: function () { return definition_js_1.PROOF_PROTOCOL; } });
33
+ // Full offline currency-launch output builder (all 7 outputs, byte-equivalent to
34
+ // definecurrency): identity update, currency def, import, notarization, export,
35
+ // reserve deposit, change.
36
+ var outputs_js_1 = require("./outputs.js");
37
+ Object.defineProperty(exports, "buildCurrencyLaunchOutputs", { enumerable: true, get: function () { return outputs_js_1.buildCurrencyLaunchOutputs; } });
38
+ // Full offline currency-launch transaction (outputs + funding + identity input + signing).
39
+ var launch_js_1 = require("./launch.js");
40
+ Object.defineProperty(exports, "buildCurrencyLaunchTransaction", { enumerable: true, get: function () { return launch_js_1.buildCurrencyLaunchTransaction; } });
41
+ // Reserve-transfer output: (pre)convert a reserve into a fractional currency
42
+ // ("invest at launch").
43
+ var reserveTransfer_js_1 = require("./reserveTransfer.js");
44
+ Object.defineProperty(exports, "buildReserveTransferOutput", { enumerable: true, get: function () { return reserveTransfer_js_1.buildReserveTransferOutput; } });
23
45
  const boundary_js_1 = require("../fork/boundary.js");
24
46
  const bn_js_1 = __importDefault(require("bn.js"));
25
47
  const index_js_1 = require("../constants/index.js");
@@ -49,6 +71,7 @@ function defineCurrency(params, network) {
49
71
  if (!params.currencyDefScript) {
50
72
  throw new errors_js_1.TransactionBuildError('currencyDefScript is required');
51
73
  }
74
+ const currencyDefScriptHex = params.currencyDefScript;
52
75
  const verusNetwork = (0, index_js_2.getNetwork)(network === 'testnet');
53
76
  const currencyDefValue = params.currencyDefValue || 0n;
54
77
  // Parse identity and set FLAG_ACTIVECURRENCY
@@ -64,7 +87,7 @@ function defineCurrency(params, network) {
64
87
  }
65
88
  const identityScript = boundary_js_1.IdentityScript.fromIdentity(identity);
66
89
  const identityOutputScript = identityScript.toBuffer();
67
- const currencyDefScript = Buffer.from(params.currencyDefScript, 'hex');
90
+ const currencyDefScript = Buffer.from(currencyDefScriptHex, 'hex');
68
91
  // Respend the identity UTXO, recreating its (value-0) definition output with
69
92
  // FLAG_ACTIVECURRENCY set, alongside the currency-definition output. The shared
70
93
  // assembler funds them, emits native change, grafts on the identity input
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/currency/index.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;GAUG;;;;;;AAuBH,wCAsEC;AA3FD,qCAAqC;AACrC,6CAAsE;AAA7D,+GAAA,gBAAgB,OAAA;AAAE,kHAAA,mBAAmB,OAAA;AAG9C,qDAA+D;AAC/D,kDAAuB;AACvB,oDAAqE;AAErE,kDAAiD;AACjD,mDAA0D;AAC1D,+CAA+C;AAC/C,4CAAsE;AAGtE,iFAAmF;AAEnF;;;;GAIG;AACH,SAAgB,cAAc,CAC5B,MAA4B,EAC5B,OAAgB;IAEhB,8EAA8E;IAC9E,mDAAmD;IACnD,MAAM,QAAQ,GAAG,IAAA,sBAAW,EAAC,MAAM,CAAC,GAAG,CAAC,CAAC;IACzC,IAAI,CAAC,QAAQ,CAAC,KAAK,EAAE,CAAC;QACpB,MAAM,IAAI,2BAAe,CAAC,QAAQ,CAAC,KAAK,C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a,EAAE,MAAM,CAAC,aAAa;QACnC,6EAA6E;QAC7E,4EAA4E;QAC5E,gBAAgB,EAAE,oBAAoB,CAAC,MAAM,GAAG,iBAAiB,CAAC,MAAM;QACxE,KAAK,EAAE,qBAAqB;KAC7B,CAAC,CAAC;IAEH,OAAO;QACL,QAAQ,EAAE,SAAS,CAAC,QAAQ;QAC5B,IAAI,EAAE,SAAS,CAAC,IAAI;QACpB,GAAG,EAAE,SAAS,CAAC,GAAG;QAClB,eAAe,EAAE,QAAQ,CAAC,kBAAkB,EAAE;QAC9C,UAAU,EAAE,SAAS,CAAC,UAAU;QAChC,YAAY,EAAE,SAAS,CAAC,YAAY;KACrC,CAAC;AACJ,CAAC"}
@@ -0,0 +1,43 @@
1
+ import type { Network } from '../constants/index.js';
2
+ import type { Utxo } from '../types/index.js';
3
+ import type { CurrencyDefinitionInput } from './definition.js';
4
+ export interface CurrencyLaunchTxParams {
5
+ /** WIF of the identity's primary address (signs both the identity input and funding). */
6
+ wif: string;
7
+ /** The currency to define (token or fractional basket). */
8
+ definition: CurrencyDefinitionInput;
9
+ /** The `identity` object from the lite node's `getidentity` for the defining ID. */
10
+ identity: Record<string, unknown>;
11
+ /** The defining identity's controlling UTXO (its current EVAL_IDENTITY_PRIMARY output; value 0). */
12
+ identityUtxo: Utxo;
13
+ /** Funding UTXOs on the signer's address — cover the reserve deposit + miner fee. */
14
+ fundingUtxos: Utxo[];
15
+ /** Native change address. Defaults to the defining identity's i-address. */
16
+ changeAddress?: string;
17
+ /** Current chain tip height (embedded in the import/notarization/export outputs). */
18
+ height: number;
19
+ /**
20
+ * Currency launch (registration) fee in native satoshis — query
21
+ * `getcurrency <parent>` (200 native for a standard token/basket, 0.02 for an
22
+ * NFT). Half funds the reserve deposit; the wrong value is rejected on broadcast.
23
+ */
24
+ launchFeeSats: bigint;
25
+ /** Expiry height; defaults to a delta above the tip. */
26
+ expiryHeight?: number;
27
+ }
28
+ export interface CurrencyLaunchTxResult {
29
+ signedTx: string;
30
+ txid: string;
31
+ fee: bigint;
32
+ nativeChange: bigint;
33
+ inputsUsed: number;
34
+ /** The new currency's i-address (equals the defining identity's address). */
35
+ currencyAddress: string;
36
+ }
37
+ /**
38
+ * Build and sign a currency-definition transaction. No node RPC is performed;
39
+ * everything is derived from the passed inputs, so the signed hex can be handed
40
+ * to any node for broadcast.
41
+ */
42
+ export declare function buildCurrencyLaunchTransaction(params: CurrencyLaunchTxParams, network: Network): CurrencyLaunchTxResult;
43
+ //# sourceMappingURL=launch.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"launch.d.ts","sourceRoot":"","sources":["../../src/currency/launch.ts"],"names":[],"mappings":"AAqBA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,uBAAuB,CAAC;AAErD,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,mBAAmB,CAAC;AAO9C,OAAO,KAAK,EAAE,uBAAuB,EAAE,MAAM,iBAAiB,CAAC;AAE/D,MAAM,WAAW,sBAAsB;IACrC,yFAAyF;IACzF,GAAG,EAAE,MAAM,CAAC;IACZ,2DAA2D;IAC3D,UAAU,EAAE,uBAAuB,CAAC;IACpC,oFAAoF;IACpF,QAAQ,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;IAClC,oGAAoG;IACpG,YAAY,EAAE,IAAI,CAAC;IACnB,qFAAqF;IACrF,YAAY,EAAE,IAAI,EAAE,CAAC;IACrB,4EAA4E;IAC5E,aAAa,CAAC,EAAE,MAAM,CAAC;IACvB,qFAAqF;IACrF,MAAM,EAAE,MAAM,CAAC;IACf;;;;OAIG;IACH,aAAa,EAAE,MAAM,CAAC;IACtB,wDAAwD;IACxD,YAAY,CAAC,EAAE,MAAM,CAAC;CACvB;AAED,MAAM,WAAW,sBAAsB;IACrC,QAAQ,EAAE,MAAM,CAAC;IACjB,IAAI,EAAE,MAAM,CAAC;IACb,GAAG,EAAE,MAAM,CAAC;IACZ,YAAY,EAAE,MAAM,CAAC;IACrB,UAAU,EAAE,MAAM,CAAC;IACnB,6EAA6E;IAC7E,eAAe,EAAE,MAAM,CAAC;CACzB;AAED;;;;GAIG;AACH,wBAAgB,8BAA8B,CAC5C,MAAM,EAAE,sBAAsB,EAC9B,OAAO,EAAE,OAAO,GACf,sBAAsB,CA+DxB"}
@@ -0,0 +1,96 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.buildCurrencyLaunchTransaction = buildCurrencyLaunchTransaction;
4
+ /**
5
+ * Assemble a fully-signed, broadcastable currency-definition transaction offline.
6
+ *
7
+ * Composes {@link buildCurrencyLaunchOutputs} (the seven byte-locked output
8
+ * scripts) with the funded-identity-update assembler: it spends the defining
9
+ * identity's output (recreated with FLAG_ACTIVECURRENCY), funds the reserve
10
+ * deposit and the miner fee from the supplied UTXOs, emits native change, and
11
+ * signs — the identity input under primary authority, the funding inputs P2PKH.
12
+ *
13
+ * Only the change output differs from the daemon's own `definecurrency`
14
+ * transaction, and it must: change value is a function of which UTXOs fund the
15
+ * transaction, so no offline builder (nor the daemon) produces a byte-identical
16
+ * whole transaction. The six consensus-checked outputs (indices 0–5), which the
17
+ * daemon validates against chain state, ARE byte-identical — see
18
+ * test/currency-outputs.test.ts.
19
+ *
20
+ * Inputs the caller gathers from a lite node: the defining identity
21
+ * (`getidentity`), its controlling UTXO, funding UTXOs on the signer's address,
22
+ * and the current block height.
23
+ */
24
+ const boundary_js_1 = require("../fork/boundary.js");
25
+ const index_js_1 = require("../constants/index.js");
26
+ const index_js_2 = require("../signing/index.js");
27
+ const index_js_3 = require("../identity/index.js");
28
+ const index_js_4 = require("../keys/index.js");
29
+ const errors_js_1 = require("../errors.js");
30
+ const fundedIdentityUpdate_js_1 = require("../assemble/fundedIdentityUpdate.js");
31
+ const outputs_js_1 = require("./outputs.js");
32
+ /**
33
+ * Build and sign a currency-definition transaction. No node RPC is performed;
34
+ * everything is derived from the passed inputs, so the signed hex can be handed
35
+ * to any node for broadcast.
36
+ */
37
+ function buildCurrencyLaunchTransaction(params, network) {
38
+ const wifCheck = (0, index_js_4.validateWif)(params.wif);
39
+ if (!wifCheck.valid) {
40
+ throw new errors_js_1.InvalidWifError(wifCheck.error);
41
+ }
42
+ if (!params.fundingUtxos || params.fundingUtxos.length === 0) {
43
+ throw new errors_js_1.TransactionBuildError('at least one funding UTXO is required');
44
+ }
45
+ const identityAddress = params.identity.identityaddress;
46
+ if (typeof identityAddress !== 'string' || !identityAddress) {
47
+ throw new errors_js_1.TransactionBuildError('identity.identityaddress is required');
48
+ }
49
+ // The currency's system must be this chain (the daemon forces it). Catch a wrong
50
+ // systemId/parent here, where the network — hence the chain id — is known.
51
+ const chainId = index_js_1.NETWORK_CONFIG[network].chainId;
52
+ const systemId = params.definition.systemId ?? params.definition.parent;
53
+ if (systemId !== chainId) {
54
+ throw new errors_js_1.TransactionBuildError(`currency systemId/parent (${systemId}) must be the chain id (${chainId}) — this SDK launches same-chain currencies only`);
55
+ }
56
+ // Fail closed if the WIF does not control the identity: the fork would sign the
57
+ // identity input anyway, yielding a transaction the daemon rejects at broadcast.
58
+ const verusNetwork = (0, index_js_2.getNetwork)(network === 'testnet');
59
+ (0, index_js_3.assertWifIsPrimary)(params.wif, boundary_js_1.Identity.fromJson(params.identity), verusNetwork);
60
+ const outputs = (0, outputs_js_1.buildCurrencyLaunchOutputs)(params.definition, {
61
+ identity: params.identity,
62
+ height: params.height,
63
+ launchFeeSats: params.launchFeeSats,
64
+ });
65
+ // The six consensus outputs (identity update … reserve deposit), in order.
66
+ // The assembler appends native change as output 6, standing in for the
67
+ // daemon's identity-change output — see the module doc.
68
+ const consensusOutputs = outputs.ordered.slice(0, 6).map((o) => ({
69
+ script: Buffer.from(o.script, 'hex'),
70
+ nativeSat: o.value,
71
+ }));
72
+ const extraOutputBytes = consensusOutputs.reduce((sum, o) => sum + o.script.length, 0);
73
+ const assembled = (0, fundedIdentityUpdate_js_1.assembleFundedIdentityUpdate)({
74
+ network,
75
+ wif: params.wif,
76
+ // Default to a bounded expiry above the tip (matching the doc), NOT 0, which
77
+ // would silently make the transaction never expire. Pass expiryHeight: 0
78
+ // explicitly to opt into a never-expiring transaction.
79
+ expiryHeight: params.expiryHeight ?? params.height + index_js_1.DEFAULT_EXPIRY_DELTA,
80
+ funding: params.fundingUtxos,
81
+ identityUtxo: params.identityUtxo,
82
+ outputs: consensusOutputs,
83
+ changeAddress: params.changeAddress ?? identityAddress,
84
+ extraOutputBytes,
85
+ label: 'currency launch',
86
+ });
87
+ return {
88
+ signedTx: assembled.signedTx,
89
+ txid: assembled.txid,
90
+ fee: assembled.fee,
91
+ nativeChange: assembled.nativeChange,
92
+ inputsUsed: assembled.inputsUsed,
93
+ currencyAddress: identityAddress,
94
+ };
95
+ }
96
+ //# sourceMappingURL=launch.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"launch.js","sourceRoot":"","sources":["../../src/currency/launch.ts"],"names":[],"mappings":";;AAwEA,wEAkEC;AA1ID;;;;;;;;;;;;;;;;;;;GAmBG;AACH,qDAA+C;AAE/C,oDAA6E;AAE7E,kDAAiD;AACjD,mDAA0D;AAC1D,+CAA+C;AAC/C,4CAAsE;AACtE,iFAAmF;AACnF,6CAA0D;AAsC1D;;;;GAIG;AACH,SAAgB,8BAA8B,CAC5C,MAA8B,EAC9B,OAAgB;IAEhB,MAAM,QAAQ,GAAG,IAAA,sBAAW,EAAC,MAAM,CAAC,GAAG,CAAC,CAAC;IACzC,IAAI,CAAC,QAAQ,CAAC,KAAK,EAAE,CAAC;QACpB,MAAM,IAAI,2BAAe,CAAC,QAAQ,CAAC,KAAK,CAAC,CAAC;IAC5C,CAAC;IACD,IAAI,CAAC,MAAM,CAAC,YAAY,IAAI,MAAM,CAAC,YAAY,CAAC,MAAM,KAAK,CAAC,EAAE,CAAC;QAC7D,MAAM,IAAI,iCAAqB,CAAC,uCAAuC,CAAC,CAAC;IAC3E,CAAC;IACD,MAAM,eAAe,GAAG,MAAM,CAAC,QAAQ,CAAC,eAAe,CAA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AAM,gBAAgB,GAAG,gBAAgB,CAAC,MAAM,CAAC,CAAC,GAAG,EAAE,CAAC,EAAE,EAAE,CAAC,GAAG,GAAG,CAAC,CAAC,MAAM,CAAC,MAAM,EAAE,CAAC,CAAC,CAAC;IAEvF,MAAM,SAAS,GAAG,IAAA,sDAA4B,EAAC;QAC7C,OAAO;QACP,GAAG,EAAE,MAAM,CAAC,GAAG;QACf,6EAA6E;QAC7E,yEAAyE;QACzE,uDAAuD;QACvD,YAAY,EAAE,MAAM,CAAC,YAAY,IAAI,MAAM,CAAC,MAAM,GAAG,+BAAoB;QACzE,OAAO,EAAE,MAAM,CAAC,YAAY;QAC5B,YAAY,EAAE,MAAM,CAAC,YAAY;QACjC,OAAO,EAAE,gBAAgB;QACzB,aAAa,EAAE,MAAM,CAAC,aAAa,IAAI,eAAe;QACtD,gBAAgB;QAChB,KAAK,EAAE,iBAAiB;KACzB,CAAC,CAAC;IAEH,OAAO;QACL,QAAQ,EAAE,SAAS,CAAC,QAAQ;QAC5B,IAAI,EAAE,SAAS,CAAC,IAAI;QACpB,GAAG,EAAE,SAAS,CAAC,GAAG;QAClB,YAAY,EAAE,SAAS,CAAC,YAAY;QACpC,UAAU,EAAE,SAAS,CAAC,UAAU;QAChC,eAAe,EAAE,eAAe;KACjC,CAAC;AACJ,CAAC"}
@@ -0,0 +1,40 @@
1
+ import { type CurrencyDefinitionInput } from './definition.js';
2
+ /** A built transaction output: its scriptPubKey hex and satoshi value. */
3
+ export interface CurrencyLaunchOutput {
4
+ script: string;
5
+ value: bigint;
6
+ }
7
+ /** Everything needed to assemble the launch outputs that the definition alone can't provide. */
8
+ export interface CurrencyLaunchContext {
9
+ /** The `identity` object from the lite node's `getidentity` for the defining ID. */
10
+ identity: Record<string, unknown>;
11
+ /** Current chain tip height (from the lite node); embedded in import/notarization/export. */
12
+ height: number;
13
+ /**
14
+ * Currency launch (registration) fee in native satoshis — the fee the chain
15
+ * charges to define a currency (query `getcurrency <parent>`; 200 native for a
16
+ * standard token/basket, 0.02 native for an NFT). Half of it funds the reserve
17
+ * deposit. Passing the wrong value yields a definition the daemon rejects.
18
+ */
19
+ launchFeeSats: bigint;
20
+ }
21
+ /** The seven output scripts of a currency-definition transaction. */
22
+ export interface CurrencyLaunchOutputs {
23
+ identityUpdate: CurrencyLaunchOutput;
24
+ currencyDefinition: CurrencyLaunchOutput;
25
+ import: CurrencyLaunchOutput;
26
+ notarization: CurrencyLaunchOutput;
27
+ export: CurrencyLaunchOutput;
28
+ reserveDeposit: CurrencyLaunchOutput;
29
+ change: CurrencyLaunchOutput;
30
+ /** Flat, in-order [0..6] view — the order they must appear in the transaction. */
31
+ ordered: CurrencyLaunchOutput[];
32
+ }
33
+ /**
34
+ * Build all seven output scripts of a currency-definition transaction offline,
35
+ * byte-equivalent to what `definecurrency` produces. The currency is defined
36
+ * under an identity of the same name; its i-address (from `context.identity`) is
37
+ * the new currency's id.
38
+ */
39
+ export declare function buildCurrencyLaunchOutputs(input: CurrencyDefinitionInput, context: CurrencyLaunchContext): CurrencyLaunchOutputs;
40
+ //# sourceMappingURL=outputs.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"outputs.d.ts","sourceRoot":"","sources":["../../src/currency/outputs.ts"],"names":[],"mappings":"AA2BA,OAAO,EAIL,KAAK,uBAAuB,EAE7B,MAAM,iBAAiB,CAAC;AAyCzB,0EAA0E;AAC1E,MAAM,WAAW,oBAAoB;IACnC,MAAM,EAAE,MAAM,CAAC;IACf,KAAK,EAAE,MAAM,CAAC;CACf;AAED,gGAAgG;AAChG,MAAM,WAAW,qBAAqB;IACpC,oFAAoF;IACpF,QAAQ,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;IAClC,6FAA6F;IAC7F,MAAM,EAAE,MAAM,CAAC;IACf;;;;;OAKG;IACH,aAAa,EAAE,MAAM,CAAC;CACvB;AAED,qEAAqE;AACrE,MAAM,WAAW,qBAAqB;IACpC,cAAc,EAAE,oBAAoB,CAAC;IACrC,kBAAkB,EAAE,oBAAoB,CAAC;IACzC,MAAM,EAAE,oBAAoB,CAAC;IAC7B,YAAY,EAAE,oBAAoB,CAAC;IACnC,MAAM,EAAE,oBAAoB,CAAC;IAC7B,cAAc,EAAE,oBAAoB,CAAC;IACrC,MAAM,EAAE,oBAAoB,CAAC;IAC7B,kFAAkF;IAClF,OAAO,EAAE,oBAAoB,EAAE,CAAC;CACjC;AA+KD;;;;;GAKG;AACH,wBAAgB,0BAA0B,CACxC,KAAK,EAAE,uBAAuB,EAC9B,OAAO,EAAE,qBAAqB,GAC7B,qBAAqB,CA6GvB"}
@@ -0,0 +1,296 @@
1
+ "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ exports.buildCurrencyLaunchOutputs = buildCurrencyLaunchOutputs;
7
+ /**
8
+ * The other outputs of a currency-definition (`definecurrency`) transaction,
9
+ * built offline. A launch transaction carries seven outputs:
10
+ *
11
+ * 0 identity update (EVAL_IDENTITY_PRIMARY) — re-issues the defining ID with FLAG_ACTIVECURRENCY
12
+ * 1 currency definition(EVAL_CURRENCY_DEFINITION) — see definition.ts
13
+ * 2 cross-chain import (EVAL_CROSSCHAIN_IMPORT) — same-chain definition import stub
14
+ * 3 notarization (EVAL_ACCEPTEDNOTARIZATION)— DEF_NOTARIZATION|PRE_LAUNCH|SAME_CHAIN stub + currency state
15
+ * 4 cross-chain export (EVAL_CROSSCHAIN_EXPORT) — definition export stub
16
+ * 5 reserve deposit (EVAL_RESERVE_DEPOSIT) — carries the launch (import) fee
17
+ * 6 change (identity CC output) — returns funds to the defining ID
18
+ *
19
+ * Outputs 2–4 embed the current chain tip height; everything else is a
20
+ * deterministic function of the definition. Byte-locked against live
21
+ * `definecurrency` output across tokens and fractional baskets — see
22
+ * test/currency-outputs.test.ts. This produces the output *scripts*; funding,
23
+ * the identity input, and signing are assembled separately.
24
+ *
25
+ * For a same-chain token/basket the notarization is a fixed stub (nVersion 2,
26
+ * flags 0x83, null prev-refs, empty state maps) — it does NOT depend on live
27
+ * notarization state, which is why the launch can be built off a lite node.
28
+ */
29
+ const bn_js_1 = __importDefault(require("bn.js"));
30
+ const boundary_js_1 = require("../fork/boundary.js");
31
+ const index_js_1 = require("../utils/index.js");
32
+ const index_js_2 = require("../identity/index.js");
33
+ const errors_js_1 = require("../errors.js");
34
+ const definition_js_1 = require("./definition.js");
35
+ const wire_js_1 = require("./wire.js");
36
+ // CryptoCondition eval codes and the daemon's fixed destination pubkeys
37
+ // (`src/cc/CCcustom.cpp`). Chain-independent, so safe to embed. The import
38
+ // output is special: it pays to the Hash160 of its pubkey (TYPE_PKH), not the
39
+ // raw pubkey (TYPE_PK) every other CC output uses.
40
+ const EVAL_CROSSCHAIN_IMPORT = 13;
41
+ const EVAL_ACCEPTEDNOTARIZATION = 5;
42
+ const EVAL_CROSSCHAIN_EXPORT = 12;
43
+ const EVAL_RESERVE_DEPOSIT = 11;
44
+ const CC_PUBKEY = {
45
+ [EVAL_ACCEPTEDNOTARIZATION]: '02d85f078815b7a52faa92639c3691d2a640e26c4e06de54dd1490f0e93bcc11c3',
46
+ [EVAL_CROSSCHAIN_EXPORT]: '02cbfe54fb371cfc89d35b46cafcad6ac3b7dc9b40546b0f30b2b29a4865ed3b4a',
47
+ [EVAL_RESERVE_DEPOSIT]: '03b99d7cb946c5b1f8a54cde49b8d7e0a2a15a22639feb798009f82b519526c050',
48
+ };
49
+ // Hash160 of the EVAL_CROSSCHAIN_IMPORT pubkey (038d259e…). The import output's
50
+ // destination is this KeyID, not the pubkey.
51
+ const CC_IMPORT_KEYHASH = Buffer.from('6e4ae35cca122eb65e73abd4c956940ef25a3eab', 'hex');
52
+ // Identity flags (`identity.h`).
53
+ const IDENTITY_FLAG_ACTIVECURRENCY = 1;
54
+ const IDENTITY_FLAG_TOKENIZED_ID_CONTROL = 4;
55
+ function pubkeyDest(evalCode) {
56
+ return { kind: 'pubkey', pubkey: Buffer.from(CC_PUBKEY[evalCode], 'hex') };
57
+ }
58
+ /** Output 0: re-issue the defining identity with FLAG_ACTIVECURRENCY (+ TOKENIZED_ID_CONTROL for NFTs). */
59
+ function buildIdentityUpdateOutput(identityJson, options) {
60
+ const identity = boundary_js_1.Identity.fromJson(identityJson);
61
+ // An identity may define a currency only once (pbaas.cpp:4533 "Identity already
62
+ // has used its one-time ability to define a currency"). If FLAG_ACTIVECURRENCY
63
+ // is already set, the launch is doomed — fail closed instead of signing it.
64
+ if (identity.flags.and(new bn_js_1.default(IDENTITY_FLAG_ACTIVECURRENCY)).gtn(0)) {
65
+ throw new errors_js_1.TransactionBuildError('identity already has an active currency (FLAG_ACTIVECURRENCY set); a currency can be defined only once per identity');
66
+ }
67
+ identity.flags = identity.flags.or(new bn_js_1.default(IDENTITY_FLAG_ACTIVECURRENCY));
68
+ if (options & definition_js_1.CURRENCY_OPTION.NFT_TOKEN) {
69
+ identity.flags = identity.flags.or(new bn_js_1.default(IDENTITY_FLAG_TOKENIZED_ID_CONTROL));
70
+ }
71
+ return { script: (0, index_js_2.buildIdentityScript)(identity).toString('hex'), value: 0n };
72
+ }
73
+ /** Output 2: same-chain currency-definition import stub (`CCrossChainImport`). */
74
+ function serializeImport(systemHash, currencyHash, exportTxOutNum, height) {
75
+ return Buffer.concat([
76
+ (0, wire_js_1.uint16LE)(1, 'import.version'),
77
+ (0, wire_js_1.uint16LE)(0x0009, 'import.flags'), // DEFINITION_IMPORT(1) | SAME_CHAIN(8)
78
+ (0, wire_js_1.uint160Raw)(systemHash, 'import.sourceSystemID'),
79
+ (0, wire_js_1.uint32LE)(height, 'import.sourceSystemHeight'),
80
+ (0, wire_js_1.uint160Raw)(currencyHash, 'import.importCurrencyID'),
81
+ (0, wire_js_1.currencyValueMap)([], 'import.importValue'),
82
+ (0, wire_js_1.currencyValueMap)([], 'import.totalReserveOutMap'),
83
+ (0, wire_js_1.int32LE)(0, 'import.numOutputs'),
84
+ (0, wire_js_1.uint256Raw)(wire_js_1.ZEROS_32, 'import.hashReserveTransfers'),
85
+ (0, wire_js_1.uint256Raw)(wire_js_1.ZEROS_32, 'import.exportTxId'),
86
+ (0, wire_js_1.int32LE)(exportTxOutNum, 'import.exportTxOutNum'),
87
+ ]);
88
+ }
89
+ /**
90
+ * The `CCoinbaseCurrencyState` embedded in the definition notarization. For a
91
+ * fresh fractional currency the pre-launch conversion price is the Bancor price
92
+ * with reserves substituted by SATOSHIDEN: `SATS³ / (initialSupply · weight[i])`
93
+ * (integer floor). Weights MUST be the normalized weights the definition carries
94
+ * — verified byte-exact against the daemon for even and uneven splits.
95
+ */
96
+ function serializeCoinbaseCurrencyState(currencyHash, reserveHashes, normalizedWeights, isFractional, initialFractionalSupply, tokenSupply) {
97
+ const n = reserveHashes.length;
98
+ const zeroVec = () => Buffer.concat([(0, index_js_1.writeCompactSize)(n), ...Array.from({ length: n }, () => (0, wire_js_1.int64LE)(0n, 'state.zero'))]);
99
+ const supply = isFractional ? initialFractionalSupply : tokenSupply;
100
+ // The state's weight vector is always one entry per currency: the normalized
101
+ // weights for a fractional basket, or all-zero for a currency-mapped token
102
+ // (e.g. an NFT, whose definition carries no weights but whose state carries a
103
+ // zero weight for the mapped system currency).
104
+ const stateWeights = normalizedWeights.length === n ? normalizedWeights : new Array(n).fill(0n);
105
+ const parts = [
106
+ (0, wire_js_1.uint16LE)(1, 'state.version'),
107
+ (0, wire_js_1.uint16LE)(isFractional ? 0x0003 : 0x0002, 'state.flags'), // PRELAUNCH(2) [| FRACTIONAL(1)]
108
+ (0, wire_js_1.uint160Raw)(currencyHash, 'state.currencyID'),
109
+ (0, index_js_1.writeCompactSize)(n),
110
+ ...reserveHashes.map((h, i) => (0, wire_js_1.uint160Raw)(h, `state.currencies[${i}]`)),
111
+ (0, index_js_1.writeCompactSize)(n),
112
+ ...stateWeights.map((w, i) => (0, wire_js_1.int32LE)(Number(w), `state.weights[${i}]`)),
113
+ zeroVec(), // reserves — zero at definition (no preconversions yet)
114
+ (0, wire_js_1.varInt)(isFractional ? initialFractionalSupply : 0n, 'state.initialSupply'),
115
+ (0, wire_js_1.varInt)(0n, 'state.emitted'),
116
+ (0, wire_js_1.varInt)(supply, 'state.supply'),
117
+ // CCoinbaseCurrencyState extension — all-zero at definition.
118
+ (0, wire_js_1.int64LE)(0n, 'state.primaryCurrencyOut'),
119
+ (0, wire_js_1.int64LE)(0n, 'state.preConvertedOut'),
120
+ (0, wire_js_1.int64LE)(0n, 'state.primaryCurrencyFees'),
121
+ (0, wire_js_1.int64LE)(0n, 'state.primaryCurrencyConversionFees'),
122
+ zeroVec(), // reserveIn
123
+ zeroVec(), // primaryCurrencyIn
124
+ zeroVec(), // reserveOut
125
+ // conversionPrice (Bancor, reserves→SATOSHIDEN substitution)
126
+ (0, index_js_1.writeCompactSize)(n),
127
+ ...stateWeights.map((w, i) => {
128
+ const price = isFractional && initialFractionalSupply > 0n && w > 0n
129
+ ? (wire_js_1.SATOSHIDEN * wire_js_1.SATOSHIDEN * wire_js_1.SATOSHIDEN) / (initialFractionalSupply * w)
130
+ : 0n;
131
+ return (0, wire_js_1.int64LE)(price, `state.conversionPrice[${i}]`);
132
+ }),
133
+ zeroVec(), // viaConversionPrice
134
+ zeroVec(), // fees
135
+ // priorWeights — zero at definition (int32 vector, one per reserve).
136
+ (0, index_js_1.writeCompactSize)(n),
137
+ ...stateWeights.map((_, i) => (0, wire_js_1.int32LE)(0, `state.priorWeights[${i}]`)),
138
+ zeroVec(), // conversionFees
139
+ ];
140
+ return Buffer.concat(parts);
141
+ }
142
+ /** Output 3 body: `CPBaaSNotarization` definition stub. */
143
+ function serializeNotarization(currencyHash, currencyState, height) {
144
+ return Buffer.concat([
145
+ (0, wire_js_1.varInt)(2n, 'notarization.version'), // CPBaaSNotarization::VERSION_CURRENT on VRSC/VRSCTEST
146
+ (0, wire_js_1.varInt)(0x83n, 'notarization.flags'), // DEF_NOTARIZATION(1) | PRE_LAUNCH(2) | SAME_CHAIN(0x80)
147
+ Buffer.from([0x00, 0x00]), // proposer: empty CTransferDestination
148
+ (0, wire_js_1.uint160Raw)(currencyHash, 'notarization.currencyID'),
149
+ currencyState,
150
+ (0, wire_js_1.uint32LE)(height, 'notarization.notarizationHeight'),
151
+ (0, wire_js_1.uint256Raw)(wire_js_1.ZEROS_32, 'notarization.prevNotarization.hash'),
152
+ (0, wire_js_1.uint32LE)(0xffffffff, 'notarization.prevNotarization.n'),
153
+ (0, wire_js_1.uint256Raw)(wire_js_1.ZEROS_32, 'notarization.hashPrevCrossNotarization'),
154
+ (0, wire_js_1.uint32LE)(0, 'notarization.prevHeight'),
155
+ (0, index_js_1.writeCompactSize)(0), // currencyStates map (empty) — version ≥ 2
156
+ (0, index_js_1.writeCompactSize)(0), // proofRoots map (empty) — version ≥ 2
157
+ (0, index_js_1.writeCompactSize)(0), // nodes vector (empty)
158
+ ]);
159
+ }
160
+ /** Output 4: same-chain currency-definition export stub (`CCrossChainExport`). */
161
+ function serializeExport(systemHash, currencyHash, height, fee) {
162
+ return Buffer.concat([
163
+ (0, wire_js_1.uint16LE)(1, 'export.version'),
164
+ (0, wire_js_1.uint16LE)(0x0041, 'export.flags'), // DEFINITION_EXPORT(0x40) | PRELAUNCH(1)
165
+ (0, wire_js_1.uint160Raw)(systemHash, 'export.sourceSystemID'),
166
+ (0, wire_js_1.uint256Raw)(wire_js_1.ZEROS_32, 'export.hashReserveTransfers'),
167
+ (0, wire_js_1.uint160Raw)(systemHash, 'export.destSystemID'), // same chain
168
+ (0, wire_js_1.uint160Raw)(currencyHash, 'export.destCurrencyID'),
169
+ Buffer.from([0x00, 0x00]), // exporter: empty CTransferDestination
170
+ (0, wire_js_1.int32LE)(-1, 'export.firstInput'),
171
+ (0, wire_js_1.int32LE)(0, 'export.numInputs'),
172
+ (0, wire_js_1.varInt)(0n, 'export.sourceHeightStart'),
173
+ (0, wire_js_1.varInt)(BigInt(height), 'export.sourceHeightEnd'),
174
+ (0, wire_js_1.currencyValueMap)(fee, 'export.totalFees'),
175
+ (0, wire_js_1.currencyValueMap)(fee, 'export.totalAmounts'),
176
+ (0, wire_js_1.currencyValueMap)([], 'export.totalBurned'),
177
+ (0, index_js_1.writeCompactSize)(0), // reserveTransfers (empty)
178
+ ]);
179
+ }
180
+ /**
181
+ * Output 5 body: `CReserveDeposit` = single-value `CTokenOutput` + controlling
182
+ * currency. Note the value fields here are VARINT, not the int64 used elsewhere.
183
+ */
184
+ function serializeReserveDeposit(systemHash, controllingHash, amount) {
185
+ return Buffer.concat([
186
+ (0, wire_js_1.varInt)(1n, 'reserveDeposit.version'),
187
+ (0, wire_js_1.uint160Raw)(systemHash, 'reserveDeposit.currencyID'),
188
+ (0, wire_js_1.varInt)(amount, 'reserveDeposit.amount'),
189
+ (0, wire_js_1.uint160Raw)(controllingHash, 'reserveDeposit.controllingCurrencyID'),
190
+ ]);
191
+ }
192
+ /**
193
+ * Output 6: the change output — a CC output spendable by the defining identity.
194
+ * Hand-assembled (master `OptCCParams` m=0/n=0, params m=1/n=1 with a single
195
+ * DEST_ID destination) to match exactly what the daemon emits for currency-def
196
+ * change.
197
+ */
198
+ function buildIdentityChangeScript(identityHash) {
199
+ const master = Buffer.from([0x04, 0x03, 0x00, 0x00, 0x00]); // v3, eval 0, m0, n0
200
+ const idDest = Buffer.concat([Buffer.from([0x15, 0x04]), identityHash]); // push 21: type DEST_ID(4) + 20-byte id
201
+ const params = Buffer.concat([Buffer.from([0x04, 0x03, 0x00, 0x01, 0x01]), idDest]); // v3, eval 0, m1, n1
202
+ return Buffer.concat([
203
+ Buffer.from([master.length]),
204
+ master,
205
+ Buffer.from([0xcc]), // OP_CHECKCRYPTOCONDITION
206
+ Buffer.from([params.length]),
207
+ params,
208
+ Buffer.from([0x75]), // OP_DROP
209
+ ]);
210
+ }
211
+ /**
212
+ * Build all seven output scripts of a currency-definition transaction offline,
213
+ * byte-equivalent to what `definecurrency` produces. The currency is defined
214
+ * under an identity of the same name; its i-address (from `context.identity`) is
215
+ * the new currency's id.
216
+ */
217
+ function buildCurrencyLaunchOutputs(input, context) {
218
+ const def = (0, definition_js_1.normalizeCurrencyDefinition)(input);
219
+ const identityAddress = context.identity.identityaddress;
220
+ if (typeof identityAddress !== 'string' || !identityAddress) {
221
+ throw new errors_js_1.TransactionBuildError('context.identity.identityaddress is required');
222
+ }
223
+ // The new currency's id is derived from its name + parent, and MUST equal the
224
+ // defining identity's address — the import/notarization/export/state outputs all
225
+ // reference it, so a mismatched identity (or a typo'd name/parent) would build
226
+ // and sign a transaction the daemon rejects with an opaque error. Fail closed.
227
+ const derivedId = (0, index_js_2.deriveIdentityAddress)(def.name, def.parent);
228
+ if (derivedId !== identityAddress) {
229
+ throw new errors_js_1.TransactionBuildError(`identity mismatch: currency "${def.name}" under ${def.parent} derives ${derivedId}, ` +
230
+ `but context.identity.identityaddress is ${identityAddress}`);
231
+ }
232
+ if (!Number.isInteger(context.height) || context.height < 0) {
233
+ throw new errors_js_1.TransactionBuildError(`context.height must be a non-negative block height, got ${context.height}`);
234
+ }
235
+ // A launch's start block must be in the future: the daemon clamps startBlock to
236
+ // above the tip (pbaasrpc.cpp:13491) and never emits a past/zero one, so a
237
+ // startBlock ≤ tip would clear the launch immediately (a state no daemon-built
238
+ // definition produces — instant launch-failure/refund for a preconvert basket).
239
+ if (def.startBlock <= context.height) {
240
+ throw new errors_js_1.TransactionBuildError(`startBlock (${def.startBlock}) must be greater than the current height (${context.height})`);
241
+ }
242
+ // The currency's system must be this chain (pbaasrpc.cpp:13450 forces
243
+ // systemID = chain id for every same-chain token). The defining identity's
244
+ // `systemid` is that chain, so mismatch here means a wrong systemId/parent.
245
+ if (typeof context.identity.systemid === 'string' && def.systemId !== context.identity.systemid) {
246
+ throw new errors_js_1.TransactionBuildError(`currency systemId (${def.systemId}) must equal the chain system id (${String(context.identity.systemid)})`);
247
+ }
248
+ if (context.launchFeeSats <= 0n) {
249
+ throw new errors_js_1.TransactionBuildError('context.launchFeeSats must be positive');
250
+ }
251
+ const systemHash = (0, index_js_1.iAddressToHash)(def.systemId);
252
+ const currencyHash = (0, index_js_1.iAddressToHash)(identityAddress);
253
+ const reserveHashes = def.currencies.map((c) => (0, index_js_1.iAddressToHash)(c));
254
+ const isFractional = Boolean(def.options & definition_js_1.CURRENCY_OPTION.FRACTIONAL);
255
+ // Half the launch fee funds the reserve deposit; the export/import threads
256
+ // carry the same amount as their fee. The token supply in the state is the sum
257
+ // of pre-allocations (fractional currencies wait for preconversions).
258
+ // LaunchFeeImportShare = fee - (fee >> 1): the ceiling half for odd fees, so the
259
+ // reserve deposit matches consensus byte-for-byte (crosschainrpc.h:1039-1047).
260
+ const importFee = context.launchFeeSats - context.launchFeeSats / 2n;
261
+ const tokenSupply = def.preAllocations.reduce((sum, p) => sum + p.amount, 0n);
262
+ const feeEntry = [{ hash: systemHash, amount: importFee }];
263
+ const identityUpdate = buildIdentityUpdateOutput(context.identity, def.options);
264
+ const currencyDefinition = {
265
+ script: (0, definition_js_1.buildCurrencyDefinitionScript)(input),
266
+ value: 0n,
267
+ };
268
+ const importOutput = {
269
+ // exportTxOutNum = 4 points at the export output (same tx).
270
+ script: (0, wire_js_1.wrapCcOutput)(EVAL_CROSSCHAIN_IMPORT, [serializeImport(systemHash, currencyHash, 4, context.height)], {
271
+ kind: 'keyid',
272
+ hash: CC_IMPORT_KEYHASH,
273
+ }).toString('hex'),
274
+ value: 0n,
275
+ };
276
+ const currencyState = serializeCoinbaseCurrencyState(currencyHash, reserveHashes, def.weights, isFractional, def.initialFractionalSupply, tokenSupply);
277
+ const notarization = {
278
+ script: (0, wire_js_1.wrapCcOutput)(EVAL_ACCEPTEDNOTARIZATION, [serializeNotarization(currencyHash, currencyState, context.height)], pubkeyDest(EVAL_ACCEPTEDNOTARIZATION)).toString('hex'),
279
+ value: 0n,
280
+ };
281
+ const exportOutput = {
282
+ script: (0, wire_js_1.wrapCcOutput)(EVAL_CROSSCHAIN_EXPORT, [serializeExport(systemHash, currencyHash, context.height, feeEntry)], pubkeyDest(EVAL_CROSSCHAIN_EXPORT)).toString('hex'),
283
+ value: 0n,
284
+ };
285
+ const reserveDeposit = {
286
+ script: (0, wire_js_1.wrapCcOutput)(EVAL_RESERVE_DEPOSIT, [serializeReserveDeposit(systemHash, currencyHash, importFee)], pubkeyDest(EVAL_RESERVE_DEPOSIT)).toString('hex'),
287
+ value: importFee,
288
+ };
289
+ const change = {
290
+ script: buildIdentityChangeScript(currencyHash).toString('hex'),
291
+ value: 0n,
292
+ };
293
+ const ordered = [identityUpdate, currencyDefinition, importOutput, notarization, exportOutput, reserveDeposit, change];
294
+ return { identityUpdate, currencyDefinition, import: importOutput, notarization, export: exportOutput, reserveDeposit, change, ordered };
295
+ }
296
+ //# sourceMappingURL=outputs.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"outputs.js","sourceRoot":"","sources":["../../src/currency/outputs.ts"],"names":[],"mappings":";;;;;AA+RA,gEAgHC;AA/YD;;;;;;;;;;;;;;;;;;;;;GAqBG;AACH,kDAAuB;AACvB,qDAA+C;AAC/C,gDAAqE;AACrE,mDAAkF;AAClF,4CAAqD;AACrD,mDAMyB;AACzB,uCAYmB;AAEnB,wEAAwE;AACxE,2EAA2E;AAC3E,8EAA8E;AAC9E,mDAAmD;AACnD,MAAM,sBAAsB,GAAG,EAAE,CAAC;AAClC,MAAM,yBAAyB,GAAG,CAAC,CAAC;AACpC,MAAM,sBAAsB,GAAG,EAAE,CAAC;AAClC,MAAM,oBAAoB,GAAG,EAAE,CAAC;AAEhC,MAAM,SAAS,GAAG;IAChB,CAAC,yBAAyB,CAAC,EAAE,oEAAoE;IACjG,CAAC,sBAAsB,CAAC,EAAE,oEAAoE;IAC9F,CAAC,oBAAoB,CAAC,EAAE,oEAAoE;CACpF,CAAC;AACX,gFAAgF;AAChF,6CAA6C;AAC7C,MAAM,iBAAiB,GAAG,MAAM,CAAC,IAAI,CAAC,0CAA0C,EAAE,KAAK,CAAC,CAAC;AAEzF,iCAAiC;AACjC,MAAM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