@tatumio/ltc 2.0.1-alpha.203

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/package.json ADDED
@@ -0,0 +1,26 @@
1
+ {
2
+ "name": "@tatumio/ltc",
3
+ "version": "v2.0.1-alpha.203",
4
+ "license": "MIT",
5
+ "main": "./src/index.js",
6
+ "typings": "./src/index.d.ts",
7
+ "dependencies": {
8
+ "@tatumio/shared-abstract-sdk": "v2.0.1-alpha.202",
9
+ "@tatumio/api-client": "v2.0.1-alpha.202",
10
+ "axios": "^0.24.0",
11
+ "cross-blob": "^3.0.0",
12
+ "form-data": "^4.0.0",
13
+ "bignumber.js": "^9.0.2",
14
+ "@tatumio/shared-testing": "v2.0.1-alpha.202",
15
+ "@tatumio/shared-blockchain-btc-based": "v2.0.1-alpha.202",
16
+ "@tatumio/shared-core": "v2.0.1-alpha.202",
17
+ "@tatumio/shared-blockchain-abstract": "v2.0.1-alpha.202",
18
+ "bip32": "^2.0.5",
19
+ "bip39": "^3.0.2",
20
+ "bitcoinjs-lib": "^5.2.0",
21
+ "hdkey": "^2.0.1",
22
+ "bitcore-lib": "^8.25.25",
23
+ "bitcore-lib-ltc": "^8.25.27"
24
+ },
25
+ "peerDependencies": {}
26
+ }
package/src/index.d.ts ADDED
@@ -0,0 +1 @@
1
+ export * from './lib/ltc.sdk';
package/src/index.js ADDED
@@ -0,0 +1,5 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ const tslib_1 = require("tslib");
4
+ (0, tslib_1.__exportStar)(require("./lib/ltc.sdk"), exports);
5
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../../packages/blockchain/ltc/src/index.ts"],"names":[],"mappings":";;;AAAA,6DAA6B"}
@@ -0,0 +1,135 @@
1
+ import { BlockchainLitecoinService } from '@tatumio/api-client';
2
+ import { SDKArguments } from '@tatumio/shared-abstract-sdk';
3
+ export declare const TatumLtcSDK: (args: SDKArguments) => {
4
+ transaction: import("@tatumio/shared-blockchain-btc-based").BtcBasedTx<import("@tatumio/api-client").LtcTransactionAddress | import("@tatumio/api-client").LtcTransactionAddressKMS | import("@tatumio/api-client").LtcTransactionUTXO | import("@tatumio/api-client").LtcTransactionUTXOKMS>;
5
+ blockchain: {
6
+ info: typeof BlockchainLitecoinService.ltcGetBlockChainInfo;
7
+ mempool: typeof BlockchainLitecoinService.ltcGetMempool;
8
+ broadcast: typeof BlockchainLitecoinService.ltcBroadcast;
9
+ getBlockHash: typeof BlockchainLitecoinService.ltcGetBlockHash;
10
+ getBlock: typeof BlockchainLitecoinService.ltcGetBlock;
11
+ getUTXO: typeof BlockchainLitecoinService.ltcGetUtxo;
12
+ getBlockchainAccountBalance: typeof BlockchainLitecoinService.ltcGetBalanceOfAddress;
13
+ getTxForAccount: typeof BlockchainLitecoinService.ltcGetTxByAddress;
14
+ getTransaction: typeof BlockchainLitecoinService.ltcGetRawTransaction;
15
+ send: typeof BlockchainLitecoinService.ltcTransferBlockchain;
16
+ };
17
+ kms: {
18
+ sign(tx: import("@tatumio/shared-core").ChainTransactionKMS, privateKeys: string[]): Promise<string>;
19
+ getAllPending(signatures?: string): import("@tatumio/api-client").CancelablePromise<import("@tatumio/api-client").PendingTransaction>;
20
+ get: typeof import("@tatumio/api-client").SecurityKeyManagementSystemService.getPendingTransactionToSign;
21
+ complete: typeof import("@tatumio/api-client").SecurityKeyManagementSystemService.completePendingSignature;
22
+ delete: typeof import("@tatumio/api-client").SecurityKeyManagementSystemService.deletePendingTransactionToSign;
23
+ };
24
+ wallet: {
25
+ generateAddressFromXPub(xpub: string, i: number, options?: {
26
+ testnet: boolean;
27
+ }): string;
28
+ generatePrivateKeyFromMnemonic(mnemonic: string, i: number, options?: {
29
+ testnet: boolean;
30
+ }): Promise<string>;
31
+ generateAddressFromPrivateKey(privateKey: string, options?: {
32
+ testnet: boolean;
33
+ }): string;
34
+ generateWallet(mnemonic?: string, options?: {
35
+ testnet: boolean;
36
+ }): Promise<import("@tatumio/api-client").TronWallet>;
37
+ };
38
+ offchain: {
39
+ depositAddress: {
40
+ checkExists: (address: string, index?: number) => Promise<import("@tatumio/api-client").Account>;
41
+ create: typeof import("@tatumio/api-client").OffChainAccountService.generateDepositAddress;
42
+ createMultiple: typeof import("@tatumio/api-client").OffChainAccountService.generateDepositAddressesBatch;
43
+ assign: typeof import("@tatumio/api-client").OffChainAccountService.assignAddress;
44
+ remove: typeof import("@tatumio/api-client").OffChainAccountService.removeAddress;
45
+ getByAccount: typeof import("@tatumio/api-client").OffChainAccountService.getAllDepositAddresses;
46
+ };
47
+ withdrawal: {
48
+ getAll: (status?: "InProgress" | "Done" | "Cancelled", pageSize?: number, offset?: number) => Promise<import("@tatumio/api-client").WithdrawalObject[]>;
49
+ };
50
+ storeTokenAddress: typeof import("@tatumio/api-client").OffChainBlockchainService.storeTokenAddress;
51
+ };
52
+ getExchangeRate(basePair?: import("@tatumio/shared-core").Fiat): import("@tatumio/api-client").CancelablePromise<import("@tatumio/api-client").ExchangeRate>;
53
+ storage: {
54
+ upload: typeof import("@tatumio/api-client").StorageIpfsService.storeIpfs;
55
+ get: typeof import("@tatumio/api-client").StorageIpfsService.getIpfsData;
56
+ };
57
+ subscriptions: typeof import("@tatumio/api-client").LedgerSubscriptionService;
58
+ ledger: {
59
+ customer: {
60
+ get: typeof import("@tatumio/api-client").LedgerCustomerService.getCustomerByExternalOrInternalId;
61
+ getAll: typeof import("@tatumio/api-client").LedgerCustomerService.findAllCustomers;
62
+ update: typeof import("@tatumio/api-client").LedgerCustomerService.updateCustomer;
63
+ activate: typeof import("@tatumio/api-client").LedgerCustomerService.activateCustomer;
64
+ deactivate: typeof import("@tatumio/api-client").LedgerCustomerService.deactivateCustomer;
65
+ enable: typeof import("@tatumio/api-client").LedgerCustomerService.enableCustomer;
66
+ disable: typeof import("@tatumio/api-client").LedgerCustomerService.disableCustomer;
67
+ };
68
+ orderBook: {
69
+ getHistorical: typeof import("@tatumio/api-client").LedgerOrderBookService.getHistoricalTradesBody;
70
+ getActiveBuyTrades: typeof import("@tatumio/api-client").LedgerOrderBookService.getBuyTradesBody;
71
+ getActiveSellTrades: typeof import("@tatumio/api-client").LedgerOrderBookService.getBuyTradesBody;
72
+ newTrade: typeof import("@tatumio/api-client").LedgerOrderBookService.storeTrade;
73
+ get: typeof import("@tatumio/api-client").LedgerOrderBookService.getTradeById;
74
+ cancel: typeof import("@tatumio/api-client").LedgerOrderBookService.deleteTrade;
75
+ cancelByAccount: typeof import("@tatumio/api-client").LedgerOrderBookService.deleteAccountTrades;
76
+ };
77
+ transaction: {
78
+ send: typeof import("@tatumio/api-client").LedgerTransactionService.sendTransaction;
79
+ sendMultiple: typeof import("@tatumio/api-client").LedgerTransactionService.sendTransactionBatch;
80
+ getAll: typeof import("@tatumio/api-client").LedgerTransactionService.getTransactions;
81
+ getAllByAccount: typeof import("@tatumio/api-client").LedgerTransactionService.getTransactionsByAccountId;
82
+ getAllByCustomer: typeof import("@tatumio/api-client").LedgerTransactionService.getTransactionsByCustomerId;
83
+ getAllByReference: typeof import("@tatumio/api-client").LedgerTransactionService.getTransactionsByReference;
84
+ countByAccount: (filter: import("@tatumio/api-client").TransactionFilter) => any;
85
+ countByCustomer: (filter: import("@tatumio/api-client").TransactionFilterCustomer) => any;
86
+ };
87
+ virtualCurrency: {
88
+ create: typeof import("@tatumio/api-client").LedgerVirtualCurrencyService.createCurrency;
89
+ mint: typeof import("@tatumio/api-client").LedgerVirtualCurrencyService.mintCurrency;
90
+ revoke: typeof import("@tatumio/api-client").LedgerVirtualCurrencyService.revokeCurrency;
91
+ getByName: typeof import("@tatumio/api-client").LedgerVirtualCurrencyService.getCurrency;
92
+ update: typeof import("@tatumio/api-client").LedgerVirtualCurrencyService.updateCurrency;
93
+ };
94
+ blockAmount: {
95
+ block: typeof import("@tatumio/api-client").LedgerAccountService.blockAmount;
96
+ unblock: typeof import("@tatumio/api-client").LedgerAccountService.deleteBlockAmount;
97
+ unblockWithTransaction: typeof import("@tatumio/api-client").LedgerAccountService.unblockAmountWithTransaction;
98
+ };
99
+ account: {
100
+ get: typeof import("@tatumio/api-client").LedgerAccountService.getAccountByAccountId;
101
+ getAll: typeof import("@tatumio/api-client").LedgerAccountService.getAllAccounts;
102
+ getByCustomerId: typeof import("@tatumio/api-client").LedgerAccountService.getAccountsByCustomerId;
103
+ getBalance: typeof import("@tatumio/api-client").LedgerAccountService.getAccountBalance;
104
+ create: typeof import("@tatumio/api-client").LedgerAccountService.createAccount;
105
+ createMultiple: typeof import("@tatumio/api-client").LedgerAccountService.createAccountBatch;
106
+ update: typeof import("@tatumio/api-client").LedgerAccountService.updateAccountByAccountId;
107
+ getBlockedAmountsByAccountId: typeof import("@tatumio/api-client").LedgerAccountService.getBlockAmountById;
108
+ activate: typeof import("@tatumio/api-client").LedgerAccountService.activateAccount;
109
+ deactivate: typeof import("@tatumio/api-client").LedgerAccountService.deactivateAccount;
110
+ freeze: typeof import("@tatumio/api-client").LedgerAccountService.freezeAccount;
111
+ unfreeze: typeof import("@tatumio/api-client").LedgerAccountService.unfreezeAccount;
112
+ generate: (account: import("@tatumio/api-client").CreateAccount, generateNewWalletFn: any, generateNewWallet?: boolean, testnet?: boolean, webhookUrl?: string) => Promise<any>;
113
+ };
114
+ };
115
+ security: {
116
+ checkMaliciousAddress: typeof import("@tatumio/api-client").SecurityAddressService.checkMalicousAddress;
117
+ };
118
+ tatum: {
119
+ getCredits: typeof import("@tatumio/api-client").TatumServiceService.getCredits;
120
+ getVersion: typeof import("@tatumio/api-client").TatumServiceService.getVersion;
121
+ freezeApiKey: typeof import("@tatumio/api-client").TatumServiceService.freezeApiKey;
122
+ unfreezeApiKey: typeof import("@tatumio/api-client").TatumServiceService.unfreezeApiKey;
123
+ };
124
+ nft: {
125
+ mintNFT: typeof import("@tatumio/api-client").BlockchainNftService.nftMintErc721;
126
+ getNFTTransaction: typeof import("@tatumio/api-client").BlockchainNftService.nftGetTransactErc721;
127
+ getNFTTransactionsByToken: typeof import("@tatumio/api-client").BlockchainNftService.nftGetTransactionByToken;
128
+ getNFTTransactionsByAddress: typeof import("@tatumio/api-client").BlockchainNftService.nftGetTransactionByAddress;
129
+ getNFTsByAddress: typeof import("@tatumio/api-client").BlockchainNftService.nftGetBalanceErc721;
130
+ getNFTProvenanceData: typeof import("@tatumio/api-client").BlockchainNftService.nftGetProvenanceDataErc721;
131
+ getNFTMetadataURI: typeof import("@tatumio/api-client").BlockchainNftService.nftGetMetadataErc721;
132
+ getNFTRoyalty: typeof import("@tatumio/api-client").BlockchainNftService.nftGetRoyaltyErc721;
133
+ prepareAddNFTMinterAbstraction: typeof import("@tatumio/api-client").BlockchainNftService.nftGetRoyaltyErc721;
134
+ };
135
+ };
@@ -0,0 +1,6 @@
1
+ import { SdkError, SdkErrorCode } from '@tatumio/shared-abstract-sdk';
2
+ export declare const LTC_ERRORS_MAPPING: {};
3
+ export declare type LtcSdkErrorCode = SdkErrorCode.BTC_FEE_TOO_SMALL | SdkErrorCode.BTC_UTXO_NOT_FOUND | SdkErrorCode.BTC_NOT_ENOUGH_BALANCE | SdkErrorCode.TX_NOT_FOUND;
4
+ export declare class LtcSdkError extends SdkError {
5
+ constructor(error: Error | LtcSdkErrorCode);
6
+ }
@@ -0,0 +1,22 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.LtcSdkError = exports.LTC_ERRORS_MAPPING = void 0;
4
+ const shared_abstract_sdk_1 = require("@tatumio/shared-abstract-sdk");
5
+ exports.LTC_ERRORS_MAPPING = {};
6
+ class LtcSdkError extends shared_abstract_sdk_1.SdkError {
7
+ constructor(error) {
8
+ if (typeof error === 'string') {
9
+ super({
10
+ code: error,
11
+ });
12
+ }
13
+ else {
14
+ super({
15
+ originalError: error,
16
+ errorSubstringMapping: exports.LTC_ERRORS_MAPPING,
17
+ });
18
+ }
19
+ }
20
+ }
21
+ exports.LtcSdkError = LtcSdkError;
22
+ //# sourceMappingURL=ltc.sdk.errors.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ltc.sdk.errors.js","sourceRoot":"","sources":["../../../../../../packages/blockchain/ltc/src/lib/ltc.sdk.errors.ts"],"names":[],"mappings":";;;AAAA,sEAAqE;AAExD,QAAA,kBAAkB,GAAG,EAAE,CAAA;AAQpC,MAAa,WAAY,SAAQ,8BAAQ;IACvC,YAAY,KAA8B;QACxC,IAAI,OAAO,KAAK,KAAK,QAAQ,EAAE;YAC7B,KAAK,CAAC;gBACJ,IAAI,EAAE,KAAK;aACZ,CAAC,CAAA;SACH;aAAM;YACL,KAAK,CAAC;gBACJ,aAAa,EAAE,KAAK;gBACpB,qBAAqB,EAAE,0BAAkB;aAC1C,CAAC,CAAA;SACH;IACH,CAAC;CACF;AAbD,kCAaC"}
@@ -0,0 +1,24 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.TatumLtcSDK = void 0;
4
+ const shared_core_1 = require("@tatumio/shared-core");
5
+ const shared_blockchain_btc_based_1 = require("@tatumio/shared-blockchain-btc-based");
6
+ const api_client_1 = require("@tatumio/api-client");
7
+ const ltc_tx_1 = require("./transaction/ltc.tx");
8
+ const blockchain = shared_core_1.Blockchain.LTC;
9
+ const TatumLtcSDK = (args) => {
10
+ return Object.assign(Object.assign({}, (0, shared_blockchain_btc_based_1.btcBasedSdk)(Object.assign(Object.assign({}, args), { blockchain }))), { transaction: (0, ltc_tx_1.ltcTransactions)(), blockchain: {
11
+ info: api_client_1.BlockchainLitecoinService.ltcGetBlockChainInfo,
12
+ mempool: api_client_1.BlockchainLitecoinService.ltcGetMempool,
13
+ broadcast: api_client_1.BlockchainLitecoinService.ltcBroadcast,
14
+ getBlockHash: api_client_1.BlockchainLitecoinService.ltcGetBlockHash,
15
+ getBlock: api_client_1.BlockchainLitecoinService.ltcGetBlock,
16
+ getUTXO: api_client_1.BlockchainLitecoinService.ltcGetUtxo,
17
+ getBlockchainAccountBalance: api_client_1.BlockchainLitecoinService.ltcGetBalanceOfAddress,
18
+ getTxForAccount: api_client_1.BlockchainLitecoinService.ltcGetTxByAddress,
19
+ getTransaction: api_client_1.BlockchainLitecoinService.ltcGetRawTransaction,
20
+ send: api_client_1.BlockchainLitecoinService.ltcTransferBlockchain,
21
+ } });
22
+ };
23
+ exports.TatumLtcSDK = TatumLtcSDK;
24
+ //# sourceMappingURL=ltc.sdk.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ltc.sdk.js","sourceRoot":"","sources":["../../../../../../packages/blockchain/ltc/src/lib/ltc.sdk.ts"],"names":[],"mappings":";;;AAAA,sDAAiD;AACjD,sFAAkE;AAClE,oDAA+D;AAC/D,iDAAsD;AAGtD,MAAM,UAAU,GAAG,wBAAU,CAAC,GAAG,CAAA;AAE1B,MAAM,WAAW,GAAG,CAAC,IAAkB,EAAE,EAAE;IAChD,uCACK,IAAA,yCAAW,kCAAM,IAAI,KAAE,UAAU,IAAG,KACvC,WAAW,EAAE,IAAA,wBAAe,GAAE,EAC9B,UAAU,EAAE;YACV,IAAI,EAAE,sCAAyB,CAAC,oBAAoB;YACpD,OAAO,EAAE,sCAAyB,CAAC,aAAa;YAChD,SAAS,EAAE,sCAAyB,CAAC,YAAY;YACjD,YAAY,EAAE,sCAAyB,CAAC,eAAe;YACvD,QAAQ,EAAE,sCAAyB,CAAC,WAAW;YAC/C,OAAO,EAAE,sCAAyB,CAAC,UAAU;YAC7C,2BAA2B,EAAE,sCAAyB,CAAC,sBAAsB;YAC7E,eAAe,EAAE,sCAAyB,CAAC,iBAAiB;YAC5D,cAAc,EAAE,sCAAyB,CAAC,oBAAoB;YAC9D,IAAI,EAAE,sCAAyB,CAAC,qBAAqB;SACtD,IACF;AACH,CAAC,CAAA;AAjBY,QAAA,WAAW,eAiBvB"}
@@ -0,0 +1,5 @@
1
+ import { LtcTransactionAddress, LtcTransactionAddressKMS, LtcTransactionUTXO, LtcTransactionUTXOKMS } from '@tatumio/api-client';
2
+ import { BtcBasedTx } from '@tatumio/shared-blockchain-btc-based';
3
+ declare type LtcTransaction = LtcTransactionAddress | LtcTransactionAddressKMS | LtcTransactionUTXO | LtcTransactionUTXOKMS;
4
+ export declare const ltcTransactions: () => BtcBasedTx<LtcTransaction>;
5
+ export {};
@@ -0,0 +1,117 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.ltcTransactions = void 0;
4
+ const tslib_1 = require("tslib");
5
+ // @ts-ignore
6
+ const bitcore_lib_ltc_1 = require("bitcore-lib-ltc");
7
+ const api_client_1 = require("@tatumio/api-client");
8
+ const shared_abstract_sdk_1 = require("@tatumio/shared-abstract-sdk");
9
+ const bignumber_js_1 = (0, tslib_1.__importDefault)(require("bignumber.js"));
10
+ const ltc_sdk_errors_1 = require("../ltc.sdk.errors");
11
+ const sendTransaction = (body) => (0, tslib_1.__awaiter)(void 0, void 0, void 0, function* () {
12
+ return api_client_1.ApiServices.blockchain.ltc.ltcBroadcast({
13
+ txData: yield prepareSignedTransaction(body),
14
+ });
15
+ });
16
+ const prepareSignedTransaction = (body) => (0, tslib_1.__awaiter)(void 0, void 0, void 0, function* () {
17
+ try {
18
+ const tx = new bitcore_lib_ltc_1.Transaction();
19
+ let privateKeysToSign = [];
20
+ body.to.forEach((to) => {
21
+ tx.to(to.address, shared_abstract_sdk_1.amountUtils.toSatoshis(to.value));
22
+ });
23
+ if ('fromAddress' in body) {
24
+ privateKeysToSign = yield privateKeysFromAddress(tx, body);
25
+ const fromAddress = body.fromAddress;
26
+ if (fromAddress && 'signatureId' in fromAddress[0] && fromAddress[0].signatureId) {
27
+ return JSON.stringify({ txData: JSON.stringify(tx), privateKeysToSign });
28
+ }
29
+ }
30
+ else if ('fromUTXO' in body) {
31
+ privateKeysToSign = yield privateKeysFromUTXO(tx, body);
32
+ const fromUTXO = body.fromUTXO;
33
+ if (fromUTXO && 'signatureId' in fromUTXO[0] && fromUTXO[0].signatureId) {
34
+ return JSON.stringify({ txData: JSON.stringify(tx), privateKeysToSign });
35
+ }
36
+ }
37
+ verifyAmounts(tx, body);
38
+ privateKeysToSign.forEach((key) => {
39
+ tx.sign(bitcore_lib_ltc_1.PrivateKey.fromWIF(key));
40
+ });
41
+ // @TODO unchecked serialize
42
+ return tx.serialize(true);
43
+ }
44
+ catch (e) {
45
+ throw new ltc_sdk_errors_1.LtcSdkError(e);
46
+ }
47
+ });
48
+ function verifyAmounts(tx, body) {
49
+ const outputsSum = body.to
50
+ .map((to) => shared_abstract_sdk_1.amountUtils.toSatoshis(to.value))
51
+ .reduce((e, acc) => e.plus(acc), new bignumber_js_1.default(0));
52
+ const inputsSum = tx.inputs
53
+ .map((i) => new bignumber_js_1.default(i.output.satoshis))
54
+ .reduce((v, acc) => v.plus(acc), new bignumber_js_1.default(0));
55
+ if (outputsSum.eq(inputsSum)) {
56
+ throw new ltc_sdk_errors_1.LtcSdkError(shared_abstract_sdk_1.SdkErrorCode.BTC_FEE_TOO_SMALL);
57
+ }
58
+ if (outputsSum.gt(inputsSum)) {
59
+ throw new ltc_sdk_errors_1.LtcSdkError(shared_abstract_sdk_1.SdkErrorCode.BTC_NOT_ENOUGH_BALANCE);
60
+ }
61
+ }
62
+ const privateKeysFromAddress = (transaction, body) => (0, tslib_1.__awaiter)(void 0, void 0, void 0, function* () {
63
+ const privateKeysToSign = [];
64
+ for (const item of body.fromAddress) {
65
+ const txs = yield api_client_1.ApiServices.blockchain.ltc.ltcGetTxByAddress(item.address, 50); // @TODO OPENAPI remove pageSize
66
+ for (const tx of txs) {
67
+ for (const [i, o] of tx.outputs.entries()) {
68
+ if (o.address !== item.address) {
69
+ continue;
70
+ }
71
+ try {
72
+ transaction.from({
73
+ txId: tx.hash,
74
+ outputIndex: i,
75
+ script: bitcore_lib_ltc_1.Script.fromAddress(item.address).toString(),
76
+ satoshis: shared_abstract_sdk_1.amountUtils.toSatoshis(o.value), // @TODO null check
77
+ });
78
+ if ('signatureId' in item)
79
+ privateKeysToSign.push(item.signatureId);
80
+ else if ('privateKey' in item)
81
+ privateKeysToSign.push(item.privateKey);
82
+ }
83
+ catch (e) {
84
+ console.error(e.toString());
85
+ }
86
+ }
87
+ }
88
+ }
89
+ return privateKeysToSign;
90
+ });
91
+ const privateKeysFromUTXO = (transaction, body) => (0, tslib_1.__awaiter)(void 0, void 0, void 0, function* () {
92
+ var _a;
93
+ const privateKeysToSign = [];
94
+ for (const item of body.fromUTXO) {
95
+ const tx = yield api_client_1.ApiServices.blockchain.ltc.ltcGetRawTransaction(item.txHash);
96
+ const output = ((_a = tx.outputs) !== null && _a !== void 0 ? _a : [])[item.index];
97
+ if (!output || !output.address || !output.value)
98
+ throw new ltc_sdk_errors_1.LtcSdkError(shared_abstract_sdk_1.SdkErrorCode.BTC_UTXO_NOT_FOUND);
99
+ transaction.from({
100
+ txId: item.txHash,
101
+ outputIndex: item.index,
102
+ script: bitcore_lib_ltc_1.Script.fromAddress(output.address).toString(),
103
+ satoshis: shared_abstract_sdk_1.amountUtils.toSatoshis(output.value),
104
+ });
105
+ if ('signatureId' in item)
106
+ privateKeysToSign.push(item.signatureId);
107
+ else if ('privateKey' in item)
108
+ privateKeysToSign.push(item.privateKey);
109
+ }
110
+ return privateKeysToSign;
111
+ });
112
+ const ltcTransactions = () => ({
113
+ sendTransaction,
114
+ prepareSignedTransaction,
115
+ });
116
+ exports.ltcTransactions = ltcTransactions;
117
+ //# sourceMappingURL=ltc.tx.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ltc.tx.js","sourceRoot":"","sources":["../../../../../../../packages/blockchain/ltc/src/lib/transaction/ltc.tx.ts"],"names":[],"mappings":";;;;AAAA,aAAa;AACb,qDAAiE;AACjE,oDAO4B;AAC5B,sEAAwE;AACxE,6EAAoC;AACpC,sDAA+C;AAS/C,MAAM,eAAe,GAAG,CAAO,IAAoB,EAA+B,EAAE;IAClF,OAAO,wBAAW,CAAC,UAAU,CAAC,GAAG,CAAC,YAAY,CAAC;QAC7C,MAAM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