mirror of
https://github.com/XRPLF/rippled.git
synced 2025-11-27 06:25:51 +00:00
Make tecUNFUNDED more specific and fix WalletAdd.
This commit is contained in:
@@ -340,7 +340,7 @@ TER OfferCreateTransactor::doApply()
|
|||||||
{
|
{
|
||||||
cLog(lsWARNING) << "OfferCreate: delay: Offers must be at least partially funded.";
|
cLog(lsWARNING) << "OfferCreate: delay: Offers must be at least partially funded.";
|
||||||
|
|
||||||
terResult = tecUNFUNDED;
|
terResult = tecUNFUNDED_OFFER;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (tesSUCCESS == terResult && !saTakerPays.isNative())
|
if (tesSUCCESS == terResult && !saTakerPays.isNative())
|
||||||
|
|||||||
@@ -161,7 +161,7 @@ TER PaymentTransactor::doApply()
|
|||||||
cLog(lsINFO) << boost::str(boost::format("Payment: Delay transaction: Insufficient funds: %s / %s (%d)")
|
cLog(lsINFO) << boost::str(boost::format("Payment: Delay transaction: Insufficient funds: %s / %s (%d)")
|
||||||
% saSrcXRPBalance.getText() % (saDstAmount + uReserve).getText() % uReserve);
|
% saSrcXRPBalance.getText() % (saDstAmount + uReserve).getText() % uReserve);
|
||||||
|
|
||||||
terResult = tecUNFUNDED;
|
terResult = tecUNFUNDED_PAYMENT;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -19,7 +19,10 @@ bool transResultInfo(TER terCode, std::string& strToken, std::string& strHuman)
|
|||||||
{ tecPATH_DRY, "tecPATH_DRY", "Path could not send partial amount." },
|
{ tecPATH_DRY, "tecPATH_DRY", "Path could not send partial amount." },
|
||||||
{ tecPATH_PARTIAL, "tecPATH_PARTIAL", "Path could not send full amount." },
|
{ tecPATH_PARTIAL, "tecPATH_PARTIAL", "Path could not send full amount." },
|
||||||
|
|
||||||
{ tecUNFUNDED, "tecUNFUNDED", "Source account had insufficient balance for transaction." },
|
{ tecUNFUNDED, "tecUNFUNDED", "One of _ADD, _OFFER, or _SEND. Deprecated." },
|
||||||
|
{ tecUNFUNDED_ADD, "tecUNFUNDED_ADD", "Insufficient XRP balance for WalletAdd." },
|
||||||
|
{ tecUNFUNDED_OFFER, "tecUNFUNDED_OFFER", "Insufficient balance to fund created offer." },
|
||||||
|
{ tecUNFUNDED_PAYMENT, "tecUNFUNDED_PAYMENT", "Insufficient XRP balance to send." },
|
||||||
|
|
||||||
{ tefFAILURE, "tefFAILURE", "Failed to apply." },
|
{ tefFAILURE, "tefFAILURE", "Failed to apply." },
|
||||||
{ tefALREADY, "tefALREADY", "The exact transaction was already in this ledger." },
|
{ tefALREADY, "tefALREADY", "The exact transaction was already in this ledger." },
|
||||||
|
|||||||
@@ -111,6 +111,9 @@ enum TER // aka TransactionEngineResult
|
|||||||
// DO NOT CHANGE THESE NUMBERS: They appear in ledger meta data.
|
// DO NOT CHANGE THESE NUMBERS: They appear in ledger meta data.
|
||||||
tecCLAIM = 100,
|
tecCLAIM = 100,
|
||||||
tecPATH_PARTIAL = 101,
|
tecPATH_PARTIAL = 101,
|
||||||
|
tecUNFUNDED_ADD = 102,
|
||||||
|
tecUNFUNDED_OFFER = 103,
|
||||||
|
tecUNFUNDED_PAYMENT = 104,
|
||||||
tecDIR_FULL = 121,
|
tecDIR_FULL = 121,
|
||||||
tecINSUF_RESERVE_LINE = 122,
|
tecINSUF_RESERVE_LINE = 122,
|
||||||
tecINSUF_RESERVE_OFFER = 123,
|
tecINSUF_RESERVE_OFFER = 123,
|
||||||
@@ -119,7 +122,7 @@ enum TER // aka TransactionEngineResult
|
|||||||
tecNO_LINE_INSUF_RESERVE = 126,
|
tecNO_LINE_INSUF_RESERVE = 126,
|
||||||
tecNO_LINE_REDUNDANT = 127,
|
tecNO_LINE_REDUNDANT = 127,
|
||||||
tecPATH_DRY = 128,
|
tecPATH_DRY = 128,
|
||||||
tecUNFUNDED = 129,
|
tecUNFUNDED = 129, // Old ambigous unfunded.
|
||||||
};
|
};
|
||||||
|
|
||||||
#define isTelLocal(x) ((x) >= telLOCAL_ERROR && (x) < temMALFORMED)
|
#define isTelLocal(x) ((x) >= telLOCAL_ERROR && (x) < temMALFORMED)
|
||||||
|
|||||||
@@ -38,29 +38,33 @@ TER WalletAddTransactor::doApply()
|
|||||||
return tefCREATED;
|
return tefCREATED;
|
||||||
}
|
}
|
||||||
|
|
||||||
STAmount saAmount = mTxn.getFieldAmount(sfAmount);
|
// Direct XRP payment.
|
||||||
STAmount saSrcBalance = mTxnAccount->getFieldAmount(sfBalance);
|
|
||||||
|
|
||||||
if (saSrcBalance < saAmount)
|
STAmount saDstAmount = mTxn.getFieldAmount(sfAmount);
|
||||||
|
const STAmount saSrcBalance = mTxnAccount->getFieldAmount(sfBalance);
|
||||||
|
const uint32 uOwnerCount = mTxnAccount->getFieldU32(sfOwnerCount);
|
||||||
|
const uint64 uReserve = mEngine->getLedger()->getReserve(uOwnerCount);
|
||||||
|
STAmount saPaid = mTxn.getTransactionFee();
|
||||||
|
|
||||||
|
// Make sure have enough reserve to send. Allow final spend to use reserve for fee.
|
||||||
|
if (saSrcBalance + saPaid < saDstAmount + uReserve) // Reserve is not scaled by fee.
|
||||||
{
|
{
|
||||||
std::cerr
|
// Vote no. However, transaction might succeed, if applied in a different order.
|
||||||
<< boost::str(boost::format("WalletAdd: Delay transaction: insufficient balance: balance=%s amount=%s")
|
cLog(lsINFO) << boost::str(boost::format("WalletAdd: Delay transaction: Insufficient funds: %s / %s (%d)")
|
||||||
% saSrcBalance.getText()
|
% saSrcBalance.getText() % (saDstAmount + uReserve).getText() % uReserve);
|
||||||
% saAmount.getText())
|
|
||||||
<< std::endl;
|
|
||||||
|
|
||||||
return tecUNFUNDED;
|
return tecUNFUNDED_ADD;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Deduct initial balance from source account.
|
// Deduct initial balance from source account.
|
||||||
mTxnAccount->setFieldAmount(sfBalance, saSrcBalance-saAmount);
|
mTxnAccount->setFieldAmount(sfBalance, saSrcBalance-saDstAmount);
|
||||||
|
|
||||||
// Create the account.
|
// Create the account.
|
||||||
sleDst = mEngine->entryCreate(ltACCOUNT_ROOT, Ledger::getAccountRootIndex(uDstAccountID));
|
sleDst = mEngine->entryCreate(ltACCOUNT_ROOT, Ledger::getAccountRootIndex(uDstAccountID));
|
||||||
|
|
||||||
sleDst->setFieldAccount(sfAccount, uDstAccountID);
|
sleDst->setFieldAccount(sfAccount, uDstAccountID);
|
||||||
sleDst->setFieldU32(sfSequence, 1);
|
sleDst->setFieldU32(sfSequence, 1);
|
||||||
sleDst->setFieldAmount(sfBalance, saAmount);
|
sleDst->setFieldAmount(sfBalance, saDstAmount);
|
||||||
sleDst->setFieldAccount(sfRegularKey, uAuthKeyID);
|
sleDst->setFieldAccount(sfRegularKey, uAuthKeyID);
|
||||||
|
|
||||||
std::cerr << "WalletAdd<" << std::endl;
|
std::cerr << "WalletAdd<" << std::endl;
|
||||||
|
|||||||
@@ -517,7 +517,7 @@ buster.testCase("Offer tests", {
|
|||||||
.offer_create("bob", "50/USD/alice", "200/EUR/carol")
|
.offer_create("bob", "50/USD/alice", "200/EUR/carol")
|
||||||
.on('proposed', function (m) {
|
.on('proposed', function (m) {
|
||||||
// console.log("PROPOSED: offer_create: %s", JSON.stringify(m));
|
// console.log("PROPOSED: offer_create: %s", JSON.stringify(m));
|
||||||
callback(m.result !== 'tecUNFUNDED');
|
callback(m.result !== 'tecUNFUNDED_OFFER');
|
||||||
|
|
||||||
seq = m.tx_json.Sequence;
|
seq = m.tx_json.Sequence;
|
||||||
})
|
})
|
||||||
|
|||||||
@@ -481,7 +481,7 @@ buster.testCase("Reserve", {
|
|||||||
.offer_create("bob", "50/USD/alice", "200/EUR/carol")
|
.offer_create("bob", "50/USD/alice", "200/EUR/carol")
|
||||||
.on('proposed', function (m) {
|
.on('proposed', function (m) {
|
||||||
// console.log("PROPOSED: offer_create: %s", JSON.stringify(m));
|
// console.log("PROPOSED: offer_create: %s", JSON.stringify(m));
|
||||||
callback(m.result !== 'tecUNFUNDED');
|
callback(m.result !== 'tecUNFUNDED_OFFER');
|
||||||
|
|
||||||
seq = m.tx_json.Sequence;
|
seq = m.tx_json.Sequence;
|
||||||
})
|
})
|
||||||
|
|||||||
Reference in New Issue
Block a user