20 #include <ripple/app/tx/impl/SetTrust.h>
21 #include <ripple/basics/Log.h>
22 #include <ripple/ledger/View.h>
23 #include <ripple/protocol/Feature.h>
24 #include <ripple/protocol/Indexes.h>
25 #include <ripple/protocol/Quality.h>
26 #include <ripple/protocol/st.h>
43 JLOG(j.trace()) <<
"Malformed transaction: Invalid flags set.";
52 if (saLimitAmount.
native())
54 JLOG(j.trace()) <<
"Malformed transaction: specifies native limit "
61 JLOG(j.trace()) <<
"Malformed transaction: specifies XRP as IOU";
65 if (saLimitAmount < beast::zero)
67 JLOG(j.trace()) <<
"Malformed transaction: Negative credit limit.";
72 auto const& issuer = saLimitAmount.
getIssuer();
76 JLOG(j.trace()) <<
"Malformed transaction: no destination account.";
98 JLOG(ctx.
j.
trace()) <<
"Retry: Auth not required.";
104 auto const currency = saLimitAmount.getCurrency();
105 auto const uDstAccountID = saLimitAmount.getIssuer();
109 if (
id == uDstAccountID)
114 if (
id == uDstAccountID)
119 auto const sleDelete =
125 <<
"Malformed transaction: Can not extend credit to self.";
147 bool const bHigh =
account_ > uDstAccountID;
174 (uOwnerCount < 2) ?
XRPAmount(beast::zero)
175 :
view().fees().accountReserve(uOwnerCount + 1));
181 if (bQualityOut && QUALITY_ONE == uQualityOut)
186 bool const bSetAuth = (uTxFlags &
tfSetfAuth);
214 <<
"Delay transaction: Destination account does not exist.";
218 STAmount saLimitAllow = saLimitAmount;
234 auto const& uLowAccountID = !bHigh ?
account_ : uDstAccountID;
235 auto const& uHighAccountID = bHigh ?
account_ : uDstAccountID;
236 SLE::ref sleLowAccount = !bHigh ? sle : sleDst;
237 SLE::ref sleHighAccount = bHigh ? sle : sleDst;
243 saLowBalance = sleRippleState->getFieldAmount(
sfBalance);
244 saHighBalance = -saLowBalance;
250 sleRippleState->setFieldAmount(
254 !bHigh ? saLimitAllow : sleRippleState->getFieldAmount(
sfLowLimit);
256 bHigh ? saLimitAllow : sleRippleState->getFieldAmount(
sfHighLimit);
273 sleRippleState->setFieldU32(
276 uLowQualityIn = !bHigh
279 uHighQualityIn = bHigh
287 sleRippleState->makeFieldAbsent(
296 if (QUALITY_ONE == uLowQualityIn)
299 if (QUALITY_ONE == uHighQualityIn)
313 else if (uQualityOut)
317 sleRippleState->setFieldU32(
320 uLowQualityOut = !bHigh
323 uHighQualityOut = bHigh
331 sleRippleState->makeFieldAbsent(
343 if (bSetNoRipple && !bClearNoRipple)
345 if ((bHigh ? saHighBalance : saLowBalance) >= beast::zero)
352 else if (bClearNoRipple && !bSetNoRipple)
357 if (bSetFreeze && !bClearFreeze && !sle->isFlag(
lsfNoFreeze))
361 else if (bClearFreeze && !bSetFreeze)
366 if (QUALITY_ONE == uLowQualityOut)
369 if (QUALITY_ONE == uHighQualityOut)
373 bool const bHighDefRipple =
376 bool const bLowReserveSet = uLowQualityIn || uLowQualityOut ||
379 saLowBalance > beast::zero;
380 bool const bLowReserveClear = !bLowReserveSet;
382 bool const bHighReserveSet = uHighQualityIn || uHighQualityOut ||
385 saHighBalance > beast::zero;
386 bool const bHighReserveClear = !bHighReserveSet;
388 bool const bDefault = bLowReserveClear && bHighReserveClear;
393 bool bReserveIncrease =
false;
400 if (bLowReserveSet && !bLowReserved)
407 bReserveIncrease =
true;
410 if (bLowReserveClear && bLowReserved)
417 if (bHighReserveSet && !bHighReserved)
424 bReserveIncrease =
true;
427 if (bHighReserveClear && bHighReserved)
434 if (uFlagsIn != uFlagsOut)
435 sleRippleState->setFieldU32(
sfFlags, uFlagsOut);
442 view(), sleRippleState, uLowAccountID, uHighAccountID, viewJ);
448 <<
"Delay transaction: Insufficent reserve to add trust line.";
458 JLOG(
j_.
trace()) <<
"Modify ripple line";
464 (!bQualityIn || !uQualityIn) &&
466 (!bQualityOut || !uQualityOut) &&
471 <<
"Redundant: Setting non-existent ripple line to defaults.";
476 JLOG(
j_.
trace()) <<
"Delay transaction: Line does not exist. "
477 "Insufficent reserve to create line.";
490 JLOG(
j_.
trace()) <<
"doTrustSet: Creating ripple line: "
502 bSetNoRipple && !bClearNoRipple,
503 bSetFreeze && !bClearFreeze,