Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
const RegisterPacketTransaction = require('../transactions/register-packet');
const transactions = require('@liskhq/lisk-transactions');
const { EPOCH_TIME } = require('@liskhq/lisk-constants');
const accounts = require('./accounts.json');
const getTimestamp = () => {
// check config file or curl localhost:4000/api/node/constants to verify your epoc time (OK when using /transport/node/index.js)
const millisSinceEpoc = Date.now() - Date.parse(EPOCH_TIME);
const inSeconds = ((millisSinceEpoc) / 1000).toFixed(0);
return parseInt(inSeconds);
};
let tx = new RegisterPacketTransaction({
asset: {
packetId: accounts.packet.address,
postage: `${transactions.utils.convertLSKToBeddows('5')}`,
security: `${transactions.utils.convertLSKToBeddows('100')}`,
minTrust: 0,
},
fee: '0',
recipientId: accounts.recipient.address,
timestamp: getTimestamp()
});
tx.sign(accounts.sender.passphrase); // 16313739661670634666L
console.log(tx.stringify());
process.exit(0);
const packetCredentials = { address: '5420762878027534930L',
passphrase:
'range axis twin quote rate rifle cute math quantum talk must round',
publicKey:
'1529b602ea69497ff5e38c3d1db5e90f9dfb6ee2f0e83534c89f18579a24653b',
privateKey:
'f3058da026f8b1a93643dc6864fc5ef7830b7614dd09292bc5f2ca3d4b115f9e1529b602ea69497ff5e38c3d1db5e90f9dfb6ee2f0e83534c89f18579a24653b'
}; // insert here the packetCredentials-object created in create_and_initialize_packet_account.js
let tx = new RegisterPacketTransaction({
asset: {
packetId: packetCredentials.address,
senderLocation: "def alley, 456 someCity",
receipientLocation: "abc street, 123 someCity",
porto: `${transactions.utils.convertLSKToBeddows('5')}`,
security: `${transactions.utils.convertLSKToBeddows('100')}`,
minTrust: 25,
estTravelTime: "18000", // 18,000 seconds = 5 hrs
},
fee: "0",
recipientId: "10881167371402274308L",
timestamp: getTimestamp()
});
tx.sign('wagon stock borrow episode laundry kitten salute link globe zero feed marble');
console.log(tx.stringify());
process.exit(0);
const packetCredentials = { address: '5420762878027534930L',
passphrase:
'range axis twin quote rate rifle cute math quantum talk must round',
publicKey:
'1529b602ea69497ff5e38c3d1db5e90f9dfb6ee2f0e83534c89f18579a24653b',
privateKey:
'f3058da026f8b1a93643dc6864fc5ef7830b7614dd09292bc5f2ca3d4b115f9e1529b602ea69497ff5e38c3d1db5e90f9dfb6ee2f0e83534c89f18579a24653b'
}; // insert here the packetCredentials-object created in create_and_initialize_packet_account.js
let tx = new RegisterPacketTransaction({
asset: {
packetId: packetCredentials.address,
senderLocation: "def alley, 456 someCity",
receipientLocation: "abc street, 123 someCity",
porto: `${transactions.utils.convertLSKToBeddows('5')}`,
security: `${transactions.utils.convertLSKToBeddows('100')}`,
minTrust: 25,
estTravelTime: "18000", // 18,000 seconds = 5 hrs
},
fee: "0",
recipientId: "10881167371402274308L",
timestamp: getTimestamp()
});
tx.sign('wagon stock borrow episode laundry kitten salute link globe zero feed marble');
console.log(tx.stringify());
process.exit(0);
const transactions = require('@liskhq/lisk-transactions');
const cryptography = require('@liskhq/lisk-cryptography');
const { APIClient } = require('@liskhq/lisk-api-client');
const { Mnemonic } = require('@liskhq/lisk-passphrase');
const accounts = require('./accounts.json');
const api = new APIClient(['http://localhost:4000']);
let tx = new transactions.TransferTransaction({
amount: `${transactions.utils.convertLSKToBeddows('2000')}`,
recipientId: accounts.carrier.address,
});
tx.sign('wagon stock borrow episode laundry kitten salute link globe zero feed marble'); // Genesis account with address: 16313739661670634666L
api.transactions.broadcast(tx.toJSON()).then(res => {
console.log("++++++++++++++++ API Response +++++++++++++++++");
console.log(res.data);
console.log("++++++++++++++++ Transaction Payload +++++++++++++++++");
console.log(tx.stringify());
console.log("++++++++++++++++ End Script +++++++++++++++++");
}).catch(err => {
console.log(JSON.stringify(err.errors, null, 2));
});
const recipientId = '16313739661670634666L'; // Address of user that send the invoice to me
const passphrase = 'robust swift grocery peasant forget share enable convince deputy road keep cheap'; // Passphrase of person who wants to fulfill invoice (associated address: 8273455169423958419L)
const paymentJSON = createPaymentJSON({
recipientId,
amount: '11', // Requested amount: 10.5 (want to give bit extra)
invoiceId: '6068542855269194380', // Look up the ID of the invoice you have created (use: http://localhost:4000/api/transactions?type=13)
}, passphrase);
console.log('------------- Payment Tx - Type 14 -----------------');
console.log(paymentJSON);
console.log('------------- Fund Account Tx - Type 0 -----------------');
// ------- Payment JSON to fund account ------- //
const transaction = transactions.utils.signRawTransaction({
transaction: {
type: 0,
amount: '10000000000', // 100 LSK
recipientId: '8273455169423958419L',
fee: '10000000',
asset: {},
},
passphrase: 'wagon stock borrow episode laundry kitten salute link globe zero feed marble',
});
console.log(JSON.stringify(transaction));
app.post('/faucet', function (req, res) {
const address = req.body.address;
const amount = req.body.amount;
const fundTransaction = new transactions.TransferTransaction({
amount: transactions.utils.convertLSKToBeddows(amount),
recipientId: address,
});
fundTransaction.sign(accounts.sender.passphrase); // Genesis account
api.transactions.broadcast(fundTransaction.toJSON()).then(response => {
res.app.locals.payload = {
res: response.data,
tx: fundTransaction.toJSON(),
};
console.log("++++++++++++++++ API Response +++++++++++++++++");
console.log(response.data);
console.log("++++++++++++++++ Transaction Payload +++++++++++++++++");
console.log(fundTransaction.stringify());
console.log("++++++++++++++++ End Script +++++++++++++++++");
res.redirect('/payload');
}).catch(err => {
app.post('/faucet', function (req, res) {
const address = req.body.address;
const amount = req.body.amount;
const fundTransaction = new transactions.TransferTransaction({
amount: transactions.utils.convertLSKToBeddows(amount),
recipientId: address,
});
fundTransaction.sign(accounts.sender.passphrase); // Genesis account
api.transactions.broadcast(fundTransaction.toJSON()).then(response => {
res.app.locals.payload = {
res: response.data,
tx: fundTransaction.toJSON(),
};
console.log("++++++++++++++++ API Response +++++++++++++++++");
console.log(response.data);
console.log("++++++++++++++++ Transaction Payload +++++++++++++++++");
console.log(fundTransaction.stringify());
console.log("++++++++++++++++ End Script +++++++++++++++++");
res.redirect('/payload');
const transactions = require('@liskhq/lisk-transactions');
const cryptography = require('@liskhq/lisk-cryptography');
const { APIClient } = require('@liskhq/lisk-api-client');
const { Mnemonic } = require('@liskhq/lisk-passphrase');
const accounts = require('./accounts.json');
const api = new APIClient(['http://localhost:4000']);
let tx = new transactions.TransferTransaction({
amount: `${transactions.utils.convertLSKToBeddows('2000')}`,
recipientId: accounts.carrier.address,
});
tx.sign('wagon stock borrow episode laundry kitten salute link globe zero feed marble'); // Genesis account with address: 16313739661670634666L
api.transactions.broadcast(tx.toJSON()).then(res => {
console.log("++++++++++++++++ API Response +++++++++++++++++");
console.log(res.data);
console.log("++++++++++++++++ Transaction Payload +++++++++++++++++");
console.log(tx.stringify());
console.log("++++++++++++++++ End Script +++++++++++++++++");
}).catch(err => {
console.log(JSON.stringify(err.errors, null, 2));
});
const passphrase = Mnemonic.generateMnemonic();
const keys = cryptography.getPrivateAndPublicKeyFromPassphrase(
passphrase
);
const credentials = {
address: cryptography.getAddressFromPublicKey(keys.publicKey),
passphrase: passphrase,
publicKey: keys.publicKey,
privateKey: keys.privateKey
};
return credentials;
};
const packetCredentials = getPacketCredentials();
let tx = new transactions.TransferTransaction({
amount: '1',
recipientId: packetCredentials.address,
});
tx.sign('wagon stock borrow episode laundry kitten salute link globe zero feed marble'); // Genesis account with address: 16313739661670634666L
res.render('initialize', { packetCredentials });
api.transactions.broadcast(tx.toJSON()).then(res => {
console.log("++++++++++++++++ API Response +++++++++++++++++");
console.log(res.data);
console.log("++++++++++++++++ Credentials +++++++++++++++++");
console.dir(packetCredentials);
console.log("++++++++++++++++ Transaction Payload +++++++++++++++++");
console.log(tx.stringify());
console.log("++++++++++++++++ End Script +++++++++++++++++");
}).catch(err => {
const passphrase = Mnemonic.generateMnemonic();
const keys = cryptography.getPrivateAndPublicKeyFromPassphrase(
passphrase
);
const credentials = {
address: cryptography.getAddressFromPublicKey(keys.publicKey),
passphrase: passphrase,
publicKey: keys.publicKey,
privateKey: keys.privateKey
};
return credentials;
};
const packetCredentials = getPacketCredentials();
let tx = new transactions.TransferTransaction({
amount: '1',
recipientId: packetCredentials.address,
});
tx.sign('wagon stock borrow episode laundry kitten salute link globe zero feed marble'); // Genesis account with address: 16313739661670634666L
api.transactions.broadcast(tx.toJSON()).then(res => {
console.log("++++++++++++++++ API Response +++++++++++++++++");
console.log(res.data);
console.log("++++++++++++++++ Credentials +++++++++++++++++");
console.dir(packetCredentials);
console.log("++++++++++++++++ Transaction Payload +++++++++++++++++");
console.log(tx.stringify());
console.log("++++++++++++++++ End Script +++++++++++++++++");
}).catch(err => {
console.log(JSON.stringify(err.errors, null, 2));