@chainvue/verus-sdk 0.4.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 (64) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +75 -0
  3. package/dist/VerusSDK.d.ts +59 -0
  4. package/dist/VerusSDK.d.ts.map +1 -0
  5. package/dist/VerusSDK.js +170 -0
  6. package/dist/VerusSDK.js.map +1 -0
  7. package/dist/address/index.d.ts +16 -0
  8. package/dist/address/index.d.ts.map +1 -0
  9. package/dist/address/index.js +33 -0
  10. package/dist/address/index.js.map +1 -0
  11. package/dist/bundle.js +34129 -0
  12. package/dist/constants/index.d.ts +51 -0
  13. package/dist/constants/index.d.ts.map +1 -0
  14. package/dist/constants/index.js +53 -0
  15. package/dist/constants/index.js.map +1 -0
  16. package/dist/currency/classify.d.ts +14 -0
  17. package/dist/currency/classify.d.ts.map +1 -0
  18. package/dist/currency/classify.js +32 -0
  19. package/dist/currency/classify.js.map +1 -0
  20. package/dist/currency/index.d.ts +22 -0
  21. package/dist/currency/index.d.ts.map +1 -0
  22. package/dist/currency/index.js +87 -0
  23. package/dist/currency/index.js.map +1 -0
  24. package/dist/errors.d.ts +37 -0
  25. package/dist/errors.d.ts.map +1 -0
  26. package/dist/errors.js +69 -0
  27. package/dist/errors.js.map +1 -0
  28. package/dist/identity/index.d.ts +129 -0
  29. package/dist/identity/index.d.ts.map +1 -0
  30. package/dist/identity/index.js +691 -0
  31. package/dist/identity/index.js.map +1 -0
  32. package/dist/index.d.ts +24 -0
  33. package/dist/index.d.ts.map +1 -0
  34. package/dist/index.js +96 -0
  35. package/dist/index.js.map +1 -0
  36. package/dist/keys/index.d.ts +48 -0
  37. package/dist/keys/index.d.ts.map +1 -0
  38. package/dist/keys/index.js +169 -0
  39. package/dist/keys/index.js.map +1 -0
  40. package/dist/message/index.d.ts +18 -0
  41. package/dist/message/index.d.ts.map +1 -0
  42. package/dist/message/index.js +61 -0
  43. package/dist/message/index.js.map +1 -0
  44. package/dist/signing/index.d.ts +53 -0
  45. package/dist/signing/index.d.ts.map +1 -0
  46. package/dist/signing/index.js +100 -0
  47. package/dist/signing/index.js.map +1 -0
  48. package/dist/transfer/index.d.ts +37 -0
  49. package/dist/transfer/index.d.ts.map +1 -0
  50. package/dist/transfer/index.js +275 -0
  51. package/dist/transfer/index.js.map +1 -0
  52. package/dist/types/index.d.ts +359 -0
  53. package/dist/types/index.d.ts.map +1 -0
  54. package/dist/types/index.js +6 -0
  55. package/dist/types/index.js.map +1 -0
  56. package/dist/utils/index.d.ts +48 -0
  57. package/dist/utils/index.d.ts.map +1 -0
  58. package/dist/utils/index.js +141 -0
  59. package/dist/utils/index.js.map +1 -0
  60. package/dist/utxo/index.d.ts +21 -0
  61. package/dist/utxo/index.d.ts.map +1 -0
  62. package/dist/utxo/index.js +139 -0
  63. package/dist/utxo/index.js.map +1 -0
  64. package/package.json +65 -0
