/// <summary> /// The ripple_path_find method is a simplified version of the path_find method that provides a single response with a payment path you can use right away. /// It is available in both the WebSocket and JSON-RPC APIs. However, the results tend to become outdated as time passes. /// Instead of making multiple calls to stay updated, you should instead use the path_find method to subscribe to continued updates where possible. /// </summary> public async Task <RipplePathFindResponse> RipplePathFind(RipplePathFindRequest request, CancellationToken cancellationToken = default) { jsonBuffer.Clear(); jsonWriter.Reset(); jsonWriter.WriteStartObject(); var requestId = WriteHeader(jsonWriter, "ripple_path_find"); LedgerSpecification.Write(jsonWriter, request.Ledger); jsonWriter.WriteString("source_account", request.SourceAccount.ToString()); jsonWriter.WriteString("destination_account", request.DestinationAccount.ToString()); jsonWriter.WritePropertyName("destination_amount"); request.DestinationAmount.WriteJson(jsonWriter); if (request.SendMax.HasValue) { jsonWriter.WritePropertyName("send_max"); request.SendMax.Value.WriteJson(jsonWriter); } if (request.SourceCurrencies != null) { jsonWriter.WriteStartArray("source_currencies"); foreach (var entry in request.SourceCurrencies) { entry.WriteJson(jsonWriter); } jsonWriter.WriteEndArray(); } WriteFooter(jsonWriter); jsonWriter.WriteEndObject(); jsonWriter.Flush(); var response = await SendReceiveAsync(requestId, jsonBuffer.WrittenMemory, cancellationToken); return(new RipplePathFindResponse(response)); }
/// <summary> /// The account_channels method returns information about an account's Payment Channels. /// This includes only channels where the specified account is the channel's source, not the destination. /// (A channel's "source" and "owner" are the same.) /// All information retrieved is relative to a particular version of the ledger. /// </summary> public async Task <AccountChannelsResponse> AccountChannels(AccountChannelsRequest request, CancellationToken cancellationToken = default) { jsonBuffer.Clear(); jsonWriter.Reset(); jsonWriter.WriteStartObject(); var requestId = WriteHeader(jsonWriter, "account_channels"); LedgerSpecification.Write(jsonWriter, request.Ledger); jsonWriter.WriteString("account", request.Account.ToString()); if (request.DestinationAccount.HasValue) { jsonWriter.WriteString("destination_account", request.DestinationAccount.Value.ToString()); } if (request.Limit.HasValue) { jsonWriter.WriteNumber("limit", request.Limit.Value); } if (request.Marker.HasValue) { jsonWriter.WritePropertyName("marker"); request.Marker.Value.WriteTo(jsonWriter); } WriteFooter(jsonWriter); jsonWriter.WriteEndObject(); jsonWriter.Flush(); var response = await SendReceiveAsync(requestId, jsonBuffer.WrittenMemory, cancellationToken); return(new AccountChannelsResponse(response, request, this)); }
/// <summary> /// The book_offers method retrieves a list of offers, also known as the order book, between two currencies. /// </summary> public async Task <BookOffersResponse> BookOffers(BookOffersRequest request, CancellationToken cancellationToken = default) { jsonBuffer.Clear(); jsonWriter.Reset(); jsonWriter.WriteStartObject(); var requestId = WriteHeader(jsonWriter, "book_offers"); LedgerSpecification.Write(jsonWriter, request.Ledger); if (request.Limit.HasValue) { jsonWriter.WriteNumber("limit", request.Limit.Value); } if (request.Taker.HasValue) { jsonWriter.WriteString("taker", request.Taker.Value.ToString()); } jsonWriter.WritePropertyName("taker_gets"); request.TakerGets.WriteJson(jsonWriter); jsonWriter.WritePropertyName("taker_pays"); request.TakerPays.WriteJson(jsonWriter); WriteFooter(jsonWriter); jsonWriter.WriteEndObject(); jsonWriter.Flush(); var response = await SendReceiveAsync(requestId, jsonBuffer.WrittenMemory, cancellationToken); return(new BookOffersResponse(response)); }
/// <summary> /// The gateway_balances command calculates the total balances issued by a given account, optionally excluding amounts held by operational addresses. /// New in: rippled 0.28.2 /// </summary> public async Task <GatewayBalancesResponse> GatewayBalances(GatewayBalancesRequest request, CancellationToken cancellationToken = default) { jsonBuffer.Clear(); jsonWriter.Reset(); jsonWriter.WriteStartObject(); var requestId = WriteHeader(jsonWriter, "gateway_balances"); LedgerSpecification.Write(jsonWriter, request.Ledger); jsonWriter.WriteString("account", request.Account.ToString()); if (request.HotWallet != null) { if (request.HotWallet.Length == 1) { jsonWriter.WriteString("hotwallet", request.HotWallet[0].ToString()); } else { jsonWriter.WriteStartArray("hotwallet"); foreach (var account in request.HotWallet) { jsonWriter.WriteStringValue(account.ToString()); } jsonWriter.WriteEndArray(); } } WriteFooter(jsonWriter); jsonWriter.WriteEndObject(); jsonWriter.Flush(); var response = await SendReceiveAsync(requestId, jsonBuffer.WrittenMemory, cancellationToken); return(new GatewayBalancesResponse(response)); }
/// <summary> /// The ledger_data method retrieves contents of the specified ledger. /// You can iterate through several calls to retrieve the entire contents of a single ledger version. /// </summary> public async Task <LedgerDataResponse> LedgerData(LedgerDataRequest request, CancellationToken cancellationToken = default) { jsonBuffer.Clear(); jsonWriter.Reset(); jsonWriter.WriteStartObject(); var requestId = WriteHeader(jsonWriter, "ledger_data"); LedgerSpecification.Write(jsonWriter, request.Ledger); jsonWriter.WriteBoolean("binary", true); if (request.Limit.HasValue) { jsonWriter.WriteNumber("limit", request.Limit.Value); } if (request.Marker.HasValue) { jsonWriter.WritePropertyName("marker"); request.Marker.Value.WriteTo(jsonWriter); } WriteFooter(jsonWriter); jsonWriter.WriteEndObject(); jsonWriter.Flush(); var response = await SendReceiveAsync(requestId, jsonBuffer.WrittenMemory, cancellationToken); return(new LedgerDataResponse(response)); }
/// <summary> /// The transaction_entry method retrieves information on a single transaction from a specific ledger version. /// (The tx method, by contrast, searches all ledgers for the specified transaction. We recommend using that method instead.) /// </summary> public async Task <TransactionResponse> TransactionEntry(TransactionEntryRequest request, CancellationToken cancellationToken = default) { jsonBuffer.Clear(); jsonWriter.Reset(); jsonWriter.WriteStartObject(); var requestId = WriteHeader(jsonWriter, "transaction_entry"); LedgerSpecification.Write(jsonWriter, request.Ledger); jsonWriter.WriteString("tx_hash", request.TxHash.ToString()); WriteFooter(jsonWriter); jsonWriter.WriteEndObject(); jsonWriter.Flush(); var response = await SendReceiveAsync(requestId, jsonBuffer.WrittenMemory, cancellationToken); return(new TransactionResponse(response)); }
/// <summary> /// The account_currencies command retrieves a list of currencies that an account can send or receive, based on its trust lines. /// (This is not a thoroughly confirmed list, but it can be used to populate user interfaces.) /// </summary> public async Task <AccountCurrenciesResponse> AccountCurrencies(AccountCurrenciesRequest request, CancellationToken cancellationToken = default) { jsonBuffer.Clear(); jsonWriter.Reset(); jsonWriter.WriteStartObject(); var requestId = WriteHeader(jsonWriter, "account_currencies"); LedgerSpecification.Write(jsonWriter, request.Ledger); jsonWriter.WriteString("account", request.Account.ToString()); WriteFooter(jsonWriter); jsonWriter.WriteEndObject(); jsonWriter.Flush(); var response = await SendReceiveAsync(requestId, jsonBuffer.WrittenMemory, cancellationToken); return(new AccountCurrenciesResponse(response)); }
/// <summary> /// The deposit_authorized command indicates whether one account is authorized to send payments directly to another. /// See Deposit Authorization for information on how to require authorization to deliver money to your account. /// </summary> public async Task <DepositAuthorizedResponse> DepositAuthorized(DepositAuthorizedRequest request, CancellationToken cancellationToken = default) { jsonBuffer.Clear(); jsonWriter.Reset(); jsonWriter.WriteStartObject(); var requestId = WriteHeader(jsonWriter, "deposit_authorized"); LedgerSpecification.Write(jsonWriter, request.Ledger); jsonWriter.WriteString("source_account", request.SourceAccount.ToString()); jsonWriter.WriteString("destination_account", request.DestinationAccount.ToString()); WriteFooter(jsonWriter); jsonWriter.WriteEndObject(); jsonWriter.Flush(); var response = await SendReceiveAsync(requestId, jsonBuffer.WrittenMemory, cancellationToken); return(new DepositAuthorizedResponse(response)); }
/// <summary> /// The ledger_entry method returns a single ledger object from the XRP Ledger in its raw format. /// See ledger format for information on the different types of objects you can retrieve. /// </summary> public async Task <LedgerEntryResponse> LedgerEntry(LedgerEntryRequest request, CancellationToken cancellationToken = default) { jsonBuffer.Clear(); jsonWriter.Reset(); jsonWriter.WriteStartObject(); var requestId = WriteHeader(jsonWriter, "ledger_entry"); LedgerSpecification.Write(jsonWriter, request.Ledger); jsonWriter.WriteBoolean("binary", true); jsonWriter.WriteString("index", request.Index.ToString()); WriteFooter(jsonWriter); jsonWriter.WriteEndObject(); jsonWriter.Flush(); var response = await SendReceiveAsync(requestId, jsonBuffer.WrittenMemory, cancellationToken); return(new LedgerEntryResponse(response)); }
/// <summary> /// The account_info command retrieves information about an account, its activity, and its XRP balance. /// All information retrieved is relative to a particular version of the ledger. /// </summary> public async Task <AccountInfoResponse> AccountInfo(AccountInfoRequest request, CancellationToken cancellationToken = default) { jsonBuffer.Clear(); jsonWriter.Reset(); jsonWriter.WriteStartObject(); var requestId = WriteHeader(jsonWriter, "account_info"); LedgerSpecification.Write(jsonWriter, request.Ledger); jsonWriter.WriteString("account", request.Account.ToString()); jsonWriter.WriteBoolean("queue", request.Queue); jsonWriter.WriteBoolean("signer_lists", request.SignerLists); WriteFooter(jsonWriter); jsonWriter.WriteEndObject(); jsonWriter.Flush(); var response = await SendReceiveAsync(requestId, jsonBuffer.WrittenMemory, cancellationToken); return(new AccountInfoResponse(response)); }
/// <summary> /// The noripple_check command provides a quick way to check the status of the Default Ripple field for an account and the No Ripple flag of its trust lines, compared with the recommended settings. /// </summary> public async Task <NoRippleCheckResponse> NoRippleCheck(NoRippleCheckRequest request, CancellationToken cancellationToken = default) { jsonBuffer.Clear(); jsonWriter.Reset(); jsonWriter.WriteStartObject(); var requestId = WriteHeader(jsonWriter, "noripple_check"); LedgerSpecification.Write(jsonWriter, request.Ledger); jsonWriter.WriteString("account", request.Account.ToString()); jsonWriter.WriteString("role", request.Role); jsonWriter.WriteBoolean("transactions", request.Transactions); if (request.Limit.HasValue) { jsonWriter.WriteNumber("limit", request.Limit.Value); } WriteFooter(jsonWriter); jsonWriter.WriteEndObject(); jsonWriter.Flush(); var response = await SendReceiveAsync(requestId, jsonBuffer.WrittenMemory, cancellationToken); return(new NoRippleCheckResponse(response)); }
/// <summary> /// Retrieve information about the public ledger. /// </summary> public async Task <LedgerResponse> Ledger(LedgerRequest request, CancellationToken cancellationToken = default) { jsonBuffer.Clear(); jsonWriter.Reset(); jsonWriter.WriteStartObject(); var requestId = WriteHeader(jsonWriter, "ledger"); LedgerSpecification.Write(jsonWriter, request.Ledger); jsonWriter.WriteBoolean("binary", true); jsonWriter.WriteBoolean("full", request.Full); jsonWriter.WriteBoolean("accounts", request.Accounts); jsonWriter.WriteBoolean("transactions", request.Transactions); jsonWriter.WriteBoolean("expand", request.Expand); jsonWriter.WriteBoolean("owner_funds", request.OwnerFunds); jsonWriter.WriteBoolean("queue", request.Queue); WriteFooter(jsonWriter); jsonWriter.WriteEndObject(); jsonWriter.Flush(); var response = await SendReceiveAsync(requestId, jsonBuffer.WrittenMemory, cancellationToken); return(new LedgerResponse(response)); }