@onekeyfe/cardano-coin-selection-asmjs 1.1.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 (79) hide show
  1. package/CHANGELOG.MD +25 -0
  2. package/README.md +183 -0
  3. package/lib/cjs/constants/index.d.ts +40 -0
  4. package/lib/cjs/constants/index.js +69 -0
  5. package/lib/cjs/index.d.ts +6 -0
  6. package/lib/cjs/index.js +101 -0
  7. package/lib/cjs/methods/largestFirst.d.ts +2 -0
  8. package/lib/cjs/methods/largestFirst.js +201 -0
  9. package/lib/cjs/methods/randomImprove.d.ts +2 -0
  10. package/lib/cjs/methods/randomImprove.js +187 -0
  11. package/lib/cjs/types/trezor.d.ts +45 -0
  12. package/lib/cjs/types/trezor.js +8 -0
  13. package/lib/cjs/types/types.d.ts +116 -0
  14. package/lib/cjs/types/types.js +17 -0
  15. package/lib/cjs/utils/common.d.ts +46 -0
  16. package/lib/cjs/utils/common.js +514 -0
  17. package/lib/cjs/utils/errors.d.ts +8 -0
  18. package/lib/cjs/utils/errors.js +13 -0
  19. package/lib/cjs/utils/logger.d.ts +5 -0
  20. package/lib/cjs/utils/logger.js +27 -0
  21. package/lib/cjs/utils/onekey/dapp.d.ts +14 -0
  22. package/lib/cjs/utils/onekey/dapp.js +247 -0
  23. package/lib/cjs/utils/onekey/error.d.ts +28 -0
  24. package/lib/cjs/utils/onekey/error.js +25 -0
  25. package/lib/cjs/utils/onekey/index.d.ts +48 -0
  26. package/lib/cjs/utils/onekey/index.js +15 -0
  27. package/lib/cjs/utils/onekey/signTx.d.ts +26 -0
  28. package/lib/cjs/utils/onekey/signTx.js +296 -0
  29. package/lib/cjs/utils/onekey/transaction.d.ts +5 -0
  30. package/lib/cjs/utils/onekey/transaction.js +49 -0
  31. package/lib/cjs/utils/onekey/txToOneKey.d.ts +67 -0
  32. package/lib/cjs/utils/onekey/txToOneKey.js +504 -0
  33. package/lib/cjs/utils/onekey/types.d.ts +79 -0
  34. package/lib/cjs/utils/onekey/types.js +16 -0
  35. package/lib/cjs/utils/trezor/index.d.ts +3 -0
  36. package/lib/cjs/utils/trezor/index.js +9 -0
  37. package/lib/cjs/utils/trezor/sign.d.ts +5 -0
  38. package/lib/cjs/utils/trezor/sign.js +69 -0
  39. package/lib/cjs/utils/trezor/transformations.d.ts +17 -0
  40. package/lib/cjs/utils/trezor/transformations.js +66 -0
  41. package/lib/esm/constants/index.d.ts +40 -0
  42. package/lib/esm/constants/index.js +43 -0
  43. package/lib/esm/index.d.ts +6 -0
  44. package/lib/esm/index.js +73 -0
  45. package/lib/esm/methods/largestFirst.d.ts +2 -0
  46. package/lib/esm/methods/largestFirst.js +174 -0
  47. package/lib/esm/methods/randomImprove.d.ts +2 -0
  48. package/lib/esm/methods/randomImprove.js +160 -0
  49. package/lib/esm/types/trezor.d.ts +45 -0
  50. package/lib/esm/types/trezor.js +5 -0
  51. package/lib/esm/types/types.d.ts +116 -0
  52. package/lib/esm/types/types.js +14 -0
  53. package/lib/esm/utils/common.d.ts +46 -0
  54. package/lib/esm/utils/common.js +460 -0
  55. package/lib/esm/utils/errors.d.ts +8 -0
  56. package/lib/esm/utils/errors.js +9 -0
  57. package/lib/esm/utils/logger.d.ts +5 -0
  58. package/lib/esm/utils/logger.js +23 -0
  59. package/lib/esm/utils/onekey/dapp.d.ts +14 -0
  60. package/lib/esm/utils/onekey/dapp.js +216 -0
  61. package/lib/esm/utils/onekey/error.d.ts +28 -0
  62. package/lib/esm/utils/onekey/error.js +22 -0
  63. package/lib/esm/utils/onekey/index.d.ts +48 -0
  64. package/lib/esm/utils/onekey/index.js +11 -0
  65. package/lib/esm/utils/onekey/signTx.d.ts +26 -0
  66. package/lib/esm/utils/onekey/signTx.js +266 -0
  67. package/lib/esm/utils/onekey/transaction.d.ts +5 -0
  68. package/lib/esm/utils/onekey/transaction.js +42 -0
  69. package/lib/esm/utils/onekey/txToOneKey.d.ts +67 -0
  70. package/lib/esm/utils/onekey/txToOneKey.js +477 -0
  71. package/lib/esm/utils/onekey/types.d.ts +79 -0
  72. package/lib/esm/utils/onekey/types.js +15 -0
  73. package/lib/esm/utils/trezor/index.d.ts +3 -0
  74. package/lib/esm/utils/trezor/index.js +3 -0
  75. package/lib/esm/utils/trezor/sign.d.ts +5 -0
  76. package/lib/esm/utils/trezor/sign.js +42 -0
  77. package/lib/esm/utils/trezor/transformations.d.ts +17 -0
  78. package/lib/esm/utils/trezor/transformations.js +60 -0
  79. package/package.json +61 -0
