mirror of
https://github.com/Xahau/xahau.js.git
synced 2025-12-06 17:27:59 +00:00
Merge pull request #471 from clark800/no-xrp-paths
Don't set paths for XRP to XRP payment
This commit is contained in:
@@ -7,15 +7,10 @@ const validate = utils.common.validate;
|
|||||||
const toRippledAmount = utils.common.toRippledAmount;
|
const toRippledAmount = utils.common.toRippledAmount;
|
||||||
const Transaction = utils.common.core.Transaction;
|
const Transaction = utils.common.core.Transaction;
|
||||||
|
|
||||||
function isSendMaxAllowed(payment) {
|
function isXRPToXRPPayment(payment) {
|
||||||
const srcAmt = payment.source.amount;
|
const sourceCurrency = _.get(payment, 'source.amount.currency');
|
||||||
const dstAmt = payment.destination.amount;
|
const destinationCurrency = _.get(payment, 'destination.amount.currency');
|
||||||
|
return sourceCurrency === 'XRP' && destinationCurrency === 'XRP';
|
||||||
// Don't set SendMax for XRP->XRP payment
|
|
||||||
// temREDUNDANT_SEND_MAX removed in:
|
|
||||||
// https://github.com/ripple/rippled/commit/
|
|
||||||
// c522ffa6db2648f1d8a987843e7feabf1a0b7de8/
|
|
||||||
return srcAmt && !(srcAmt.currency === 'XRP' && dstAmt.currency === 'XRP');
|
|
||||||
}
|
}
|
||||||
|
|
||||||
function isIOUWithoutCounterparty(amount) {
|
function isIOUWithoutCounterparty(amount) {
|
||||||
@@ -58,9 +53,6 @@ function createPaymentTransaction(account, payment) {
|
|||||||
if (payment.destination.tag) {
|
if (payment.destination.tag) {
|
||||||
transaction.destinationTag(payment.destination.tag);
|
transaction.destinationTag(payment.destination.tag);
|
||||||
}
|
}
|
||||||
if (payment.paths) {
|
|
||||||
transaction.paths(JSON.parse(payment.paths));
|
|
||||||
}
|
|
||||||
if (payment.memos) {
|
if (payment.memos) {
|
||||||
_.forEach(payment.memos, memo =>
|
_.forEach(payment.memos, memo =>
|
||||||
transaction.addMemo(memo.type, memo.format, memo.data)
|
transaction.addMemo(memo.type, memo.format, memo.data)
|
||||||
@@ -75,11 +67,19 @@ function createPaymentTransaction(account, payment) {
|
|||||||
if (payment.limitQuality) {
|
if (payment.limitQuality) {
|
||||||
transaction.setFlags(['LimitQuality']);
|
transaction.setFlags(['LimitQuality']);
|
||||||
}
|
}
|
||||||
if (isSendMaxAllowed(payment)) {
|
if (!isXRPToXRPPayment(payment)) {
|
||||||
|
// Don't set SendMax for XRP->XRP payment
|
||||||
|
// temREDUNDANT_SEND_MAX removed in:
|
||||||
|
// https://github.com/ripple/rippled/commit/
|
||||||
|
// c522ffa6db2648f1d8a987843e7feabf1a0b7de8/
|
||||||
const maxValue = new BigNumber(payment.source.amount.value)
|
const maxValue = new BigNumber(payment.source.amount.value)
|
||||||
.plus(payment.source.slippage || 0).toString();
|
.plus(payment.source.slippage || 0).toString();
|
||||||
const maxAmount = _.assign({}, payment.source.amount, {value: maxValue});
|
const maxAmount = _.assign({}, payment.source.amount, {value: maxValue});
|
||||||
transaction.sendMax(toRippledAmount(maxAmount));
|
transaction.sendMax(toRippledAmount(maxAmount));
|
||||||
|
|
||||||
|
if (payment.paths) {
|
||||||
|
transaction.paths(JSON.parse(payment.paths));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return transaction;
|
return transaction;
|
||||||
|
|||||||
@@ -7,27 +7,6 @@
|
|||||||
"InvoiceID": "A98FD36C17BE2B8511AD36DC335478E7E89F06262949F36EB88E2D683BBCC50A",
|
"InvoiceID": "A98FD36C17BE2B8511AD36DC335478E7E89F06262949F36EB88E2D683BBCC50A",
|
||||||
"SourceTag": 14,
|
"SourceTag": 14,
|
||||||
"DestinationTag": 58,
|
"DestinationTag": 58,
|
||||||
"Paths": [
|
|
||||||
[
|
|
||||||
{
|
|
||||||
"account": "rMwjYedjc7qqtKYVLiAccJSmCwih4LnE2q",
|
|
||||||
"issuer": "rMwjYedjc7qqtKYVLiAccJSmCwih4LnE2q",
|
|
||||||
"currency": "USD",
|
|
||||||
"type_hex": "0000000000000031"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"issuer": "rfYv1TXnwgDDK4WQNbFALykYuEBnrR4pDX",
|
|
||||||
"currency": "LTC",
|
|
||||||
"type_hex": "0000000000000030"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"account": "rfYv1TXnwgDDK4WQNbFALykYuEBnrR4pDX",
|
|
||||||
"issuer": "rfYv1TXnwgDDK4WQNbFALykYuEBnrR4pDX",
|
|
||||||
"currency": "LTC",
|
|
||||||
"type_hex": "0000000000000031"
|
|
||||||
}
|
|
||||||
]
|
|
||||||
],
|
|
||||||
"Memos": [
|
"Memos": [
|
||||||
{
|
{
|
||||||
"Memo": {
|
"Memo": {
|
||||||
@@ -40,4 +19,4 @@
|
|||||||
"LastLedgerSequence": 8820051,
|
"LastLedgerSequence": 8820051,
|
||||||
"Fee": "12",
|
"Fee": "12",
|
||||||
"Sequence": 23
|
"Sequence": 23
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user