Handler account_currencies (#524)

Fixes #525
This commit is contained in:
cyan317
2023-02-27 09:17:51 +00:00
committed by GitHub
parent 7d4e5ff0bd
commit a3211f4458
10 changed files with 592 additions and 19 deletions

View File

@@ -153,6 +153,12 @@ CreateCreateOfferTransactionObject(
ripple::Issue
GetIssue(std::string_view currency, std::string_view issuerId)
{
// standard currency
if (currency.size() == 3)
return ripple::Issue(
ripple::to_currency(std::string(currency)),
ripple::parseBase58<ripple::AccountID>(std::string(issuerId))
.value());
return ripple::Issue(
ripple::Currency{currency},
ripple::parseBase58<ripple::AccountID>(std::string(issuerId)).value());
@@ -285,3 +291,33 @@ CreatePaymentChannelLedgerObject(
channel.setFieldVL(ripple::sfPublicKey, slice);
return channel;
}
[[nodiscard]] ripple::STObject
CreateRippleStateLedgerObject(
std::string_view accountId,
std::string_view currency,
std::string_view issuerId,
int balance,
std::string_view lowNodeAccountId,
int lowLimit,
std::string_view highNodeAccountId,
int highLimit,
std::string_view previousTxnId,
uint32_t previousTxnSeq)
{
auto line = ripple::STObject(ripple::sfLedgerEntry);
line.setFieldU16(ripple::sfLedgerEntryType, ripple::ltRIPPLE_STATE);
line.setFieldU32(ripple::sfFlags, 0);
line.setFieldAmount(
ripple::sfBalance,
ripple::STAmount(GetIssue(currency, issuerId), balance));
line.setFieldAmount(
ripple::sfHighLimit,
ripple::STAmount(GetIssue(currency, highNodeAccountId), highLimit));
line.setFieldAmount(
ripple::sfLowLimit,
ripple::STAmount(GetIssue(currency, lowNodeAccountId), lowLimit));
line.setFieldH256(ripple::sfPreviousTxnID, ripple::uint256{previousTxnId});
line.setFieldU32(ripple::sfPreviousTxnLgrSeq, previousTxnSeq);
return line;
}