@@ -0,0 +1,296 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
15
+ }) : function(o, v) {
16
+ o["default"] = v;
17
+ });
18
+ var __importStar = (this && this.__importStar) || function (mod) {
19
+ if (mod && mod.__esModule) return mod;
20
+ var result = {};
21
+ if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
22
+ __setModuleDefault(result, mod);
23
+ return result;
24
+ };
25
+ Object.defineProperty(exports, "__esModule", { value: true });
26
+ exports.requestAccountKey = exports.getUtxos = exports.signTx = exports.signTransaction = void 0;
27
+ const CardanoWasm = __importStar(require("@emurgo/cardano-serialization-lib-asmjs"));
28
+ const error_1 = require("./error");
29
+ const signTransaction = async (txBodyHex, address, accountIndex, utxos, xprv, signOnly, partialSign) => {
30
+ const { paymentKey, stakeKey, accountKey } = await (0, exports.requestAccountKey)(xprv, accountIndex);
31
+ const serializedUtxos = await (0, exports.getUtxos)(address, utxos);
32
+ if (!serializedUtxos || serializedUtxos === null) {
33
+ throw new Error('no utxos');
34
+ }
35
+ const transactionWitnessSet = CardanoWasm.TransactionWitnessSet.new();
36
+ const rawTx = CardanoWasm.Transaction.new(CardanoWasm.TransactionBody.from_hex(txBodyHex), CardanoWasm.TransactionWitnessSet.from_bytes(transactionWitnessSet.to_bytes()));
37
+ const keyHashes = await getKeyHashes(rawTx, serializedUtxos, { paymentAddr: address });
38
+ const witnessSet = await (0, exports.signTx)({ paymentKey, stakeKey, accountKey }, Buffer.from(rawTx.to_bytes(), 'utf8').toString('hex'), keyHashes.key, partialSign);
39
+ if (signOnly) {
40
+ return {
41
+ signedTx: Buffer.from(witnessSet.to_bytes(), 'utf8').toString('hex'),
42
+ txid: '',
43
+ };
44
+ }
45
+ const transaction = CardanoWasm.Transaction.new(rawTx.body(), witnessSet, rawTx.auxiliary_data());
46
+ const signedTx = Buffer.from(transaction.to_bytes(), 'hex').toString('hex');
47
+ const hash = CardanoWasm.hash_transaction(transaction.body()).to_hex();
48
+ return {
49
+ signedTx,
50
+ txid: hash,
51
+ };
52
+ };
53
+ exports.signTransaction = signTransaction;
54
+ /**
55
+ *
56
+ * @param {string} tx - cbor hex string
57
+ * @param {Array<string>} keyHashes
58
+ * @param {string} password
59
+ * @returns {string} witness set as hex string
60
+ */
61
+ const signTx = async (keys, tx, keyHashes, partialSign = false) => {
62
+ const { paymentKey, stakeKey } = keys;
63
+ const paymentKeyHash = Buffer.from(paymentKey === null || paymentKey === void 0 ? void 0 : paymentKey.to_public().hash().to_bytes(), 'hex').toString('hex');
64
+ const stakeKeyHash = Buffer.from(stakeKey.to_public().hash().to_bytes(), 'hex').toString('hex');
65
+ const rawTx = CardanoWasm.Transaction.from_bytes(Buffer.from(tx, 'hex'));
66
+ const txWitnessSet = CardanoWasm.TransactionWitnessSet.new();
67
+ const vkeyWitnesses = CardanoWasm.Vkeywitnesses.new();
68
+ const txHash = CardanoWasm.hash_transaction(rawTx.body());
69
+ keyHashes.forEach(keyHash => {
70
+ let signingKey;
71
+ if (keyHash === paymentKeyHash)
72
+ signingKey = paymentKey;
73
+ else if (keyHash === stakeKeyHash)
74
+ signingKey = stakeKey;
75
+ else if (!partialSign)
76
+ throw error_1.TxSignError.ProofGeneration;
77
+ else
78
+ return;
79
+ const vkey = CardanoWasm.make_vkey_witness(txHash, signingKey);
80
+ vkeyWitnesses.add(vkey);
81
+ });
82
+ stakeKey.free();
83
+ // stakeKey = null;
84
+ paymentKey.free();
85
+ // paymentKey = null;
86
+ txWitnessSet.set_vkeys(vkeyWitnesses);
87
+ return txWitnessSet;
88
+ };
89
+ exports.signTx = signTx;
90
+ const getKeyHashes = async (tx, utxos, account) => {
91
+ var _a, _b, _c, _d;
92
+ let requiredKeyHashes = [];
93
+ const baseAddr = CardanoWasm.BaseAddress.from_address(CardanoWasm.Address.from_bech32(account.paymentAddr));
94
+ if (!baseAddr)
95
+ return { key: [], keyKind: [] };
96
+ const paymentKeyHash = Buffer.from((_b = (_a = baseAddr.payment_cred().to_keyhash()) === null || _a === void 0 ? void 0 : _a.to_bytes()) !== null && _b !== void 0 ? _b : '').toString('hex');
97
+ const stakeKeyHash = Buffer.from((_d = (_c = baseAddr.stake_cred().to_keyhash()) === null || _c === void 0 ? void 0 : _c.to_bytes()) !== null && _d !== void 0 ? _d : '').toString('hex');
98
+ //get key hashes from inputs
99
+ const inputs = tx.body().inputs();
100
+ for (let i = 0; i < inputs.len(); i++) {
101
+ const input = inputs.get(i);
102
+ const txHash = Buffer.from(input.transaction_id().to_bytes()).toString('hex');
103
+ const index = input.index();
104
+ if (utxos.some(utxo => Buffer.from(utxo.input().transaction_id().to_bytes()).toString('hex') === txHash && utxo.input().index() === index)) {
105
+ requiredKeyHashes.push(paymentKeyHash);
106
+ }
107
+ else {
108
+ requiredKeyHashes.push('<not_owned_key_hash>');
109
+ }
110
+ }
111
+ //get key hashes from certificates
112
+ const txBody = tx.body();
113
+ const keyHashFromCert = txBody => {
114
+ for (let i = 0; i < txBody.certs().len(); i++) {
115
+ const cert = txBody.certs().get(i);
116
+ if (cert.kind() === 0) {
117
+ const credential = cert.as_stake_registration().stake_credential();
118
+ if (credential.kind() === 0) {
119
+ // stake registration doesn't required key hash
120
+ }
121
+ }
122
+ else if (cert.kind() === 1) {
123
+ const credential = cert.as_stake_deregistration().stake_credential();
124
+ if (credential.kind() === 0) {
125
+ const keyHash = Buffer.from(credential.to_keyhash().to_bytes()).toString('hex');
126
+ requiredKeyHashes.push(keyHash);
127
+ }
128
+ }
129
+ else if (cert.kind() === 2) {
130
+ const credential = cert.as_stake_delegation().stake_credential();
131
+ if (credential.kind() === 0) {
132
+ const keyHash = Buffer.from(credential.to_keyhash().to_bytes()).toString('hex');
133
+ requiredKeyHashes.push(keyHash);
134
+ }
135
+ }
136
+ else if (cert.kind() === 3) {
137
+ const owners = cert.as_pool_registration().pool_params().pool_owners();
138
+ for (let i = 0; i < owners.len(); i++) {
139
+ const keyHash = Buffer.from(owners.get(i).to_bytes()).toString('hex');
140
+ requiredKeyHashes.push(keyHash);
141
+ }
142
+ }
143
+ else if (cert.kind() === 4) {
144
+ const operator = cert.as_pool_retirement().pool_keyhash().to_hex();
145
+ requiredKeyHashes.push(operator);
146
+ }
147
+ else if (cert.kind() === 6) {
148
+ const instant_reward = cert
149
+ .as_move_instantaneous_rewards_cert()
150
+ .move_instantaneous_reward()
151
+ .as_to_stake_creds()
152
+ .keys();
153
+ for (let i = 0; i < instant_reward.len(); i++) {
154
+ const credential = instant_reward.get(i);
155
+ if (credential.kind() === 0) {
156
+ const keyHash = Buffer.from(credential.to_keyhash().to_bytes()).toString('hex');
157
+ requiredKeyHashes.push(keyHash);
158
+ }
159
+ }
160
+ }
161
+ }
162
+ };
163
+ if (txBody.certs())
164
+ keyHashFromCert(txBody);
165
+ // key hashes from withdrawals
166
+ const withdrawals = txBody.withdrawals();
167
+ const keyHashFromWithdrawal = withdrawals => {
168
+ const rewardAddresses = withdrawals.keys();
169
+ for (let i = 0; i < rewardAddresses.len(); i++) {
170
+ const credential = rewardAddresses.get(i).payment_cred();
171
+ if (credential.kind() === 0) {
172
+ requiredKeyHashes.push(credential.to_keyhash().to_hex());
173
+ }
174
+ }
175
+ };
176
+ if (withdrawals)
177
+ keyHashFromWithdrawal(withdrawals);
178
+ //get key hashes from scripts
179
+ const scripts = tx.witness_set().native_scripts();
180
+ const keyHashFromScript = scripts => {
181
+ for (let i = 0; i < scripts.len(); i++) {
182
+ const script = scripts.get(i);
183
+ if (script.kind() === 0) {
184
+ const keyHash = Buffer.from(script.as_script_pubkey().addr_keyhash().to_bytes()).toString('hex');
185
+ requiredKeyHashes.push(keyHash);
186
+ }
187
+ if (script.kind() === 1) {
188
+ return keyHashFromScript(script.as_script_all().native_scripts());
189
+ }
190
+ if (script.kind() === 2) {
191
+ return keyHashFromScript(script.as_script_any().native_scripts());
192
+ }
193
+ if (script.kind() === 3) {
194
+ return keyHashFromScript(script.as_script_n_of_k().native_scripts());
195
+ }
196
+ }
197
+ };
198
+ if (scripts)
199
+ keyHashFromScript(scripts);
200
+ //get keyHashes from required signers
201
+ const requiredSigners = tx.body().required_signers();
202
+ if (requiredSigners) {
203
+ for (let i = 0; i < requiredSigners.len(); i++) {
204
+ requiredKeyHashes.push(Buffer.from(requiredSigners.get(i).to_bytes()).toString('hex'));
205
+ }
206
+ }
207
+ //get keyHashes from collateral
208
+ const collateral = txBody.collateral();
209
+ if (collateral) {
210
+ // TODO: Collateral KeyHashed
211
+ // for (let i = 0; i < collateral.len(); i++) {
212
+ // const c = collateral.get(i);
213
+ // const utxo = await getSpecificUtxo(
214
+ // Buffer.from(c.transaction_id().to_bytes()).toString('hex'),
215
+ // c.index(),
216
+ // );
217
+ // if (utxo) {
218
+ // const address = CardanoWasm.Address.from_bech32(utxo.address);
219
+ // requiredKeyHashes.push(await getPaymentKeyHash(address));
220
+ // }
221
+ // }
222
+ }
223
+ const keyKind = [];
224
+ requiredKeyHashes = [...new Set(requiredKeyHashes)];
225
+ if (requiredKeyHashes.includes(paymentKeyHash))
226
+ keyKind.push('payment');
227
+ if (requiredKeyHashes.includes(stakeKeyHash))
228
+ keyKind.push('stake');
229
+ return {
230
+ key: requiredKeyHashes,
231
+ keyKind,
232
+ };
233
+ };
234
+ const getUtxos = async (address, utxos) => {
235
+ const paymentAddr = getPaymentHexAddress(address);
236
+ const converted = utxos.map(utxo => utxoFromJson(utxo, paymentAddr));
237
+ if (converted.length <= 0) {
238
+ return null;
239
+ }
240
+ return Promise.resolve(converted);
241
+ };
242
+ exports.getUtxos = getUtxos;
243
+ const getPaymentHexAddress = (address) => {
244
+ const paymentAddr = Buffer.from(CardanoWasm.Address.from_bech32(address).to_bytes(), 'hex').toString('hex');
245
+ return paymentAddr;
246
+ };
247
+ /**
248
+ *
249
+ * @param {JSON} output
250
+ * @param {BaseAddress} address
251
+ * @returns
252
+ */
253
+ const utxoFromJson = (output, address) => CardanoWasm.TransactionUnspentOutput.new(CardanoWasm.TransactionInput.new(CardanoWasm.TransactionHash.from_bytes(Buffer.from(output.tx_hash, 'hex')), Number(output.output_index)), CardanoWasm.TransactionOutput.new(CardanoWasm.Address.from_bytes(Buffer.from(address, 'hex')), assetsToValue(output.amount)));
254
+ const assetsToValue = (assets) => {
255
+ const multiAsset = CardanoWasm.MultiAsset.new();
256
+ const lovelace = assets.find(asset => asset.unit === 'lovelace');
257
+ const policies = [
258
+ ...new Set(assets
259
+ .filter(asset => asset.unit !== 'lovelace')
260
+ .map(asset => asset.unit.slice(0, 56))),
261
+ ];
262
+ policies.forEach(policy => {
263
+ const policyAssets = assets.filter(asset => asset.unit.slice(0, 56) === policy);
264
+ const assetsValue = CardanoWasm.Assets.new();
265
+ policyAssets.forEach(asset => {
266
+ assetsValue.insert(CardanoWasm.AssetName.new(Buffer.from(asset.unit.slice(56), 'hex')), CardanoWasm.BigNum.from_str(asset.quantity));
267
+ });
268
+ multiAsset.insert(CardanoWasm.ScriptHash.from_bytes(Buffer.from(policy, 'hex')), assetsValue);
269
+ });
270
+ const value = CardanoWasm.Value.new(CardanoWasm.BigNum.from_str(lovelace ? lovelace.quantity : '0'));
271
+ if (assets.length > 1 || !lovelace) {
272
+ value.set_multiasset(multiAsset);
273
+ }
274
+ return value;
275
+ };
276
+ const harden = (num) => {
277
+ return 0x80000000 + num;
278
+ };
279
+ const requestAccountKey = async (xprv, accountIndex) => {
280
+ let accountKey;
281
+ try {
282
+ accountKey = CardanoWasm.Bip32PrivateKey.from_bech32(xprv)
283
+ .derive(harden(1852)) // purpose
284
+ .derive(harden(1815)) // coin type;
285
+ .derive(harden(parseInt(`${accountIndex}`)));
286
+ }
287
+ catch (e) {
288
+ throw new Error('Wrong private key');
289
+ }
290
+ return {
291
+ accountKey,
292
+ paymentKey: accountKey.derive(0).derive(0).to_raw_key(),
293
+ stakeKey: accountKey.derive(2).derive(0).to_raw_key(),
294
+ };
295
+ };
296
+ exports.requestAccountKey = requestAccountKey;
@@ -0,0 +1,5 @@
1
+ import { PrecomposedTransaction } from '../../types/types';
2
+ import { ITransferInfo, IAdaUTXO, IOutput } from './types';
3
+ export declare const composeTxPlan: (transferInfo: ITransferInfo, accountXpub: string, utxos: IAdaUTXO[], changeAddress: string, outputs: IOutput[], options?: {
4
+ debug: boolean;
5
+ }) => Promise<PrecomposedTransaction>;
@@ -0,0 +1,49 @@
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.composeTxPlan = void 0;
7
+ const bignumber_js_1 = __importDefault(require("bignumber.js"));
8
+ const index_1 = require("../../index");
9
+ const logger_1 = require("../logger");
10
+ const composeTxPlan = (transferInfo, accountXpub, utxos, changeAddress, outputs, options) => {
11
+ var _a;
12
+ const logger = (0, logger_1.getLogger)(!!(options === null || options === void 0 ? void 0 : options.debug));
13
+ const transformUtxos = utxos.map(utxo => {
14
+ var _a;
15
+ return (Object.assign(Object.assign({}, utxo), { txHash: utxo.tx_hash, outputIndex: utxo.output_index, address: (_a = utxo.address) !== null && _a !== void 0 ? _a : transferInfo.from }));
16
+ });
17
+ try {
18
+ const txPlan = (0, index_1.coinSelection)({
19
+ utxos: transformUtxos,
20
+ outputs: outputs,
21
+ changeAddress,
22
+ certificates: [],
23
+ withdrawals: [],
24
+ accountPubKey: accountXpub,
25
+ }, {
26
+ debug: (_a = options === null || options === void 0 ? void 0 : options.debug) !== null && _a !== void 0 ? _a : false,
27
+ });
28
+ return Promise.resolve(txPlan);
29
+ }
30
+ catch (err) {
31
+ if ((err === null || err === void 0 ? void 0 : err.code) === 'UTXO_BALANCE_INSUFFICIENT') {
32
+ logger.debug('UTxO balance insufficient');
33
+ if (outputs.length === 1) {
34
+ const fixedOutput = [...outputs];
35
+ const amountBN = new bignumber_js_1.default(outputs[0].amount);
36
+ const oneLovelace = new bignumber_js_1.default('100000');
37
+ if (amountBN.gte(oneLovelace)) {
38
+ fixedOutput[0].amount = amountBN.minus(oneLovelace).toFixed();
39
+ return (0, exports.composeTxPlan)(transferInfo, accountXpub, utxos, changeAddress, fixedOutput);
40
+ }
41
+ }
42
+ throw err;
43
+ }
44
+ else {
45
+ throw err;
46
+ }
47
+ }
48
+ };
49
+ exports.composeTxPlan = composeTxPlan;
@@ -0,0 +1,67 @@
1
+ import type { IChangeAddress } from './types';
2
+ export declare enum CardanoAddressType {
3
+ BASE = 0,
4
+ BASE_SCRIPT_KEY = 1,
5
+ BASE_KEY_SCRIPT = 2,
6
+ BASE_SCRIPT_SCRIPT = 3,
7
+ POINTER = 4,
8
+ POINTER_SCRIPT = 5,
9
+ ENTERPRISE = 6,
10
+ ENTERPRISE_SCRIPT = 7,
11
+ BYRON = 8,
12
+ REWARD = 14,
13
+ REWARD_SCRIPT = 15
14
+ }
15
+ export declare enum CardanoTxSigningMode {
16
+ ORDINARY_TRANSACTION = 0,
17
+ POOL_REGISTRATION_AS_OWNER = 1,
18
+ MULTISIG_TRANSACTION = 2,
19
+ PLUTUS_TRANSACTION = 3
20
+ }
21
+ export declare enum CardanoCertificateType {
22
+ STAKE_REGISTRATION = 0,
23
+ STAKE_DEREGISTRATION = 1,
24
+ STAKE_DELEGATION = 2,
25
+ STAKE_POOL_REGISTRATION = 3
26
+ }
27
+ export declare enum CardanoPoolRelayType {
28
+ SINGLE_HOST_IP = 0,
29
+ SINGLE_HOST_NAME = 1,
30
+ MULTIPLE_HOST_NAME = 2
31
+ }
32
+ declare type Key = {
33
+ hash: string | null;
34
+ path: string | null;
35
+ };
36
+ declare type Keys = {
37
+ payment: Key;
38
+ stake: Key;
39
+ };
40
+ /**
41
+ *
42
+ * @param {Transaction} tx
43
+ */
44
+ export declare const txToOneKey: (rawTx: string, network: number, initKeys: Keys, xpub: string, changeAddress: IChangeAddress) => Promise<{
45
+ signingMode: CardanoTxSigningMode.ORDINARY_TRANSACTION | CardanoTxSigningMode.POOL_REGISTRATION_AS_OWNER | CardanoTxSigningMode.PLUTUS_TRANSACTION;
46
+ outputs: never[];
47
+ fee: string;
48
+ ttl: string | null;
49
+ validityIntervalStart: any;
50
+ certificates: [] | null;
51
+ withdrawals: null;
52
+ auxiliaryData: {
53
+ hash: string;
54
+ } | null;
55
+ mint: null;
56
+ scriptDataHash: string | null;
57
+ collateralInputs: null;
58
+ requiredSigners: null;
59
+ protocolMagic: number;
60
+ networkId: number;
61
+ includeNetworkId: boolean;
62
+ additionalWitnessRequests: null;
63
+ collateralReturn: null;
64
+ totalCollateral: string | null;
65
+ referenceInputs: null;
66
+ }>;
67
+ export {};