20 #include <ripple/rpc/impl/GRPCHelpers.h>
33 template <
class T,
class L>
43 if constexpr (std::is_integral_v<typename T::value_type>)
45 getProto()->set_value(from[field]);
50 getProto()->set_value(v.data(), v.size());
64 getProto()->set_value(
65 reinterpret_cast<const char*
>(data.data()), data.size());
79 for (
size_t i = 0; i < vec.
size(); ++i)
82 getProto()->set_value(elt.
data(), elt.
size());
96 getProto()->mutable_value()->set_address(
125 auto proto = getProto()->mutable_value();
126 proto->set_code(cur.data(), cur.size());
131 template <
class T,
class R>
135 R
const& populateProto,
144 for (
auto it = arr.begin(); it != arr.end(); ++it)
146 populateProto(*it, *getProto());
156 [&to]() {
return to.mutable_clear_flag(); }, from,
sfClearFlag);
164 [&to]() {
return to.mutable_domain(); }, from,
sfDomain);
172 [&to]() {
return to.mutable_email_hash(); }, from,
sfEmailHash);
180 [&to]() {
return to.mutable_message_key(); }, from,
sfMessageKey);
188 [&to]() {
return to.mutable_set_flag(); }, from,
sfSetFlag);
196 [&to]() {
return to.mutable_transfer_rate(); }, from,
sfTransferRate);
204 [&to]() {
return to.mutable_tick_size(); }, from,
sfTickSize);
212 [&to]() {
return to.mutable_expiration(); }, from,
sfExpiration);
220 [&to]() {
return to.mutable_offer_sequence(); }, from,
sfOfferSequence);
228 [&to]() {
return to.mutable_taker_gets(); }, from,
sfTakerGets);
236 [&to]() {
return to.mutable_taker_pays(); }, from,
sfTakerPays);
244 [&to]() {
return to.mutable_destination(); }, from,
sfDestination);
252 [&to]() {
return to.mutable_check_id(); }, from,
sfCheckID);
260 [&to]() {
return to.mutable_amount(); }, from,
sfAmount);
268 [&to]() {
return to.mutable_deliver_min(); }, from,
sfDeliverMin);
276 [&to]() {
return to.mutable_send_max(); }, from,
sfSendMax);
284 [&to]() {
return to.mutable_delivered_amount(); },
294 [&to]() {
return to.mutable_destination_tag(); },
304 [&to]() {
return to.mutable_invoice_id(); }, from,
sfInvoiceID);
312 [&to]() {
return to.mutable_authorize(); }, from,
sfAuthorize);
320 [&to]() {
return to.mutable_unauthorize(); }, from,
sfUnauthorize);
335 [&to]() {
return to.mutable_cancel_after(); }, from,
sfCancelAfter);
343 [&to]() {
return to.mutable_finish_after(); }, from,
sfFinishAfter);
351 [&to]() {
return to.mutable_condition(); }, from,
sfCondition);
359 [&to]() {
return to.mutable_fulfillment(); }, from,
sfFulfillment);
367 [&to]() {
return to.mutable_channel(); }, from,
sfChannel);
375 [&to]() {
return to.mutable_balance(); }, from,
sfBalance);
383 [&to]() {
return to.mutable_payment_channel_signature(); },
393 [&to]() {
return to.mutable_public_key(); }, from,
sfPublicKey);
401 [&to]() {
return to.mutable_settle_delay(); }, from,
sfSettleDelay);
409 [&to]() {
return to.mutable_regular_key(); }, from,
sfRegularKey);
417 [&to]() {
return to.mutable_signer_quorum(); }, from,
sfSignerQuorum);
425 [&to]() {
return to.mutable_count(); }, from,
sfTicketCount);
433 [&to]() {
return to.mutable_limit_amount(); }, from,
sfLimitAmount);
440 [&to]() {
return to.mutable_quality_in(); }, from,
sfQualityIn);
448 [&to]() {
return to.mutable_quality_out(); }, from,
sfQualityOut);
456 [&to]() {
return to.mutable_account(); }, from,
sfAccount);
474 [&to]() {
return to.mutable_signing_public_key(); },
484 [&to]() {
return to.mutable_transaction_signature(); },
494 [&to]() {
return to.mutable_flags(); }, from,
sfFlags);
502 [&to]() {
return to.mutable_ledger_sequence(); },
512 [&to]() {
return to.mutable_validator_to_disable(); },
522 [&to]() {
return to.mutable_validator_to_re_enable(); },
532 [&to]() {
return to.mutable_last_ledger_sequence(); },
542 [&to]() {
return to.mutable_source_tag(); }, from,
sfSourceTag);
550 [&to]() {
return to.mutable_account_transaction_id(); },
560 [&to]() {
return to.mutable_memo_data(); }, from,
sfMemoData);
568 [&to]() {
return to.mutable_memo_format(); }, from,
sfMemoFormat);
576 [&to]() {
return to.mutable_memo_type(); }, from,
sfMemoType);
584 [&to]() {
return to.mutable_sequence(); }, from,
sfSequence);
592 [&to]() {
return to.mutable_amendment(); }, from,
sfAmendment);
600 [&to]() {
return to.mutable_close_time(); }, from,
sfCloseTime);
608 [&to]() {
return to.mutable_signer_weight(); }, from,
sfSignerWeight);
616 [&to]() {
return to.add_amendments(); }, from,
sfAmendments);
624 [&to]() {
return to.mutable_owner_count(); }, from,
sfOwnerCount);
632 [&to]() {
return to.mutable_previous_transaction_id(); },
642 [&to]() {
return to.mutable_previous_transaction_ledger_sequence(); },
652 [&to]() {
return to.mutable_low_limit(); }, from,
sfLowLimit);
660 [&to]() {
return to.mutable_high_limit(); }, from,
sfHighLimit);
668 [&to]() {
return to.mutable_low_node(); }, from,
sfLowNode);
676 [&to]() {
return to.mutable_high_node(); }, from,
sfHighNode);
684 [&to]() {
return to.mutable_low_quality_in(); }, from,
sfLowQualityIn);
692 [&to]() {
return to.mutable_low_quality_out(); },
702 [&to]() {
return to.mutable_high_quality_in(); },
712 [&to]() {
return to.mutable_high_quality_out(); },
722 [&to]() {
return to.mutable_book_directory(); }, from,
sfBookDirectory);
730 [&to]() {
return to.mutable_book_node(); }, from,
sfBookNode);
738 [&to]() {
return to.mutable_owner_node(); }, from,
sfOwnerNode);
746 [&to]() {
return to.mutable_signer_list_id(); }, from,
sfSignerListID);
754 [&to]() {
return to.mutable_ticket_sequence(); },
778 [&to]() {
return to.mutable_root_index(); }, from,
sfRootIndex);
786 [&to]() {
return to.mutable_index_next(); }, from,
sfIndexNext);
794 [&to]() {
return to.mutable_index_previous(); }, from,
sfIndexPrevious);
802 [&to]() {
return to.mutable_taker_pays_currency(); },
812 [&to]() {
return to.mutable_taker_pays_issuer(); },
822 [&to]() {
return to.mutable_taker_gets_currency(); },
832 [&to]() {
return to.mutable_taker_gets_issuer(); },
842 [&to]() {
return to.mutable_destination_node(); },
852 [&to]() {
return to.mutable_base_fee(); }, from,
sfBaseFee);
860 [&to]() {
return to.mutable_reference_fee_units(); },
870 [&to]() {
return to.mutable_reserve_base(); }, from,
sfReserveBase);
878 [&to]() {
return to.mutable_reserve_increment(); },
888 [&to]() {
return to.add_signer_entries(); },
889 [](
auto& innerObj,
auto& innerProto) {
903 [&to]() {
return to.add_disabled_validators(); },
904 [](
auto& innerObj,
auto& innerProto) {
918 [&to]() {
return to.add_memos(); },
919 [](
auto& innerObj,
auto& innerProto) {
934 [&to]() {
return to.add_signers(); },
935 [](
auto& innerObj,
auto& innerProto) {
950 [&to]() {
return to.add_majorities(); },
951 [](
auto innerObj,
auto innerProto) {
966 org::xrpl::rpc::v1::TransactionResult::RESULT_TYPE_TEC);
971 org::xrpl::rpc::v1::TransactionResult::RESULT_TYPE_TEF);
976 org::xrpl::rpc::v1::TransactionResult::RESULT_TYPE_TEL);
981 org::xrpl::rpc::v1::TransactionResult::RESULT_TYPE_TEM);
986 org::xrpl::rpc::v1::TransactionResult::RESULT_TYPE_TER);
991 org::xrpl::rpc::v1::TransactionResult::RESULT_TYPE_TES);
1200 for (
auto it = pathset.
begin(); it < pathset.
end(); ++it)
1202 STPath const& path = *it;
1204 org::xrpl::rpc::v1::Payment_Path* protoPath = to.add_paths();
1206 for (
auto it2 = path.begin(); it2 != path.end(); ++it2)
1208 org::xrpl::rpc::v1::Payment_PathElement* protoElement =
1209 protoPath->add_elements();
1217 protoElement->mutable_currency()->set_name(
1223 protoElement->mutable_issuer()->set_address(
1230 protoElement->mutable_account()->set_address(
1522 org::xrpl::rpc::v1::AffectedNode& proto,
1528 proto.set_ledger_entry_type(
1529 org::xrpl::rpc::v1::LEDGER_ENTRY_TYPE_ACCOUNT_ROOT);
1532 proto.set_ledger_entry_type(
1533 org::xrpl::rpc::v1::LEDGER_ENTRY_TYPE_DIRECTORY_NODE);
1536 proto.set_ledger_entry_type(
1537 org::xrpl::rpc::v1::LEDGER_ENTRY_TYPE_RIPPLE_STATE);
1540 proto.set_ledger_entry_type(
1541 org::xrpl::rpc::v1::LEDGER_ENTRY_TYPE_SIGNER_LIST);
1544 proto.set_ledger_entry_type(
1545 org::xrpl::rpc::v1::LEDGER_ENTRY_TYPE_OFFER);
1548 proto.set_ledger_entry_type(
1549 org::xrpl::rpc::v1::LEDGER_ENTRY_TYPE_LEDGER_HASHES);
1552 proto.set_ledger_entry_type(
1553 org::xrpl::rpc::v1::LEDGER_ENTRY_TYPE_AMENDMENTS);
1556 proto.set_ledger_entry_type(
1557 org::xrpl::rpc::v1::LEDGER_ENTRY_TYPE_FEE_SETTINGS);
1560 proto.set_ledger_entry_type(
1561 org::xrpl::rpc::v1::LEDGER_ENTRY_TYPE_ESCROW);
1564 proto.set_ledger_entry_type(
1565 org::xrpl::rpc::v1::LEDGER_ENTRY_TYPE_PAY_CHANNEL);
1568 proto.set_ledger_entry_type(
1569 org::xrpl::rpc::v1::LEDGER_ENTRY_TYPE_CHECK);
1572 proto.set_ledger_entry_type(
1573 org::xrpl::rpc::v1::LEDGER_ENTRY_TYPE_DEPOSIT_PREAUTH);
1576 proto.set_ledger_entry_type(
1577 org::xrpl::rpc::v1::LEDGER_ENTRY_TYPE_NEGATIVE_UNL);
1580 proto.set_ledger_entry_type(
1581 org::xrpl::rpc::v1::LEDGER_ENTRY_TYPE_TICKET);
1650 convert(*getProto(), data, lgrType);
1678 to.set_transaction_index(from->getIndex());
1680 convert(*to.mutable_transaction_result(), from->getResultTER());
1681 to.mutable_transaction_result()->set_result(
1684 if (from->hasDeliveredAmount())
1685 convert(*to.mutable_delivered_amount(), from->getDeliveredAmount());
1687 STArray& nodes = from->getNodes();
1688 for (
auto it = nodes.
begin(); it != nodes.
end(); ++it)
1691 org::xrpl::rpc::v1::AffectedNode* node = to.add_affected_nodes();
1695 node->set_ledger_index(ledgerIndex.
data(), ledgerIndex.
size());
1706 return node->mutable_modified_node()
1707 ->mutable_final_fields();
1714 return node->mutable_modified_node()
1715 ->mutable_previous_fields();
1723 *node->mutable_modified_node(), obj);
1730 return node->mutable_created_node()->mutable_new_fields();
1740 return node->mutable_deleted_node()->mutable_final_fields();
1750 org::xrpl::rpc::v1::QueueData& to,
1755 to.set_txn_count(from.
size());
1763 bool anyAuthChanged =
false;
1766 for (
auto const& tx : from)
1768 org::xrpl::rpc::v1::QueuedTransaction& qt = *to.add_transactions();
1770 if (tx.seqProxy.isSeq())
1772 qt.mutable_sequence()->set_value(tx.seqProxy.value());
1775 lowestSeq = tx.seqProxy.
value();
1776 highestSeq = tx.seqProxy.
value();
1780 qt.mutable_ticket()->set_value(tx.seqProxy.value());
1783 lowestTicket = tx.seqProxy.
value();
1784 highestTicket = tx.seqProxy.
value();
1787 qt.set_fee_level(tx.feeLevel.fee());
1789 qt.mutable_last_ledger_sequence()->set_value(*tx.lastValid);
1791 qt.mutable_fee()->set_drops(tx.consequences.fee().drops());
1793 tx.consequences.potentialSpend() + tx.consequences.fee();
1794 qt.mutable_max_spend_drops()->set_drops(spend.drops());
1795 totalSpend += spend;
1796 bool const authChanged = tx.consequences.isBlocker();
1798 anyAuthChanged =
true;
1799 qt.set_auth_change(authChanged);
1803 to.set_sequence_count(seqCount);
1805 to.set_ticket_count(ticketCount);
1807 to.set_lowest_sequence(*lowestSeq);
1809 to.set_highest_sequence(*highestSeq);
1811 to.set_lowest_ticket(*lowestTicket);
1813 to.set_highest_ticket(*highestTicket);
1815 to.set_auth_change_queued(anyAuthChanged);
1816 to.mutable_max_spend_drops_total()->set_drops(totalSpend.
drops());
1822 org::xrpl::rpc::v1::Transaction& to,
1855 case TxType::ttPAYMENT:
1856 convert(*to.mutable_payment(), fromObj);
1858 case TxType::ttESCROW_CREATE:
1859 convert(*to.mutable_escrow_create(), fromObj);
1861 case TxType::ttESCROW_FINISH:
1862 convert(*to.mutable_escrow_finish(), fromObj);
1864 case TxType::ttACCOUNT_SET:
1865 convert(*to.mutable_account_set(), fromObj);
1867 case TxType::ttESCROW_CANCEL:
1868 convert(*to.mutable_escrow_cancel(), fromObj);
1870 case TxType::ttREGULAR_KEY_SET:
1871 convert(*to.mutable_set_regular_key(), fromObj);
1873 case TxType::ttOFFER_CREATE:
1874 convert(*to.mutable_offer_create(), fromObj);
1876 case TxType::ttOFFER_CANCEL:
1877 convert(*to.mutable_offer_cancel(), fromObj);
1879 case TxType::ttSIGNER_LIST_SET:
1880 convert(*to.mutable_signer_list_set(), fromObj);
1882 case TxType::ttPAYCHAN_CREATE:
1883 convert(*to.mutable_payment_channel_create(), fromObj);
1885 case TxType::ttPAYCHAN_FUND:
1886 convert(*to.mutable_payment_channel_fund(), fromObj);
1888 case TxType::ttPAYCHAN_CLAIM:
1889 convert(*to.mutable_payment_channel_claim(), fromObj);
1891 case TxType::ttCHECK_CREATE:
1892 convert(*to.mutable_check_create(), fromObj);
1894 case TxType::ttCHECK_CASH:
1895 convert(*to.mutable_check_cash(), fromObj);
1897 case TxType::ttCHECK_CANCEL:
1898 convert(*to.mutable_check_cancel(), fromObj);
1900 case TxType::ttDEPOSIT_PREAUTH:
1901 convert(*to.mutable_deposit_preauth(), fromObj);
1903 case TxType::ttTRUST_SET:
1904 convert(*to.mutable_trust_set(), fromObj);
1906 case TxType::ttACCOUNT_DELETE:
1907 convert(*to.mutable_account_delete(), fromObj);
1909 case TxType::ttTICKET_CREATE:
1910 convert(*to.mutable_ticket_create(), fromObj);