Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
/* Validate Parameters */
validateNewPayment(payment);
// Convert blank issuer to sender's address (Ripple convention for 'any issuer')
if (payment.source_amount && payment.source_amount.currency !== 'XRP' && payment.source_amount.issuer === '') {
payment.source_amount.issuer = payment.source_address;
}
if (payment.destination_amount && payment.destination_amount.currency !== 'XRP' && payment.destination_amount.issuer === '') {
payment.destination_amount.issuer = payment.destination_address;
}
/* Construct payment */
var tx = (opts.remote ? opts.remote.transaction() : ripple.Transaction());
tx.payment({
from: payment.source_address,
to: payment.destination_address,
amount: (payment.destination_amount.currency === 'XRP' ?
rpparser.xrpToDrops(payment.destination_amount.value) :
payment.destination_amount),
invoiceID: payment.invoice_id
});
// Tags
if (payment.source_tag) {
tx.sourceTag(payment.source_tag);
}
if (payment.destination_tag) {
tx.destinationTag(payment.destination_tag);
if (payment.destination_amount
&& payment.destination_amount.currency !== 'XRP'
&& payment.destination_amount.issuer === '') {
payment.destination_amount.issuer = payment.destination_account;
}
// Uppercase currency codes
if (payment.source_amount) {
payment.source_amount.currency =
payment.source_amount.currency.toUpperCase();
}
if (payment.destination_amount) {
payment.destination_amount.currency =
payment.destination_amount.currency.toUpperCase();
}
/* Construct payment */
var transaction = new ripple.Transaction();
var transactionData = {
from: payment.source_account,
to: payment.destination_account,
amount: utils.convertAmount(payment.destination_amount)
};
// invoice_id Because transactionData is a object, transaction.payment
// function is ignored invoiceID
if (payment.invoice_id) {
transaction.invoiceID(payment.invoice_id);
}
transaction.payment(transactionData);
// Tags
if (payment.source_tag) {
transaction.sourceTag(parseInt(payment.source_tag, 10));
}
function createOrderCancellationTransaction(account, sequence) {
validate.address(account);
validate.sequence(sequence);
var transaction = new ripple.Transaction();
transaction.offerCancel(account, parseInt(sequence, 10));
return transaction;
}
{
secret = process.argv[cursor++];
}
if (process.argv.length > cursor)
{
tx_json = JSON.parse(process.argv[cursor++]);
}
if (process.argv.length !== cursor || !secret || !tx_json)
{
usage();
}
else
{
var tx = new Transaction();
tx.tx_json = tx_json;
tx._secret = secret;
tx.complete();
var unsigned = tx.serialize().to_hex();
tx.sign();
if (verbose)
{
var sim = {};
sim.tx_blob = tx.serialize().to_hex();
sim.tx_json = tx.tx_json;
sim.tx_signing_hash = tx.signing_hash().to_hex();
sim.tx_unsigned = unsigned;
function createSettingsTransaction(account, settings) {
validate.address(account);
validate.settings(settings);
var transaction = new ripple.Transaction();
transaction.accountSet(account);
setTransactionBitFlags(transaction, {
input: settings,
flags: constants.AccountSetFlags,
clear_setting: CLEAR_SETTING
});
setTransactionIntFlags(transaction, settings, constants.AccountSetIntFlags);
setTransactionFields(transaction, settings, constants.AccountRootFields);
transaction.tx_json.TransferRate = convertTransferRate(
transaction.tx_json.TransferRate);
return transaction;
}
function createOrderTransaction(account, order) {
validate.address(account);
validate.order(order);
order = renameCounterpartyToIssuerInOrder(order);
var transaction = new ripple.Transaction();
var takerPays = order.taker_pays.currency !== 'XRP'
? order.taker_pays : utils.xrpToDrops(order.taker_pays.value);
var takerGets = order.taker_gets.currency !== 'XRP'
? order.taker_gets : utils.xrpToDrops(order.taker_gets.value);
transaction.offerCreate(account, ripple.Amount.from_json(takerPays),
ripple.Amount.from_json(takerGets));
utils.setTransactionBitFlags(transaction, {
input: order,
flags: OfferCreateFlags
});
if (order.type === 'sell') {
transaction.setFlags('Sell');
}
function createTrustLineTransaction(account, trustline) {
validate.address(account);
validate.trustline(trustline);
if (trustline && trustline.limit) {
trustline.limit = String(trustline.limit);
}
var transaction = new ripple.Transaction();
var limit = [
trustline.limit,
trustline.currency,
trustline.counterparty
].join('/');
transaction.trustSet(account, limit);
if (typeof trustline.quality_in === 'number') {
transaction.tx_json.QualityIn = trustline.quality_in;
}
if (typeof trustline.quality_out === 'number') {
transaction.tx_json.QualityOut = trustline.quality_out;
}
utils.setTransactionBitFlags(transaction, {