@@ -0,0 +1,100 @@
1
+ "use strict";
2
+ /**
3
+ * Transaction signing using @bitgo/utxo-lib
4
+ *
5
+ * Wraps the Verus fork of utxo-lib's TransactionBuilder to handle:
6
+ * - Standard P2PKH signing
7
+ * - Smart transaction signing (CryptoConditions/OptCCParams)
8
+ * - Mixed transactions (P2PKH inputs + smart tx inputs)
9
+ */
10
+ Object.defineProperty(exports, "__esModule", { value: true });
11
+ exports.getNetwork = getNetwork;
12
+ exports.signTransactionSmart = signTransactionSmart;
13
+ exports.signTransactionMultiKey = signTransactionMultiKey;
14
+ exports.createTransactionBuilder = createTransactionBuilder;
15
+ exports.validateFundedTransaction = validateFundedTransaction;
16
+ const utxo_lib_1 = require("@bitgo/utxo-lib");
17
+ const index_js_1 = require("../constants/index.js");
18
+ const { getFundedTxBuilder, validateFundedCurrencyTransfer } = utxo_lib_1.smarttxs;
19
+ /**
20
+ * Get the Verus network config
21
+ */
22
+ function getNetwork(testnet = false) {
23
+ return testnet ? utxo_lib_1.networks.verustest : utxo_lib_1.networks.verus;
24
+ }
25
+ /**
26
+ * Sign a pre-built transaction hex with a single WIF key
27
+ *
28
+ * `maxFeeSats`: utxo-lib's TransactionBuilder enforces a last-resort fee-RATE
29
+ * cap (default 2500 sat/vbyte) at build() and throws "Transaction has absurd
30
+ * fees" above it. An identity registration intentionally burns the protocol
31
+ * fee (~100 native) as an implicit miner fee — far above any sane rate cap —
32
+ * so callers that KNOW their intended absolute fee pass it here. It is
33
+ * converted into a rate bound using the unsigned hex size as a lower bound of
34
+ * the final vsize (signatures only grow a tx), so the guard still trips if
35
+ * the actual fee materially exceeds the declared one.
36
+ */
37
+ function signTransactionSmart(txHex, wif, utxos, network = utxo_lib_1.networks.verus, maxFeeSats) {
38
+ const keyPair = utxo_lib_1.ECPair.fromWIF(wif, network);
39
+ const prevOutScripts = utxos.map((u) => Buffer.from(u.script, 'hex'));
40
+ const txb = getFundedTxBuilder(txHex, network, prevOutScripts);
41
+ if (maxFeeSats !== undefined) {
42
+ // The fork's .d.ts omits maximumFeeRate, but it exists at runtime
43
+ // (transaction_builder.js: `this.maximumFeeRate = maximumFeeRate || 2500`).
44
+ txb.maximumFeeRate = Math.ceil(maxFeeSats / (txHex.length / 2));
45
+ }
46
+ for (let i = 0; i < utxos.length; i++) {
47
+ txb.sign(i, keyPair, null, utxo_lib_1.Transaction.SIGHASH_ALL, utxos[i].satoshis);
48
+ }
49
+ const signedTx = txb.build();
50
+ return {
51
+ signedTx: signedTx.toHex(),
52
+ txid: signedTx.getId(),
53
+ };
54
+ }
55
+ /**
56
+ * Sign a transaction with multiple keys (for multi-signature or mixed-authority inputs)
57
+ */
58
+ function signTransactionMultiKey(txHex, keys, utxos, network = utxo_lib_1.networks.verus) {
59
+ const prevOutScripts = utxos.map((u) => Buffer.from(u.script, 'hex'));
60
+ const txb = getFundedTxBuilder(txHex, network, prevOutScripts);
61
+ for (let i = 0; i < keys.length; i++) {
62
+ if (!keys[i] || keys[i].length === 0)
63
+ continue;
64
+ for (const wif of keys[i]) {
65
+ if (!wif)
66
+ continue;
67
+ const keyPair = utxo_lib_1.ECPair.fromWIF(wif, network);
68
+ txb.sign(i, keyPair, null, utxo_lib_1.Transaction.SIGHASH_ALL, utxos[i].satoshis);
69
+ }
70
+ }
71
+ const signedTx = txb.build();
72
+ return {
73
+ signedTx: signedTx.toHex(),
74
+ txid: signedTx.getId(),
75
+ };
76
+ }
77
+ /**
78
+ * Create a new TransactionBuilder for manual transaction construction
79
+ */
80
+ function createTransactionBuilder(network = utxo_lib_1.networks.verus, expiryHeight = 0, version = 4, versionGroupId = index_js_1.VERSION_GROUP_ID) {
81
+ const txb = new utxo_lib_1.TransactionBuilder(network);
82
+ txb.setVersion(version);
83
+ txb.setExpiryHeight(expiryHeight);
84
+ txb.setVersionGroupId(versionGroupId);
85
+ return txb;
86
+ }
87
+ /**
88
+ * Validate a funded transaction against its unfunded version
89
+ */
90
+ function validateFundedTransaction(systemId, fundedTxHex, unfundedTxHex, changeAddress, network, utxoList) {
91
+ const result = validateFundedCurrencyTransfer(systemId, fundedTxHex, unfundedTxHex, changeAddress, network, utxoList.map((u) => ({
92
+ txid: u.txid,
93
+ outputIndex: u.outputIndex,
94
+ satoshis: u.satoshis,
95
+ script: u.script,
96
+ height: u.height || 0,
97
+ })));
98
+ return result;
99
+ }
100
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/signing/index.ts"],"names":[],"mappings":";AAAA;;;;;;;GAOG;;AAoBH,gCAEC;AAcD,oDA4BC;AAKD,0DAuBC;AAKD,4DAWC;AAKD,8DA6BC;AA5ID,8CAMyB;AAEzB,oDAAyD;AAEzD,MAAM,EAAE,kBAAkB,EAAE,8BAA8B,EAAE,GAAG,mBAAQ,CAAC;AAKxE;;GAEG;AACH,SAAgB,UAAU,CAAC,UAAmB,KAAK;IACjD,OAAO,OAAO,CAAC,CAAC,CAAC,mBAAQ,CAAC,SAAS,CAAC,CAAC,CAAC,mBAAQ,CAAC,KAAK,CAAC;AACvD,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C,iBAAiB,CAAC,cAAc,CAAC,CAAC;IACtC,OAAO,GAAG,CAAC;AACb,CAAC;AAED;;GAEG;AACH,SAAgB,yBAAyB,CACvC,QAAgB,EAChB,WAAmB,EACnB,aAAqB,EACrB,aAAqB,EACrB,OAAqB,EACrB,QAAgB;IAOhB,MAAM,MAAM,GAAG,8BAA8B,CAC3C,QAAQ,EACR,WAAW,EACX,aAAa,EACb,aAAa,EACb,OAAO,EACP,QAAQ,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC;QACnB,IAAI,EAAE,CAAC,CAAC,IAAI;QACZ,WAAW,EAAE,CAAC,CAAC,WAAW;QAC1B,QAAQ,EAAE,CAAC,CAAC,QAAQ;QACpB,MAAM,EAAE,CAAC,CAAC,MAAM;QAChB,MAAM,EAAE,CAAC,CAAC,MAAM,IAAI,CAAC;KACtB,CAAC,CAAC,CACJ,CAAC;IAEF,OAAO,MAAM,CAAC;AAChB,CAAC"}
@@ -0,0 +1,37 @@
1
+ /**
2
+ * Transfer orchestration
3
+ *
4
+ * Handles all types of Verus currency operations:
5
+ * - Simple native (VRSC) transfers
6
+ * - Token/currency transfers
7
+ * - Currency conversions
8
+ * - Reserve-to-reserve conversions
9
+ * - Cross-chain transfers
10
+ * - Simple P2PKH build+sign
11
+ */
12
+ import type { Network } from '../constants/index.js';
13
+ import type { SendCurrencyParams, SendCurrencyResult, TransferParams, TransferTokenParams, ConvertParams, BuildAndSignParams, SignedTxResult } from '../types/index.js';
14
+ /**
15
+ * Build and sign a currency transfer transaction (full control)
16
+ *
17
+ * Supports native VRSC transfers, token transfers, conversions,
18
+ * reserve-to-reserve, and cross-chain transfers.
19
+ */
20
+ export declare function sendCurrency(params: SendCurrencyParams, network: Network): SendCurrencyResult;
21
+ /**
22
+ * Simple native VRSC transfer to an R-address
23
+ */
24
+ export declare function transfer(params: TransferParams, network: Network): SendCurrencyResult;
25
+ /**
26
+ * Token/currency transfer
27
+ */
28
+ export declare function transferToken(params: TransferTokenParams, network: Network): SendCurrencyResult;
29
+ /**
30
+ * Currency conversion
31
+ */
32
+ export declare function convert(params: ConvertParams, network: Network): SendCurrencyResult;
33
+ /**
34
+ * Build and sign a simple P2PKH transaction from explicit inputs/outputs
35
+ */
36
+ export declare function buildAndSign(params: BuildAndSignParams, network: Network): SignedTxResult;
37
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/transfer/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AAYH,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,uBAAuB,CAAC;AAOrD,OAAO,KAAK,EAGV,kBAAkB,EAClB,kBAAkB,EAClB,cAAc,EACd,mBAAmB,EACnB,aAAa,EACb,kBAAkB,EAClB,cAAc,EACf,MAAM,mBAAmB,CAAC;AA8D3B;;;;;GAKG;AACH,wBAAgB,YAAY,CAC1B,MAAM,EAAE,kBAAkB,EAC1B,OAAO,EAAE,OAAO,GACf,kBAAkB,CAmIpB;AAED;;GAEG;AACH,wBAAgB,QAAQ,CACtB,MAAM,EAAE,cAAc,EACtB,OAAO,EAAE,OAAO,GACf,kBAAkB,CAepB;AAED;;GAEG;AACH,wBAAgB,aAAa,CAC3B,MAAM,EAAE,mBAAmB,EAC3B,OAAO,EAAE,OAAO,GACf,kBAAkB,CAcpB;AAED;;GAEG;AACH,wBAAgB,OAAO,CACrB,MAAM,EAAE,aAAa,EACrB,OAAO,EAAE,OAAO,GACf,kBAAkB,CAgBpB;AAED;;GAEG;AACH,wBAAgB,YAAY,CAC1B,MAAM,EAAE,kBAAkB,EAC1B,OAAO,EAAE,OAAO,GACf,cAAc,CA6DhB"}
@@ -0,0 +1,275 @@
1
+ "use strict";
2
+ /**
3
+ * Transfer orchestration
4
+ *
5
+ * Handles all types of Verus currency operations:
6
+ * - Simple native (VRSC) transfers
7
+ * - Token/currency transfers
8
+ * - Currency conversions
9
+ * - Reserve-to-reserve conversions
10
+ * - Cross-chain transfers
11
+ * - Simple P2PKH build+sign
12
+ */
13
+ var __importDefault = (this && this.__importDefault) || function (mod) {
14
+ return (mod && mod.__esModule) ? mod : { "default": mod };
15
+ };
16
+ Object.defineProperty(exports, "__esModule", { value: true });
17
+ exports.sendCurrency = sendCurrency;
18
+ exports.transfer = transfer;
19
+ exports.transferToken = transferToken;
20
+ exports.convert = convert;
21
+ exports.buildAndSign = buildAndSign;
22
+ const utxo_lib_1 = require("@bitgo/utxo-lib");
23
+ const verus_typescript_primitives_1 = require("verus-typescript-primitives");
24
+ const bn_js_1 = __importDefault(require("bn.js"));
25
+ const bs58check_1 = __importDefault(require("bs58check"));
26
+ const index_js_1 = require("../constants/index.js");
27
+ const index_js_2 = require("../signing/index.js");
28
+ const index_js_3 = require("../utxo/index.js");
29
+ const index_js_4 = require("../identity/index.js");
30
+ const index_js_5 = require("../utils/index.js");
31
+ const errors_js_1 = require("../errors.js");
32
+ const index_js_6 = require("../keys/index.js");
33
+ const { createUnfundedCurrencyTransfer } = utxo_lib_1.smarttxs;
34
+ /** Validate common transfer parameters */
35
+ function validateTransferInputs(wif, utxos) {
36
+ if (!wif || typeof wif !== 'string') {
37
+ throw new errors_js_1.InvalidWifError('WIF is required');
38
+ }
39
+ const wifCheck = (0, index_js_6.validateWif)(wif);
40
+ if (!wifCheck.valid) {
41
+ throw new errors_js_1.InvalidWifError(wifCheck.error);
42
+ }
43
+ if (!utxos || utxos.length === 0) {
44
+ throw new errors_js_1.TransactionBuildError('At least one UTXO is required');
45
+ }
46
+ }
47
+ /** Validate amount is positive and finite */
48
+ function validateAmount(amount, label = 'amount') {
49
+ if (!Number.isFinite(amount) || amount <= 0) {
50
+ throw new errors_js_1.TransactionBuildError(`Invalid ${label}: must be a positive finite number (got ${amount})`);
51
+ }
52
+ }
53
+ /**
54
+ * Parse an address string into a TransferDestination
55
+ */
56
+ function parseAddress(address, addressType) {
57
+ let type;
58
+ let destinationBytes;
59
+ switch (addressType) {
60
+ case 'PKH': {
61
+ type = verus_typescript_primitives_1.DEST_PKH;
62
+ const decoded = bs58check_1.default.decode(address);
63
+ destinationBytes = Buffer.from(decoded.slice(1));
64
+ break;
65
+ }
66
+ case 'ID': {
67
+ type = verus_typescript_primitives_1.DEST_ID;
68
+ const decoded = bs58check_1.default.decode(address);
69
+ destinationBytes = Buffer.from(decoded.slice(1));
70
+ break;
71
+ }
72
+ case 'ETH': {
73
+ type = verus_typescript_primitives_1.DEST_ETH;
74
+ const addr = address.startsWith('0x') ? address.substring(2) : address;
75
+ destinationBytes = Buffer.from(addr, 'hex');
76
+ break;
77
+ }
78
+ default:
79
+ throw new Error(`Unsupported address type: ${addressType}`);
80
+ }
81
+ return new verus_typescript_primitives_1.TransferDestination({
82
+ type,
83
+ destination_bytes: destinationBytes,
84
+ fees: new bn_js_1.default(0, 10),
85
+ });
86
+ }
87
+ /**
88
+ * Build and sign a currency transfer transaction (full control)
89
+ *
90
+ * Supports native VRSC transfers, token transfers, conversions,
91
+ * reserve-to-reserve, and cross-chain transfers.
92
+ */
93
+ function sendCurrency(params, network) {
94
+ validateTransferInputs(params.wif, params.utxos);
95
+ if (!params.outputs || params.outputs.length === 0) {
96
+ throw new errors_js_1.TransactionBuildError('At least one output is required');
97
+ }
98
+ const networkConfig = index_js_1.NETWORK_CONFIG[network];
99
+ const verusNetwork = (0, index_js_2.getNetwork)(network === 'testnet');
100
+ const systemId = networkConfig.chainId;
101
+ const expiryHeight = params.expiryHeight || 0;
102
+ const txOutputs = params.outputs.map((out) => ({
103
+ currency: out.currency,
104
+ satoshis: out.satoshis,
105
+ address: parseAddress(out.address, out.addressType || 'PKH'),
106
+ convertto: out.convertTo,
107
+ exportto: out.exportTo,
108
+ via: out.via,
109
+ bridgeid: out.bridgeId,
110
+ feecurrency: out.feeCurrency,
111
+ feesatoshis: out.feeSatoshis,
112
+ preconvert: out.preconvert,
113
+ }));
114
+ const unfundedTxHex = createUnfundedCurrencyTransfer(systemId, txOutputs, verusNetwork, expiryHeight);
115
+ const unfundedTx = utxo_lib_1.Transaction.fromHex(unfundedTxHex, verusNetwork);
116
+ let requiredNative = 0;
117
+ for (const out of unfundedTx.outs) {
118
+ requiredNative += out.value;
119
+ }
120
+ const hasSmartOutputs = params.outputs.some((o) => o.convertTo || o.exportTo || o.via || o.currency !== systemId);
121
+ const requiredCurrencies = new Map();
122
+ for (const out of params.outputs) {
123
+ if (out.currency !== systemId) {
124
+ const amount = parseInt(out.satoshis, 10);
125
+ requiredCurrencies.set(out.currency, (requiredCurrencies.get(out.currency) || 0) + amount);
126
+ }
127
+ }
128
+ const selection = (0, index_js_3.selectUtxos)(params.utxos, requiredNative, requiredCurrencies, unfundedTx.outs.length, systemId, undefined, hasSmartOutputs);
129
+ const txb = new utxo_lib_1.TransactionBuilder(verusNetwork);
130
+ txb.setVersion(4);
131
+ txb.setExpiryHeight(expiryHeight);
132
+ txb.setVersionGroupId(index_js_1.VERSION_GROUP_ID);
133
+ for (const utxo of selection.selected) {
134
+ txb.addInput(Buffer.from(utxo.txid, 'hex').reverse(), utxo.outputIndex, 0xffffffff, Buffer.from(utxo.script, 'hex'));
135
+ }
136
+ for (const out of unfundedTx.outs) {
137
+ txb.addOutput(out.script, out.value);
138
+ }
139
+ if (selection.currencyChanges.size > 0) {
140
+ const tokenChange = (0, index_js_4.buildTokenChangeOutput)(params.changeAddress, selection.currencyChanges);
141
+ txb.addOutput(tokenChange.script, tokenChange.nativeValue);
142
+ }
143
+ if (selection.nativeChange > 0) {
144
+ // utxo-lib's addOutput only resolves base58 R-addresses; identity
145
+ // change (an i-address changeAddress) needs the explicit P2ID script —
146
+ // byte-identical to the chain's own pay-to-identity outputs.
147
+ if (params.changeAddress.startsWith('i')) {
148
+ txb.addOutput((0, index_js_4.identityPaymentScript)(params.changeAddress), selection.nativeChange);
149
+ }
150
+ else {
151
+ txb.addOutput(params.changeAddress, selection.nativeChange);
152
+ }
153
+ }
154
+ const unsignedTx = txb.buildIncomplete();
155
+ const { signedTx, txid } = (0, index_js_2.signTransactionSmart)(unsignedTx.toHex(), params.wif, selection.selected, verusNetwork);
156
+ // Defense in depth: utxo-lib's own funded-transfer validator re-checks the
157
+ // assembled tx against the unfunded intent (value conservation per
158
+ // currency, change to the declared change address, fee sanity). A
159
+ // selection/change bug here means money — refuse to hand out the hex.
160
+ const validation = (0, index_js_2.validateFundedTransaction)(systemId, signedTx, unfundedTxHex, params.changeAddress, verusNetwork, selection.selected);
161
+ if (!validation.valid) {
162
+ throw new errors_js_1.TransactionBuildError(`funded transaction failed validation: ${validation.message ?? 'no reason given'}`);
163
+ }
164
+ return {
165
+ signedTx,
166
+ txid,
167
+ fee: selection.fee,
168
+ inputsUsed: selection.selected.length,
169
+ nativeChange: selection.nativeChange,
170
+ };
171
+ }
172
+ /**
173
+ * Simple native VRSC transfer to an R-address
174
+ */
175
+ function transfer(params, network) {
176
+ validateAmount(params.amount);
177
+ const systemId = index_js_1.NETWORK_CONFIG[network].chainId;
178
+ return sendCurrency({
179
+ wif: params.wif,
180
+ outputs: [{
181
+ currency: systemId,
182
+ satoshis: params.amount.toString(),
183
+ address: params.to,
184
+ addressType: 'PKH',
185
+ }],
186
+ utxos: params.utxos,
187
+ changeAddress: params.changeAddress,
188
+ expiryHeight: params.expiryHeight,
189
+ }, network);
190
+ }
191
+ /**
192
+ * Token/currency transfer
193
+ */
194
+ function transferToken(params, network) {
195
+ validateAmount(params.amount);
196
+ return sendCurrency({
197
+ wif: params.wif,
198
+ outputs: [{
199
+ currency: params.currency,
200
+ satoshis: params.amount.toString(),
201
+ address: params.to,
202
+ addressType: params.addressType || 'PKH',
203
+ }],
204
+ utxos: params.utxos,
205
+ changeAddress: params.changeAddress,
206
+ expiryHeight: params.expiryHeight,
207
+ }, network);
208
+ }
209
+ /**
210
+ * Currency conversion
211
+ */
212
+ function convert(params, network) {
213
+ validateAmount(params.amount);
214
+ return sendCurrency({
215
+ wif: params.wif,
216
+ outputs: [{
217
+ currency: params.currency,
218
+ satoshis: params.amount.toString(),
219
+ address: params.changeAddress, // Conversion output goes to self
220
+ addressType: 'PKH',
221
+ convertTo: params.convertTo,
222
+ via: params.via,
223
+ }],
224
+ utxos: params.utxos,
225
+ changeAddress: params.changeAddress,
226
+ expiryHeight: params.expiryHeight,
227
+ }, network);
228
+ }
229
+ /**
230
+ * Build and sign a simple P2PKH transaction from explicit inputs/outputs
231
+ */
232
+ function buildAndSign(params, network) {
233
+ if (!params.wif || typeof params.wif !== 'string') {
234
+ throw new errors_js_1.InvalidWifError('WIF is required');
235
+ }
236
+ const wifCheck = (0, index_js_6.validateWif)(params.wif);
237
+ if (!wifCheck.valid) {
238
+ throw new errors_js_1.InvalidWifError(wifCheck.error);
239
+ }
240
+ if (!params.inputs || params.inputs.length === 0) {
241
+ throw new errors_js_1.TransactionBuildError('At least one input is required');
242
+ }
243
+ if (!params.outputs || params.outputs.length === 0) {
244
+ throw new errors_js_1.TransactionBuildError('At least one output is required');
245
+ }
246
+ const verusNetwork = (0, index_js_2.getNetwork)(network === 'testnet');
247
+ const totalInput = params.inputs.reduce((sum, i) => sum + i.amount, 0);
248
+ const totalOutput = params.outputs.reduce((sum, o) => sum + o.amount, 0);
249
+ const fee = params.fee || (totalInput - totalOutput);
250
+ if (totalOutput + fee > totalInput) {
251
+ throw new Error(`Insufficient funds. Input: ${totalInput}, Output: ${totalOutput}, Fee: ${fee}`);
252
+ }
253
+ // Use high maxFeeRate since callers explicitly control input/output amounts
254
+ const txb = new utxo_lib_1.TransactionBuilder(verusNetwork, Number.MAX_SAFE_INTEGER);
255
+ txb.setVersion(4);
256
+ txb.setExpiryHeight(params.expiryHeight || 0);
257
+ txb.setVersionGroupId(index_js_1.VERSION_GROUP_ID);
258
+ for (const inp of params.inputs) {
259
+ txb.addInput(Buffer.from(inp.txid, 'hex').reverse(), inp.vout, 0xffffffff, Buffer.from(inp.scriptPubKey, 'hex'));
260
+ }
261
+ for (const out of params.outputs) {
262
+ const script = (0, index_js_5.addressToScriptPubKey)(out.address);
263
+ txb.addOutput(script, out.amount);
264
+ }
265
+ const unsignedTx = txb.buildIncomplete();
266
+ const utxos = params.inputs.map((i) => ({
267
+ txid: i.txid,
268
+ outputIndex: i.vout,
269
+ satoshis: i.amount,
270
+ script: i.scriptPubKey,
271
+ }));
272
+ const { signedTx, txid } = (0, index_js_2.signTransactionSmart)(unsignedTx.toHex(), params.wif, utxos, verusNetwork);
273
+ return { signedTx, txid, fee };
274
+ }
275
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/transfer/index.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;GAUG;;;;;AAiGH,oCAsIC;AAKD,4BAkBC;AAKD,sCAiBC;AAKD,0BAmBC;AAKD,oCAgEC;AA/WD,8CAA4E;AAC5E,6EAKqC;AACrC,kDAAuB;AACvB,0DAAkC;AAClC,oDAAyE;AAEzE,kDAAkG;AAClG,+CAA+C;AAC/C,mDAAqF;AACrF,gDAA0D;AAC1D,4CAAsE;AACtE,+CAA+C;AAa/C,MAAM,EAAE,8BAA8B,EAAE,GAAG,mBAAQ,CAAC;AAEpD,0CAA0C;AAC1C,SAAS,sBAAsB,CAAC,GAAW,EAAE,KAAa;IACxD,IAAI,CAAC,GAAG,IAAI,OAAO,GAAG,KAAK,QAAQ,EAAE,CAAC;QACpC,MAAM,IAAI,2BAAe,CAAC,iBAAiB,CAAC,CAAC;IAC/C,CAAC;IACD,MAAM,QAAQ,GAAG,IAAA,sBAAW,EAAC,GAAG,CAAC,CAAC;IAClC,IAAI,CAAC,QAAQ,CAAC,KAAK,EAAE,CAAC;QACpB,MAAM,IAAI,2BAAe,CAAC,QAAQ,CAAC,KAAK,CAAC,CAAC;IAC5C,CAAC;IACD,IAAI,CAAC,KAAK,IAAI,KAAK,CAAC,MAAM,KAAK,CAAC,EAAE,CAAC;QACjC,MAAM,IAAI,iCAAqB,CAAC,+BAA+B,CAAC,CAAC;IACnE,CAAC;AACH,CAAC;AAED,6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