Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
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));
to: addressTo => {
const amountBeddows = `${amount * this.fixedPoint}`;
const transferTx = new TransferTransaction({
amount: amountBeddows,
recipientId: Object.values(this.state.accounts).find(
anAccount => anAccount.address === addressTo,
).address,
timestamp: this.timestamp,
});
transferTx.sign(
Object.values(this.state.accounts).find(
anAccount => anAccount.address === addressFrom,
).passphrase,
);
// Push it to pending transaction
this.state.pendingTransactions.push(transferTx);
this.lastTransactionId = transferTx._id;
return this;
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: '1235',
recipientId: packetCredentials.address,
});
tx.sign('wagon stock borrow episode laundry kitten salute link globe zero feed marble');
api.transactions.broadcast(tx.toJSON()).then(res => {
console.log(res.data);
console.log("+++++++++++++++++++++++++++++++++" );
console.dir(packetCredentials);
console.log("+++++++++++++++++++++++++++++++++" );
console.log("+++++++++++++++++++++++++++++++++" );
console.log(tx.stringify());
console.log("+++++++++++++++++++++++++++++++++" );
}).catch(err => { console.log(JSON.stringify(err.errors, null, 2)) });
const generateTestCasesValidBlockSecondSignatureTx = () => {
const amount = '5500000000';
const transferObject = {
amount,
recipientId: accounts.existingDelegate.address,
timestamp,
};
const transferTx = new TransferTransaction(transferObject);
transferTx.sign(accounts.genesis.passphrase);
const block = createBlock(
defaultConfig,
initialAccountState,
genesisBlock,
1,
0,
{
version: 1,
transactions: [transferTx],
},
);
const { balance: senderBalance } = initialAccountState.find(
account => account.address === accounts.genesis.address,
inputs.timestamp = inputs.timestamp || 0;
const recipientIdFromPublicKey = recipientPublicKey
? getAddressFromPublicKey(recipientPublicKey)
: undefined;
inputs.recipientId = recipientIdFromPublicKey
? recipientIdFromPublicKey
: inputs.recipientId;
if (!passphrase) {
throw "Cannot sign a transaction without a passphrase. Specify your passphrase as in the input object (and optional second passphrase)";
}
const transferTransaction = new TransferTransaction(
{
asset: data ? { data } : {},
amount,
fee,
recipientId,
senderPublicKey,
type,
timestamp,
}
);
transferTransaction.sign(passphrase, secondPassphrase);
return asJSON(skipUndefined(transferTransaction.toJSON()));
};