From 8bb162ce52bb46e2b855e0e7079fa49c65a433d0 Mon Sep 17 00:00:00 2001 From: Ed Hennis Date: Sat, 22 Nov 2025 19:36:50 -0500 Subject: [PATCH] Review feedback from @gregtatcam - Rewrite "Asset::native()" and "integral()" to use std::visit. - Improve documentation for the LoanPay transaction flags: tfLoanFullPayment, tfLoanLatePayment --- include/xrpl/protocol/Asset.h | 18 ++++++++++++++++-- include/xrpl/protocol/TxFlags.h | 8 +++++++- .../xrpl/protocol/detail/ledger_entries.macro | 2 +- 3 files changed, 24 insertions(+), 4 deletions(-) diff --git a/include/xrpl/protocol/Asset.h b/include/xrpl/protocol/Asset.h index 6765f7cf7d..7ad1e70256 100644 --- a/include/xrpl/protocol/Asset.h +++ b/include/xrpl/protocol/Asset.h @@ -81,13 +81,27 @@ public: bool native() const { - return holds() && get().native(); + return std::visit( + [&](TIss const& issue) { + if constexpr (std::is_same_v) + return issue.native(); + if constexpr (std::is_same_v) + return false; + }, + issue_); } bool integral() const { - return !holds() || get().native(); + return std::visit( + [&](TIss const& issue) { + if constexpr (std::is_same_v) + return issue.native(); + if constexpr (std::is_same_v) + return true; + }, + issue_); } friend constexpr bool diff --git a/include/xrpl/protocol/TxFlags.h b/include/xrpl/protocol/TxFlags.h index 0f3ea94b21..d4faed192c 100644 --- a/include/xrpl/protocol/TxFlags.h +++ b/include/xrpl/protocol/TxFlags.h @@ -272,8 +272,14 @@ constexpr std::uint32_t const tfBatchMask = // as an overpayment. False, no overpayments will be taken. constexpr std::uint32_t const tfLoanOverpayment = 0x00010000; // LoanPay exclusive flags: -// tfLoanFullPayment: True, indicates that the payment is +// tfLoanFullPayment: True, indicates that the payment is an early +// full payment. It must pay the entire loan including close +// interest and fees, or it will fail. False: Not a full payment. constexpr std::uint32_t const tfLoanFullPayment = 0x00020000; +// tfLoanLatePayment: True, indicates that the payment is late, +// and includes late iterest and fees. If the loan is not late, +// it will fail. False: not a late payment. If the current payment +// is overdue, the transaction will fail. constexpr std::uint32_t const tfLoanLatePayment = 0x00040000; constexpr std::uint32_t const tfLoanSetMask = ~(tfUniversal | tfLoanOverpayment); diff --git a/include/xrpl/protocol/detail/ledger_entries.macro b/include/xrpl/protocol/detail/ledger_entries.macro index 5f6d1b844e..1034c35895 100644 --- a/include/xrpl/protocol/detail/ledger_entries.macro +++ b/include/xrpl/protocol/detail/ledger_entries.macro @@ -572,7 +572,7 @@ LEDGER_ENTRY(ltLOAN, 0x0089, Loan, loan, ({ // // - InterestOwedToVault = InterestOutstanding - ManagementFeeOutstanding // The amount of the total interest that is owed to the vault, and - // will be sent to as part of a payment. + // will be sent to it as part of a payment. // // - TrueTotalLoanValue = PaymentRemaining * PeriodicPayment // The unrounded true total value of the loan.