mirror of
https://github.com/XRPLF/xrpl-dev-portal.git
synced 2025-11-21 12:15:50 +00:00
Re-added code to clean branch
This commit is contained in:
@@ -0,0 +1,28 @@
|
||||
const xrpl = require("xrpl");
|
||||
|
||||
/**
|
||||
* Prepares, signs and submits a payment transaction
|
||||
*
|
||||
* @param paymentData
|
||||
* @param client
|
||||
* @param wallet
|
||||
* @returns {Promise<*>}
|
||||
*/
|
||||
const sendXrp = async (paymentData, client, wallet) => {
|
||||
// Reference: https://xrpl.org/submit.html#request-format-1
|
||||
const paymentTx = {
|
||||
"TransactionType": "Payment",
|
||||
"Account": wallet.address,
|
||||
"Amount": xrpl.xrpToDrops(paymentData.amount),
|
||||
"Destination": paymentData.destinationAddress,
|
||||
"DestinationTag": parseInt(paymentData.destinationTag)
|
||||
}
|
||||
|
||||
const preparedTx = await client.autofill(paymentTx)
|
||||
|
||||
const signedTx = wallet.sign(preparedTx)
|
||||
|
||||
return await client.submitAndWait(signedTx.tx_blob)
|
||||
}
|
||||
|
||||
module.exports = { sendXrp }
|
||||
Reference in New Issue
Block a user