@tradelayerprotocol/tradelayer 1.9.1
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/.claude/settings.local.json +13 -0
- package/.claude/skills/tl-algo/SKILL.md +255 -0
- package/.gitattributes +2 -0
- package/.github/workflows/publish.yaml +26 -0
- package/4mm.js +163 -0
- package/LICENSE +21 -0
- package/NPMSwapRefactor.zip +0 -0
- package/README.md +217 -0
- package/address.sh +26 -0
- package/algoAPI.js +581 -0
- package/analyzepsbt.js +92 -0
- package/apiEx.js +99 -0
- package/bb_hyperscalper.js +290 -0
- package/bbo_demo.js +111 -0
- package/buyer.js +622 -0
- package/client.js +50 -0
- package/createTxTest.js +26 -0
- package/createWallet.js +75 -0
- package/daytrader.js +531 -0
- package/decodeTest.js +69 -0
- package/fundingManager.js +144 -0
- package/index.js +4 -0
- package/listener.js +27 -0
- package/litecoreTxBuilder.js +1128 -0
- package/mmEx.js +356 -0
- package/networks.js +51 -0
- package/orderbook.js +200 -0
- package/package.json +34 -0
- package/perTradeQueue.js +36 -0
- package/projectsTLNPMTLNPM/package-lock.json +162 -0
- package/projectsTLNPMTLNPM/package.json +5 -0
- package/quick.js +32 -0
- package/quickFut.js +37 -0
- package/quickSell.js +37 -0
- package/relayerClient.js +117 -0
- package/run4mm.js +80 -0
- package/run_bbo_tracker.js +241 -0
- package/seller.js +443 -0
- package/session.js +45 -0
- package/setup-lin-ltc.sh +139 -0
- package/setup-lin.sh +203 -0
- package/setup-win-ltc.bat +108 -0
- package/setup-win.bat +167 -0
- package/spam_screamer_futures.js +222 -0
- package/tradelayer.js/.gitattributes +2 -0
- package/tradelayer.js/README.md +2 -0
- package/tradelayer.js/oldTests/activationTest.js +6 -0
- package/tradelayer.js/oldTests/base58.test.js +23 -0
- package/tradelayer.js/oldTests/base64Decode.test.js +16 -0
- package/tradelayer.js/oldTests/blocksRefactor.js +140 -0
- package/tradelayer.js/oldTests/checkVestBalance.js +25 -0
- package/tradelayer.js/oldTests/consensusHashProto.js +151 -0
- package/tradelayer.js/oldTests/contractOrderbook.js +243 -0
- package/tradelayer.js/oldTests/createPayload.js +0 -0
- package/tradelayer.js/oldTests/createTestnetAddr.js +43 -0
- package/tradelayer.js/oldTests/decode.js +205 -0
- package/tradelayer.js/oldTests/decodeTest.js +50 -0
- package/tradelayer.js/oldTests/displayTallyMap.js +19 -0
- package/tradelayer.js/oldTests/encodeDecode.js +340 -0
- package/tradelayer.js/oldTests/expressTest.js +29 -0
- package/tradelayer.js/oldTests/extractBlocksVanilla.js +214 -0
- package/tradelayer.js/oldTests/extractBlocksVanillaa.js +179 -0
- package/tradelayer.js/oldTests/extractPubkeyTest.js +60 -0
- package/tradelayer.js/oldTests/fillInputCacheProto.js +111 -0
- package/tradelayer.js/oldTests/getRawTxTest.js +22 -0
- package/tradelayer.js/oldTests/indexTest.js +26 -0
- package/tradelayer.js/oldTests/initTokensTest.js +32 -0
- package/tradelayer.js/oldTests/interfaceChild.js +129 -0
- package/tradelayer.js/oldTests/listenerChild.js +112 -0
- package/tradelayer.js/oldTests/opdecode.js +26 -0
- package/tradelayer.js/oldTests/options.js +79 -0
- package/tradelayer.js/oldTests/optxtest.js +116 -0
- package/tradelayer.js/oldTests/optxtest1.js +64 -0
- package/tradelayer.js/oldTests/oracle.test.js +32 -0
- package/tradelayer.js/oldTests/orderbook.test.js +36 -0
- package/tradelayer.js/oldTests/parsing.js +93 -0
- package/tradelayer.js/oldTests/payload.js +13 -0
- package/tradelayer.js/oldTests/persistenceUnitTest.js +23 -0
- package/tradelayer.js/oldTests/property.test.js +53 -0
- package/tradelayer.js/oldTests/propertyLevel.js +75 -0
- package/tradelayer.js/oldTests/propertyTest.js +32 -0
- package/tradelayer.js/oldTests/queryAddressTest.js +17 -0
- package/tradelayer.js/oldTests/salter.js +14 -0
- package/tradelayer.js/oldTests/tally.js +81 -0
- package/tradelayer.js/oldTests/tally.test.js +48 -0
- package/tradelayer.js/oldTests/tally2.js +124 -0
- package/tradelayer.js/oldTests/tally3.js +142 -0
- package/tradelayer.js/oldTests/tallyDiag.js +38 -0
- package/tradelayer.js/oldTests/testGetRaw.js +40 -0
- package/tradelayer.js/oldTests/testHexConvert.js +47 -0
- package/tradelayer.js/oldTests/testNewEncoding.js +96 -0
- package/tradelayer.js/oldTests/testNewEncoding2.js +113 -0
- package/tradelayer.js/oldTests/testNewEncoding3 +112 -0
- package/tradelayer.js/oldTests/testNewEncoding3.js +168 -0
- package/tradelayer.js/oldTests/testOPReturn.js +102 -0
- package/tradelayer.js/oldTests/testPayload.js +23 -0
- package/tradelayer.js/oldTests/testRaw.js +50 -0
- package/tradelayer.js/oldTests/testSendTooMuch.js +20 -0
- package/tradelayer.js/oldTests/testTxBuild +28 -0
- package/tradelayer.js/oldTests/testTxBuild.js +42 -0
- package/tradelayer.js/oldTests/tokenOrderbook.js +243 -0
- package/tradelayer.js/oldTests/txUtilsA.js +515 -0
- package/tradelayer.js/oldTests/validityUnitTest.js +53 -0
- package/tradelayer.js/oldTests/vaults.js +72 -0
- package/tradelayer.js/oldTests/volumeIndex.js +117 -0
- package/tradelayer.js/oldTests/volumeIndex2.js +88 -0
- package/tradelayer.js/output_base64.txt +1 -0
- package/tradelayer.js/package-lock.json +9967 -0
- package/tradelayer.js/package.json +61 -0
- package/tradelayer.js/server/index.js +88 -0
- package/tradelayer.js/server/litecoind.exe +0 -0
- package/tradelayer.js/src/activation.js +303 -0
- package/tradelayer.js/src/adjuster.js +77 -0
- package/tradelayer.js/src/amm.js +400 -0
- package/tradelayer.js/src/base256.js +55 -0
- package/tradelayer.js/src/base94.js +79 -0
- package/tradelayer.js/src/channels.js +1163 -0
- package/tradelayer.js/src/clearing.js +3109 -0
- package/tradelayer.js/src/clearlist.js +364 -0
- package/tradelayer.js/src/client.js +295 -0
- package/tradelayer.js/src/consensus.js +613 -0
- package/tradelayer.js/src/contractRegistry.js +964 -0
- package/tradelayer.js/src/db.js +89 -0
- package/tradelayer.js/src/init.js +24 -0
- package/tradelayer.js/src/insurance.js +347 -0
- package/tradelayer.js/src/interface.js +218 -0
- package/tradelayer.js/src/interfaceExpress.js +178 -0
- package/tradelayer.js/src/iou.js +509 -0
- package/tradelayer.js/src/listener.js +226 -0
- package/tradelayer.js/src/logic.js +1702 -0
- package/tradelayer.js/src/main.js +927 -0
- package/tradelayer.js/src/marginMap.js +2165 -0
- package/tradelayer.js/src/options.js +126 -0
- package/tradelayer.js/src/oracle.js +394 -0
- package/tradelayer.js/src/orderbook.js +4123 -0
- package/tradelayer.js/src/persistence.js +554 -0
- package/tradelayer.js/src/property.js +411 -0
- package/tradelayer.js/src/reOrg.js +41 -0
- package/tradelayer.js/src/scaling.js +145 -0
- package/tradelayer.js/src/tally.js +1275 -0
- package/tradelayer.js/src/tradeHistoryManager.js +552 -0
- package/tradelayer.js/src/txDecoder.js +584 -0
- package/tradelayer.js/src/txEncoder.js +610 -0
- package/tradelayer.js/src/txIndex.js +502 -0
- package/tradelayer.js/src/txUtils.js +1392 -0
- package/tradelayer.js/src/types.js +429 -0
- package/tradelayer.js/src/validity.js +3077 -0
- package/tradelayer.js/src/vaults.js +430 -0
- package/tradelayer.js/src/vesting.js +491 -0
- package/tradelayer.js/src/volumeIndex.js +618 -0
- package/tradelayer.js/src/walletInterface.js +220 -0
- package/tradelayer.js/src/walletListener.js +665 -0
- package/tradelayer.js/tests/256decode.js +82 -0
- package/tradelayer.js/tests/UTXOracle.js +205 -0
- package/tradelayer.js/tests/base94test.js +23 -0
- package/tradelayer.js/tests/cancelTxTest.js +62 -0
- package/tradelayer.js/tests/contractInterfaceTest.js +48 -0
- package/tradelayer.js/tests/decimalTest.js +65 -0
- package/tradelayer.js/tests/decoderTest.js +100 -0
- package/tradelayer.js/tests/deltaCount.js +47 -0
- package/tradelayer.js/tests/deltaCount2.js +60 -0
- package/tradelayer.js/tests/interfaceTest.js +37 -0
- package/tradelayer.js/tests/mainTest.js +53 -0
- package/tradelayer.js/tests/makeActivationTest.js +24 -0
- package/tradelayer.js/tests/maxHeightTest.js +49 -0
- package/tradelayer.js/tests/reverseHash.js +72 -0
- package/tradelayer.js/tests/sensitiveConsoleOutput.txt +267 -0
- package/tradelayer.js/tests/tallyTest.js +40 -0
- package/tradelayer.js/tests/testBuybacks.js +46 -0
- package/tradelayer.js/tests/testCodeHash.js +49 -0
- package/tradelayer.js/tests/testConsensusHash.js +91 -0
- package/tradelayer.js/tests/testDecode.js +30 -0
- package/tradelayer.js/tests/testEncodingLengths.js +129 -0
- package/tradelayer.js/tests/testGetTx +32 -0
- package/tradelayer.js/tests/testGetTx.js +32 -0
- package/tradelayer.js/tests/testHexHash.js +32 -0
- package/tradelayer.js/tests/testIndexHash.js +35 -0
- package/tradelayer.js/tests/testInitContracts.js +38 -0
- package/tradelayer.js/tests/testMaxConsensus.js +12 -0
- package/tradelayer.js/tests/testMaxSynth.js +44 -0
- package/tradelayer.js/tests/testMint.js +21 -0
- package/tradelayer.js/tests/testNetwork.js +33 -0
- package/tradelayer.js/tests/testOrderbookLoad.js +62 -0
- package/tradelayer.js/tests/testRebates.js +32 -0
- package/tradelayer.js/tests/testRedeem.js +22 -0
- package/tradelayer.js/tests/testTokenTrade.js +39 -0
- package/tradelayer.js/tests/testTxBuild.js +42 -0
- package/tradelayer.js/tests/testUTXOTrade.js +27 -0
- package/tradelayer.js/tests/tokenTradeHistory.js +27 -0
- package/tradelayer.js/tests/tradeFutures.js +40 -0
- package/tradelayer.js/tests/tradeHistoryExample.js +35 -0
- package/tradelayer.js/tests/tradeHistoryLoad.js +15 -0
- package/tradelayer.js/tests/txScanTest.js +134 -0
- package/tradelayer.js/tests/validateTest.js +136 -0
- package/tradelayer.js/tests/vestingTest.js +37 -0
- package/tradelayer.js/utils/activateMainnet.js +59 -0
- package/tradelayer.js/utils/activateMainnetDoge.js +63 -0
- package/tradelayer.js/utils/autocompactdb.js +23 -0
- package/tradelayer.js/utils/base64toHex.js +32 -0
- package/tradelayer.js/utils/broadcastDoge.js +38 -0
- package/tradelayer.js/utils/calcRedeem.js +19 -0
- package/tradelayer.js/utils/checkNetwork.js +27 -0
- package/tradelayer.js/utils/createAddress.js +48 -0
- package/tradelayer.js/utils/createAttestation.js +133 -0
- package/tradelayer.js/utils/createContract.js +118 -0
- package/tradelayer.js/utils/createOracle.js +94 -0
- package/tradelayer.js/utils/createwallet.js +20 -0
- package/tradelayer.js/utils/crossFuturesTrades.js +57 -0
- package/tradelayer.js/utils/crossTokenTrades.js +62 -0
- package/tradelayer.js/utils/dumpPriv.js +29 -0
- package/tradelayer.js/utils/generateChannel.js +34 -0
- package/tradelayer.js/utils/getInfo.js +21 -0
- package/tradelayer.js/utils/hardWipe.js +20 -0
- package/tradelayer.js/utils/hexTo64.js +16 -0
- package/tradelayer.js/utils/importAddress.js +28 -0
- package/tradelayer.js/utils/importpriv.js +20 -0
- package/tradelayer.js/utils/issueOracleContract.js +67 -0
- package/tradelayer.js/utils/issueTokens.js +41 -0
- package/tradelayer.js/utils/listunspent.js +66 -0
- package/tradelayer.js/utils/litecoinClient.js +30 -0
- package/tradelayer.js/utils/loadwallet.js +20 -0
- package/tradelayer.js/utils/publishOracle.js +113 -0
- package/tradelayer.js/utils/sendActivation.js +21 -0
- package/tradelayer.js/utils/sendChannelContractTrade.js +34 -0
- package/tradelayer.js/utils/sendChannelTokenTrade.js +34 -0
- package/tradelayer.js/utils/sendCommit.js +24 -0
- package/tradelayer.js/utils/sendDoge.js +62 -0
- package/tradelayer.js/utils/sendDogeMain.js +67 -0
- package/tradelayer.js/utils/sendDogeTx.js +46 -0
- package/tradelayer.js/utils/sendLTC.js +63 -0
- package/tradelayer.js/utils/sendMainnet.js +62 -0
- package/tradelayer.js/utils/sendTransfer.js +19 -0
- package/tradelayer.js/utils/sendVestTest.js +88 -0
- package/tradelayer.js/utils/sendWithdrawal.js +26 -0
- package/tradelayer.js/utils/simpleStart.js +8 -0
- package/tradelayer.js/utils/startStop.js +27 -0
- package/tradelayer.js/utils/structuredTrades.js +136 -0
- package/tradelayer.js/utils/verifySignature.js +90 -0
- package/tradelayer.js/utils/verifyWitnessAndScriptPubkey.js +41 -0
- package/tradelayer.js/utils/walletCache.js +172 -0
- package/tradelayer.js/utils/walletContractInterface.js +48 -0
- package/tradelayer.js/utils/walletFetchTxs.js +66 -0
- package/tradelayer.js/utils/walletUtils.js +97 -0
- package/tradelayer.js/utils/wipeDB.js +55 -0
- package/tradelayer.js/utils/wipeDBNotTx.js +50 -0
- package/txEncoder.js +529 -0
- package/utility.js +28 -0
- package/verifymessage.js +38 -0
- package/ws-transport.js +311 -0
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
//const PropertyManager = require('./property.js');
|
|
2
|
+
//const TallyMap = require('./tally.js');
|
|
3
|
+
//const Logic = require('./logic.js');
|
|
4
|
+
const litecore = require('bitcore-lib-ltc');
|
|
5
|
+
const TxUtils = require('../src/txUtils');
|
|
6
|
+
|
|
7
|
+
function generateNewAddress() {
|
|
8
|
+
const privateKey = new litecore.PrivateKey(); // Generate a new private key
|
|
9
|
+
const address = privateKey.toAddress(); // Generate the address from the private key
|
|
10
|
+
return {
|
|
11
|
+
address: address.toString(),
|
|
12
|
+
privateKey: privateKey.toString()
|
|
13
|
+
};
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
//const { address, privateKey } = generateNewAddress();
|
|
17
|
+
//console.log('Generated new address:', address);
|
|
18
|
+
|
|
19
|
+
TxUtils.activationTransaction('tltc1qa0kd2d39nmeph3hvcx8ytv65ztcywg5sazhtw8',9)
|
|
20
|
+
|
|
21
|
+
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
const PropertyManager = require('./property.js');
|
|
2
|
+
const TallyMap = require('./tally.js');
|
|
3
|
+
const Logic = require('./logic.js');
|
|
4
|
+
const litecore = require('bitcore-lib-ltc');
|
|
5
|
+
const TxUtils = require('./txUtils');
|
|
6
|
+
const TxIndex = require('./txIndex.js')
|
|
7
|
+
|
|
8
|
+
async function executeTransaction() {
|
|
9
|
+
const chainTip = await TxIndex.fetchChainTip();
|
|
10
|
+
|
|
11
|
+
let params = {
|
|
12
|
+
contractId: 1,
|
|
13
|
+
price: 45000,
|
|
14
|
+
amount: 1,
|
|
15
|
+
columnAIsSeller: '1',
|
|
16
|
+
expiryBlock: chainTip + 10,
|
|
17
|
+
insurance: '0'
|
|
18
|
+
};
|
|
19
|
+
|
|
20
|
+
// Function to generate a random number within a range
|
|
21
|
+
function randomNumber(min, max) {
|
|
22
|
+
return Math.floor(Math.random() * (max - min + 1)) + min;
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
var random = randomNumber(20000, 50000);
|
|
26
|
+
console.log('creating contract channel trade - params: '+JSON.stringify(params))
|
|
27
|
+
TxUtils.createChannelContractTradeTransaction('tltc1q7r6x4v67n8vnaftnz8pk33yvf9t9gpynuwdfgk', params, null);
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
// Call the async function
|
|
31
|
+
executeTransaction();
|
|
32
|
+
|
|
33
|
+
//tltc1qa0kd2d39nmeph3hvcx8ytv65ztcywg5sazhtw8
|
|
34
|
+
//tltc1qpgenrwmg9hxgv23mnvd2t7085prjkge2xw7myz
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
const PropertyManager = require('./property.js');
|
|
2
|
+
const TallyMap = require('./tally.js');
|
|
3
|
+
const Logic = require('./logic.js');
|
|
4
|
+
const litecore = require('bitcore-lib-ltc');
|
|
5
|
+
const TxUtils = require('./txUtils');
|
|
6
|
+
const TxIndex = require('./txIndex.js')
|
|
7
|
+
|
|
8
|
+
async function executeTransaction() {
|
|
9
|
+
const chainTip = await TxIndex.fetchChainTip();
|
|
10
|
+
|
|
11
|
+
let params = {
|
|
12
|
+
propertyId1: 3,
|
|
13
|
+
propertyId2: 4,
|
|
14
|
+
amountOffered1: 100,
|
|
15
|
+
amountDesired2: 50,
|
|
16
|
+
expiryBlock:chainTip+10,
|
|
17
|
+
columnAIsOfferer: 0
|
|
18
|
+
}
|
|
19
|
+
// Function to generate a random number within a range
|
|
20
|
+
function randomNumber(min, max) {
|
|
21
|
+
return Math.floor(Math.random() * (max - min + 1)) + min;
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
var random = randomNumber(20000, 50000);
|
|
25
|
+
|
|
26
|
+
TxUtils.createChannelTokenTradeTransaction('tltc1q7r6x4v67n8vnaftnz8pk33yvf9t9gpynuwdfgk', params, null);
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
// Call the async function
|
|
30
|
+
executeTransaction();
|
|
31
|
+
|
|
32
|
+
|
|
33
|
+
//const { address, privateKey } = generateNewAddress();
|
|
34
|
+
//console.log('Generated new address:', address);
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
const PropertyManager = require('./property.js');
|
|
2
|
+
const TallyMap = require('./tally.js');
|
|
3
|
+
const Logic = require('./logic.js');
|
|
4
|
+
const litecore = require('bitcore-lib-ltc');
|
|
5
|
+
const TxUtils = require('./txUtils');
|
|
6
|
+
|
|
7
|
+
let params = {
|
|
8
|
+
propertyId:'s-5-4',
|
|
9
|
+
amount:1,
|
|
10
|
+
channelAddress:'tltc1qn3src8lgu50gxhndn5hnd6zrc9yv2364wu858m'
|
|
11
|
+
}
|
|
12
|
+
//const { address, privateKey } = generateNewAddress();
|
|
13
|
+
//console.log('Generated new address:', address);
|
|
14
|
+
|
|
15
|
+
// Function to generate a random number within a range
|
|
16
|
+
function randomNumber(min, max) {
|
|
17
|
+
return Math.floor(Math.random() * (max - min + 1)) + min;
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
var random = randomNumber(20000,50000)
|
|
21
|
+
|
|
22
|
+
TxUtils.createCommitTransaction('tltc1qn3src8lgu50gxhndn5hnd6zrc9yv2364wu858m',params,4)
|
|
23
|
+
//tltc1qpgenrwmg9hxgv23mnvd2t7085prjkge2xw7myz
|
|
24
|
+
//
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
const dogecore = require("bitcore-lib-doge");
|
|
2
|
+
|
|
3
|
+
function createTransaction({ senderAddress, privateKeyWIF, recipientAddress, amountToSend, utxos, fee }) {
|
|
4
|
+
try {
|
|
5
|
+
// Convert amount to send and fee to satoshis
|
|
6
|
+
const satoshisToSend = Math.floor(amountToSend * 1e8);
|
|
7
|
+
const transactionFee = Math.floor(fee * 1e8);
|
|
8
|
+
|
|
9
|
+
// Validate UTXOs
|
|
10
|
+
const totalInputSatoshis = utxos.reduce((acc, utxo) => acc + utxo.satoshis, 0);
|
|
11
|
+
if (totalInputSatoshis < satoshisToSend + transactionFee) {
|
|
12
|
+
throw new Error("Insufficient funds for the transaction.");
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
// Create a new transaction
|
|
16
|
+
const tx = new dogecore.Transaction()
|
|
17
|
+
.from(utxos) // Add the UTXOs as inputs
|
|
18
|
+
.to(recipientAddress, satoshisToSend) // Specify the recipient and amount
|
|
19
|
+
.change(senderAddress) // Specify the change address
|
|
20
|
+
.fee(transactionFee) // Set the transaction fee
|
|
21
|
+
.sign(privateKeyWIF); // Sign the transaction with the sender's private key
|
|
22
|
+
|
|
23
|
+
// Return the serialized raw transaction hex
|
|
24
|
+
return tx.toString();
|
|
25
|
+
} catch (error) {
|
|
26
|
+
console.error("Error creating transaction:", error.message);
|
|
27
|
+
return null;
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
// Example usage
|
|
32
|
+
const senderAddress = "DLSfu9qvEggkeXAgCAwBBw5BVLvMCtkewz"; // Replace with your Dogecoin address
|
|
33
|
+
const privateKeyWIF = "QW4UD1gNJcYGBPLBGpwTsXKoeVntaT9oNEV1ZU96zTfxc712cwAH"; // Replace with the private key in WIF format
|
|
34
|
+
const recipientAddress = "DNWszyeJFD3qX51cCCDZcBKxnTpbN2N8Sh"; // Replace with recipient's Dogecoin address
|
|
35
|
+
const amountToSend = 6.0; // Amount of Doge to send
|
|
36
|
+
const fee = 1; // Transaction fee in Doge
|
|
37
|
+
|
|
38
|
+
// Replace this with actual UTXOs from your wallet
|
|
39
|
+
const utxos = [
|
|
40
|
+
{
|
|
41
|
+
txId: "fc1835fe96922e6540f614b51b5bcc444db2b860b061ae869ab8aaa41cbbdd6f",
|
|
42
|
+
outputIndex: 0,
|
|
43
|
+
address: senderAddress,
|
|
44
|
+
script: "76a914a7dcce4bf35b50dbe9da38e5dc6758b7ab78ae5a88ac",
|
|
45
|
+
satoshis: 700000000, // 7 Doge in satoshis
|
|
46
|
+
},
|
|
47
|
+
];
|
|
48
|
+
|
|
49
|
+
const rawTx = createTransaction({
|
|
50
|
+
senderAddress,
|
|
51
|
+
privateKeyWIF,
|
|
52
|
+
recipientAddress,
|
|
53
|
+
amountToSend,
|
|
54
|
+
utxos,
|
|
55
|
+
fee,
|
|
56
|
+
});
|
|
57
|
+
|
|
58
|
+
if (rawTx) {
|
|
59
|
+
console.log("Raw Transaction Hex:", rawTx);
|
|
60
|
+
} else {
|
|
61
|
+
console.error("Failed to create transaction.");
|
|
62
|
+
}
|
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
const dogecore = require("bitcore-lib-doge"); // Dogecoin library
|
|
2
|
+
const Encode = require("../src/txEncoder.js");
|
|
3
|
+
|
|
4
|
+
// Constants
|
|
5
|
+
const STANDARD_FEE = 250000; // 0.01 DOGE in satoshis
|
|
6
|
+
const DUST_THRESHOLD = 1000000; // 0.01 DOGE in satoshis (dust threshold)
|
|
7
|
+
|
|
8
|
+
// Function to send Dogecoin
|
|
9
|
+
async function sendDogecoin(senderAddress, recipientAddress, amountToSend) {
|
|
10
|
+
//try {
|
|
11
|
+
// Define UTXOs for the sender address
|
|
12
|
+
const utxos = [
|
|
13
|
+
{
|
|
14
|
+
txId: "5144f44bc8cec947eb757ce9377f75f3321f2f0f92cd1e2526526df1179ae744",
|
|
15
|
+
outputIndex: 0,
|
|
16
|
+
address: senderAddress,
|
|
17
|
+
script: "76a914226eae66f1d4da7f47015be99d1c4e2484e39b9c88ac", // P2PKH script
|
|
18
|
+
satoshis: 78750000, // 0.1 DOGE in satoshis
|
|
19
|
+
},
|
|
20
|
+
];
|
|
21
|
+
|
|
22
|
+
// Calculate total input balance
|
|
23
|
+
const totalInput = utxos.reduce((sum, utxo) => sum + utxo.satoshis, 0);
|
|
24
|
+
|
|
25
|
+
|
|
26
|
+
// Calculate change
|
|
27
|
+
const change = totalInput - amountToSend - STANDARD_FEE;
|
|
28
|
+
const out = amountToSend-STANDARD_FEE
|
|
29
|
+
// Prepare OP_RETURN payload
|
|
30
|
+
const params = {
|
|
31
|
+
sendAll: 0,
|
|
32
|
+
propertyId: 1,
|
|
33
|
+
amount: 20000000,
|
|
34
|
+
address: "D7NdPZKMnMo9pdmJik15TLDCSN9rXBFNMa", // Example Dogecoin address
|
|
35
|
+
isColoredOutput: 0,
|
|
36
|
+
};
|
|
37
|
+
const opReturnData = Encode.encodeSend(params);
|
|
38
|
+
const opReturnScript = dogecore.Script.buildDataOut(opReturnData);
|
|
39
|
+
|
|
40
|
+
// Create transaction
|
|
41
|
+
const tx = new dogecore.Transaction()
|
|
42
|
+
.from(utxos)
|
|
43
|
+
.to(recipientAddress, out) // Send specified amount
|
|
44
|
+
.fee(STANDARD_FEE) // Include transaction fee
|
|
45
|
+
.addOutput(
|
|
46
|
+
new dogecore.Transaction.Output({
|
|
47
|
+
script: opReturnScript,
|
|
48
|
+
satoshis: 0, // OP_RETURN value must be 0
|
|
49
|
+
})
|
|
50
|
+
);
|
|
51
|
+
|
|
52
|
+
|
|
53
|
+
// Serialize transaction
|
|
54
|
+
const serializedTx = tx.toString();
|
|
55
|
+
console.log(`Transaction hex: ${serializedTx}`);
|
|
56
|
+
//} catch (error) {
|
|
57
|
+
//console.error("Error constructing transaction:", error.message);
|
|
58
|
+
//}
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
// Replace with actual values
|
|
62
|
+
const senderAddress = "D8HA73pAhxK7eNXSUVhQrWpUkrszUDGs7Z"; // Example sender address
|
|
63
|
+
const recipientAddress = "D8HA73pAhxK7eNXSUVhQrWpUkrszUDGs7Z"; // Example recipient address
|
|
64
|
+
const amountToSend = 78750000; // 0.09 DOGE in satoshis
|
|
65
|
+
|
|
66
|
+
// Execute the function
|
|
67
|
+
sendDogecoin(senderAddress, recipientAddress, amountToSend);
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
const axios = require('axios');
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Broadcasts a Dogecoin transaction using the Tatum API.
|
|
5
|
+
*
|
|
6
|
+
* @param {string} txHex - The raw transaction hex string (signed).
|
|
7
|
+
* @param {string} apiKey - Your Tatum API key.
|
|
8
|
+
*/
|
|
9
|
+
async function broadcastDogecoinTransaction(txHex, apiKey) {
|
|
10
|
+
const apiUrl = 'https://api.tatum.io/v3/dogecoin/broadcast';
|
|
11
|
+
|
|
12
|
+
try {
|
|
13
|
+
// Prepare the payload
|
|
14
|
+
const payload = {
|
|
15
|
+
txData: txHex
|
|
16
|
+
};
|
|
17
|
+
|
|
18
|
+
// Send the POST request to the Tatum API
|
|
19
|
+
const response = await axios.post(apiUrl, payload, {
|
|
20
|
+
headers: {
|
|
21
|
+
'Content-Type': 'application/json',
|
|
22
|
+
'x-api-key': apiKey // Set your API key in the headers
|
|
23
|
+
}
|
|
24
|
+
});
|
|
25
|
+
|
|
26
|
+
// Check if the broadcast was successful
|
|
27
|
+
if (response.status === 200) {
|
|
28
|
+
console.log("Transaction broadcasted successfully!");
|
|
29
|
+
console.log("Response:", response.data);
|
|
30
|
+
} else {
|
|
31
|
+
console.error(`Failed to broadcast transaction. Status Code: ${response.status}`);
|
|
32
|
+
console.error("Response:", response.data);
|
|
33
|
+
}
|
|
34
|
+
} catch (error) {
|
|
35
|
+
if (error.response) {
|
|
36
|
+
console.error("API Response Error:", error.response.data);
|
|
37
|
+
} else {
|
|
38
|
+
console.error("Error:", error.message);
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
// Example Usage
|
|
44
|
+
const txHex = "010000000144e79a17f16d5226251ecd920f2f1f32f3757f37e97c75eb47c9cec84bf44451000000006b483045022100a6ea0b1cd9b404030a53fcee8b445a8026bc8337b67d254c77cd7ef4a0193ad30220045f771a506a0b3ddb0dea03379754bf0e2a166ed3a02793c7ef7e7f062eeceb0121034480f60d0010d92fb3e35516e4ddef458c0f7405010afce931488ed1c0570ba6ffffffff02a0d0ad04000000001976a914226eae66f1d4da7f47015be99d1c4e2484e39b9c88ac0000000000000000336a31746c32303b44374e64505a4b4d6e4d6f3970646d4a696b3135544c4443534e39725842464e4d613b313b62776f336b3b3000000000"; // Replace with your signed transaction hex
|
|
45
|
+
const apiKey = "t-6796b068758217afa9cf49ca-93175dba4b9545f3be960d83"; // Replace with your Tatum API key
|
|
46
|
+
broadcastDogecoinTransaction(txHex, apiKey);
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
const async = require('async');
|
|
2
|
+
const util = require('util');
|
|
3
|
+
const litecore = require('bitcore-lib-ltc');
|
|
4
|
+
const Encode = require('../src/txEncoder.js');
|
|
5
|
+
const litecoin = require('litecoin');
|
|
6
|
+
|
|
7
|
+
const clientConfig = /*test ?*/ {
|
|
8
|
+
host: '127.0.0.1',
|
|
9
|
+
port: 18332,
|
|
10
|
+
user: 'user',
|
|
11
|
+
pass: 'pass',
|
|
12
|
+
timeout: 10000
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
const client = new litecoin.Client(clientConfig);
|
|
16
|
+
// Assuming standard fee and other constants are defined
|
|
17
|
+
const STANDARD_FEE = 10000; // Standard fee in satoshis
|
|
18
|
+
const DUST_THRESHOLD = 54600;
|
|
19
|
+
|
|
20
|
+
// Promisify client functions
|
|
21
|
+
const listUnspentAsync = util.promisify(client.cmd.bind(client, 'listunspent'));
|
|
22
|
+
const dumpprivkeyAsync = util.promisify(client.cmd.bind(client, 'dumpprivkey'));
|
|
23
|
+
const sendrawtransactionAsync = util.promisify(client.cmd.bind(client, 'sendrawtransaction'));
|
|
24
|
+
|
|
25
|
+
async function sendLitecoin(senderAddress, recipientAddress, amountToSend) {
|
|
26
|
+
let send = amountToSend*100000000
|
|
27
|
+
try {
|
|
28
|
+
// Fetch the private key for the sender address
|
|
29
|
+
const privateKeyWIF = await dumpprivkeyAsync(senderAddress);
|
|
30
|
+
console.log('privateKeyWIF '+privateKeyWIF)
|
|
31
|
+
const privateKey = new litecore.PrivateKey.fromWIF(privateKeyWIF);
|
|
32
|
+
console.log('privatekey '+privateKey)
|
|
33
|
+
// Fetch UTXOs for the sender address
|
|
34
|
+
const utxos = await listUnspentAsync(1, 9999999, [senderAddress]);
|
|
35
|
+
if (!utxos || utxos.length === 0) {
|
|
36
|
+
throw new Error('No UTXOs available for the sender address');
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
// Create a new transaction
|
|
40
|
+
const tx = new litecore.Transaction()
|
|
41
|
+
.from(utxos)
|
|
42
|
+
.to(recipientAddress, send)
|
|
43
|
+
.change(senderAddress)
|
|
44
|
+
.fee(STANDARD_FEE)
|
|
45
|
+
.sign(privateKey);
|
|
46
|
+
|
|
47
|
+
// Serialize and broadcast the transaction
|
|
48
|
+
const serializedTx = tx.uncheckedSerialize();
|
|
49
|
+
const txid = await sendrawtransactionAsync(serializedTx);
|
|
50
|
+
console.log(`Transaction sent successfully. TXID: ${txid}`);
|
|
51
|
+
} catch (error) {
|
|
52
|
+
console.error('Error sending Litecoin:', error);
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
// Replace with actual values
|
|
57
|
+
const senderAddress = "tltc1qa0kd2d39nmeph3hvcx8ytv65ztcywg5sazhtw8"; //tltc1qfffvwpftp8w3kv6gg6273ejtsfnu2dara5x4tr
|
|
58
|
+
const recipientAddress = "tltc1qqgru3cahyq5tj7l5q066ssv33gg3v7z9auxkcg"//tltc1qtee90ysf57393hfqyn79syj9mkekm7hq0epqzw"
|
|
59
|
+
//tltc1qp5z2la8sy69np798pc36up5zk2vg0fw2g7pml2"//tltc1qn3src8lgu50gxhndn5hnd6zrc9yv2364wu858m" //"tltc1qpgenrwmg9hxgv23mnvd2t7085prjkge2xw7myz"
|
|
60
|
+
const amountToSend = 0.01; // Amount of LTC to send
|
|
61
|
+
|
|
62
|
+
// Execute the function to send Litecoin
|
|
63
|
+
sendLitecoin(senderAddress, recipientAddress, amountToSend);
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
const async = require('async');
|
|
2
|
+
const util = require('util');
|
|
3
|
+
const litecore = require('bitcore-lib-ltc');
|
|
4
|
+
const Encode = require('../src/txEncoder.js');
|
|
5
|
+
|
|
6
|
+
// Assuming standard fee and other constants are defined
|
|
7
|
+
const STANDARD_FEE = 3000; // Standard fee in satoshis
|
|
8
|
+
const DUST_THRESHOLD = 5460;
|
|
9
|
+
|
|
10
|
+
async function sendLitecoin(senderAddress, recipientAddress, amountToSend) {
|
|
11
|
+
let send = amountToSend-STANDARD_FEE
|
|
12
|
+
try {
|
|
13
|
+
// Fetch the private key for the sender address
|
|
14
|
+
// Fetch UTXOs for the sender address
|
|
15
|
+
|
|
16
|
+
//console.log('bleh '+litecore.Script.buildScriptHashOut('d9feb2d55d2c022d4fc463ab54dcbdd75f7b0ebc'))
|
|
17
|
+
const utxos = [{
|
|
18
|
+
txId: 'ae5ca8a023576e90a661685b8ca16a98abecd75fb5e3473b60f53413f150de11',
|
|
19
|
+
outputIndex: 0,
|
|
20
|
+
address: senderAddress,
|
|
21
|
+
script: "a914fa55f5d92be2c5ea8c2ec3a7630cc4ebf22b963587",
|
|
22
|
+
satoshis: 497000, // Amount in satoshis
|
|
23
|
+
}]
|
|
24
|
+
const params = {
|
|
25
|
+
sendAll: 0, // Activation types
|
|
26
|
+
propertyId: 1,
|
|
27
|
+
amount: 10000,
|
|
28
|
+
address: "ltc1q6c2gdte3pcf49at8z9ylnxy40ljlgaw5dqhxca",
|
|
29
|
+
isColoredOutput: 0
|
|
30
|
+
};
|
|
31
|
+
const opReturnData = Encode.encodeSend(params);
|
|
32
|
+
console.log('payload '+opReturnData)
|
|
33
|
+
const opReturnScript = litecore.Script.buildDataOut(opReturnData);
|
|
34
|
+
// Create a new transaction
|
|
35
|
+
const tx = new litecore.Transaction()
|
|
36
|
+
.from(utxos)
|
|
37
|
+
.to(recipientAddress, send)
|
|
38
|
+
//.change(senderAddress)
|
|
39
|
+
.fee(STANDARD_FEE)
|
|
40
|
+
.addOutput(new litecore.Transaction.Output({
|
|
41
|
+
script: opReturnScript,
|
|
42
|
+
satoshis: 0,
|
|
43
|
+
}))
|
|
44
|
+
//.sign(privateKey);
|
|
45
|
+
|
|
46
|
+
// Serialize and broadcast the transaction
|
|
47
|
+
const serializedTx = tx.toString();
|
|
48
|
+
//const txid = await sendrawtransactionAsync(serializedTx);
|
|
49
|
+
console.log(`Transaction hex to sign: ${tx}`);
|
|
50
|
+
} catch (error) {
|
|
51
|
+
console.error('Error sending Litecoin:', error);
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
// Replace with actual values
|
|
56
|
+
const senderAddress = "MWip91xMhaEmDn5oUW5NDNbWSDyG5dSK9Q"; //tltc1qfffvwpftp8w3kv6gg6273ejtsfnu2dara5x4tr
|
|
57
|
+
const recipientAddress = "MWip91xMhaEmDn5oUW5NDNbWSDyG5dSK9Q"
|
|
58
|
+
//tltc1qp5z2la8sy69np798pc36up5zk2vg0fw2g7pml2"//tltc1qn3src8lgu50gxhndn5hnd6zrc9yv2364wu858m" //"tltc1qpgenrwmg9hxgv23mnvd2t7085prjkge2xw7myz"
|
|
59
|
+
const amountToSend = 497000; // Amount of LTC to send
|
|
60
|
+
|
|
61
|
+
// Execute the function to send Litecoin
|
|
62
|
+
sendLitecoin(senderAddress, recipientAddress, amountToSend);
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
const PropertyManager = require('./property.js');
|
|
2
|
+
const TallyMap = require('./tally.js');
|
|
3
|
+
const Logic = require('./logic.js');
|
|
4
|
+
const litecore = require('bitcore-lib-ltc');
|
|
5
|
+
const TxUtils = require('./txUtils');
|
|
6
|
+
|
|
7
|
+
//const { address, privateKey } = generateNewAddress();
|
|
8
|
+
//console.log('Generated new address:', address);
|
|
9
|
+
|
|
10
|
+
const params = {
|
|
11
|
+
propertyId:4,
|
|
12
|
+
amount: 998,
|
|
13
|
+
isColumnA: 0,
|
|
14
|
+
destinationAddr: 'tltc1q7r6x4v67n8vnaftnz8pk33yvf9t9gpynuwdfgk'
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
TxUtils.createTransferTransaction('tltc1qa0kd2d39nmeph3hvcx8ytv65ztcywg5sazhtw8',params)
|
|
18
|
+
|
|
19
|
+
|
|
@@ -0,0 +1,88 @@
|
|
|
1
|
+
const litecoin = require('litecoin');
|
|
2
|
+
const util = require('util');
|
|
3
|
+
const litecore = require('bitcore-lib-ltc');
|
|
4
|
+
const TxUtils = require('../src/txUtils.js');
|
|
5
|
+
|
|
6
|
+
const clientConfig = {
|
|
7
|
+
host: '127.0.0.1',
|
|
8
|
+
port: 18332,
|
|
9
|
+
user: 'user',
|
|
10
|
+
pass: 'pass',
|
|
11
|
+
timeout: 10000
|
|
12
|
+
};
|
|
13
|
+
|
|
14
|
+
const client = new litecoin.Client(clientConfig);
|
|
15
|
+
|
|
16
|
+
const listUnspentAsync = util.promisify(client.cmd.bind(client, 'listunspent'));
|
|
17
|
+
const dumpPrivKeyAsync = util.promisify(client.cmd.bind(client, 'dumpprivkey'));
|
|
18
|
+
const sendrawtransactionAsync = util.promisify(client.cmd.bind(client, 'sendrawtransaction'));
|
|
19
|
+
|
|
20
|
+
// Function to dump the private key and fetch the biggest unspent output
|
|
21
|
+
async function prepareTransactionParams(address) {
|
|
22
|
+
try {
|
|
23
|
+
// Dump the private key of the given address
|
|
24
|
+
const privateKey = await dumpPrivKeyAsync(address);
|
|
25
|
+
console.log('Private Key:', privateKey);
|
|
26
|
+
|
|
27
|
+
// List all unspent outputs
|
|
28
|
+
const unspentOutputs = await listUnspentAsync(0, 9999999, [address]);
|
|
29
|
+
|
|
30
|
+
if (!unspentOutputs.length) {
|
|
31
|
+
throw new Error('No unspent outputs available for the address.');
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
// Find the biggest unspent output
|
|
35
|
+
const biggestUnspent = unspentOutputs.reduce((prev, current) => {
|
|
36
|
+
return prev.amount > current.amount ? prev : current;
|
|
37
|
+
});
|
|
38
|
+
|
|
39
|
+
console.log('Biggest Unspent Output:', biggestUnspent);
|
|
40
|
+
|
|
41
|
+
// Return private key and unspent output data
|
|
42
|
+
return {
|
|
43
|
+
privateKey,
|
|
44
|
+
utxo: {
|
|
45
|
+
txid: biggestUnspent.txid,
|
|
46
|
+
vout: biggestUnspent.vout,
|
|
47
|
+
scriptPubKey: biggestUnspent.scriptPubKey,
|
|
48
|
+
amount: biggestUnspent.amount
|
|
49
|
+
}
|
|
50
|
+
};
|
|
51
|
+
} catch (error) {
|
|
52
|
+
console.error('Error preparing transaction parameters:', error);
|
|
53
|
+
throw error;
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
// Example async function to send a transaction
|
|
58
|
+
async function sendTransactionWithParams(fromAddress, toAddress, propertyid, amount, sendall) {
|
|
59
|
+
try {
|
|
60
|
+
// Prepare parameters
|
|
61
|
+
const { privateKey, utxo } = await prepareTransactionParams(fromAddress);
|
|
62
|
+
|
|
63
|
+
console.log('Prepared Parameters:', { privateKey, utxo });
|
|
64
|
+
|
|
65
|
+
// Call TxUtils.sendTransaction with the prepared parameters
|
|
66
|
+
const txid = await TxUtils.sendTransaction(fromAddress, toAddress, propertyid, amount, false,
|
|
67
|
+
privateKey,
|
|
68
|
+
utxo
|
|
69
|
+
);
|
|
70
|
+
|
|
71
|
+
console.log('Transaction sent successfully.');
|
|
72
|
+
} catch (error) {
|
|
73
|
+
console.error('Error sending transaction:', error);
|
|
74
|
+
}
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
// Example usage
|
|
78
|
+
sendTransactionWithParams(
|
|
79
|
+
'tltc1qfffvwpftp8w3kv6gg6273ejtsfnu2dara5x4tr',
|
|
80
|
+
'tltc1qn3src8lgu50gxhndn5hnd6zrc9yv2364wu858m',
|
|
81
|
+
5,
|
|
82
|
+
10000,
|
|
83
|
+
false
|
|
84
|
+
);
|
|
85
|
+
|
|
86
|
+
//tltc1qa0kd2d39nmeph3hvcx8ytv65ztcywg5sazhtw8
|
|
87
|
+
//tltc1qtee90ysf57393hfqyn79syj9mkekm7hq0epqzw
|
|
88
|
+
//tltc1qxcyu5682whfzpjunwu6ek39dvc8lqmjtvxmscc
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
const PropertyManager = require('./property.js');
|
|
2
|
+
const TallyMap = require('./tally.js');
|
|
3
|
+
const Logic = require('./logic.js');
|
|
4
|
+
const litecore = require('bitcore-lib-ltc');
|
|
5
|
+
const TxUtils = require('./txUtils');
|
|
6
|
+
|
|
7
|
+
let params = {
|
|
8
|
+
withdrawAll: 0,
|
|
9
|
+
propertyId: 4,
|
|
10
|
+
amount:500,
|
|
11
|
+
column: 0,
|
|
12
|
+
channelAddress:'tltc1q7r6x4v67n8vnaftnz8pk33yvf9t9gpynuwdfgk'
|
|
13
|
+
}
|
|
14
|
+
//const { address, privateKey } = generateNewAddress();
|
|
15
|
+
//console.log('Generated new address:', address);
|
|
16
|
+
|
|
17
|
+
// Function to generate a random number within a range
|
|
18
|
+
function randomNumber(min, max) {
|
|
19
|
+
return Math.floor(Math.random() * (max - min + 1)) + min;
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
var random = randomNumber(20000,50000)
|
|
23
|
+
|
|
24
|
+
TxUtils.createWithdrawalTransaction('tltc1qa0kd2d39nmeph3hvcx8ytv65ztcywg5sazhtw8',params)
|
|
25
|
+
//tltc1qpgenrwmg9hxgv23mnvd2t7085prjkge2xw7myz
|
|
26
|
+
//tltc1qa0kd2d39nmeph3hvcx8ytv65ztcywg5sazhtw8
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
const { exec } = require('child_process');
|
|
2
|
+
|
|
3
|
+
function startLitecoind() {
|
|
4
|
+
// Starting litecoind with server and RPC flags
|
|
5
|
+
exec('litecoind -daemon --server -rpcuser=yourusername -rpcpassword=yourpassword', (err, stdout, stderr) => {
|
|
6
|
+
if (err) {
|
|
7
|
+
console.error(`Error starting litecoind: ${err}`);
|
|
8
|
+
return;
|
|
9
|
+
}
|
|
10
|
+
console.log(`litecoind started: ${stdout}`);
|
|
11
|
+
});
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
function stopLitecoind() {
|
|
15
|
+
// Stopping litecoind
|
|
16
|
+
exec('litecoin-cli stop', (err, stdout, stderr) => {
|
|
17
|
+
if (err) {
|
|
18
|
+
console.error(`Error stopping litecoind: ${err}`);
|
|
19
|
+
return;
|
|
20
|
+
}
|
|
21
|
+
console.log(`litecoind stopped: ${stdout}`);
|
|
22
|
+
});
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
// Example usage
|
|
26
|
+
startLitecoind();
|
|
27
|
+
// When you need to stop litecoind, call stopLitecoind()
|