From 746c1831c5180041d904bebde328e980d9f5f7e7 Mon Sep 17 00:00:00 2001 From: Yeastplume Date: Tue, 22 Nov 2022 12:04:17 +0000 Subject: [PATCH] add query pagination options struct --- libwallet/src/api_impl/owner.rs | 6 ++++-- libwallet/src/api_impl/types.rs | 28 ++++++++++++++++++++++++++++ libwallet/src/lib.rs | 2 +- 3 files changed, 33 insertions(+), 3 deletions(-) diff --git a/libwallet/src/api_impl/owner.rs b/libwallet/src/api_impl/owner.rs index 96cbfdc7..5e410ddc 100644 --- a/libwallet/src/api_impl/owner.rs +++ b/libwallet/src/api_impl/owner.rs @@ -33,8 +33,9 @@ use crate::types::{AcctPathMapping, NodeClient, TxLogEntry, WalletBackend, Walle use crate::Error; use crate::{ address, wallet_lock, BuiltOutput, InitTxArgs, IssueInvoiceTxArgs, NodeHeightResult, - OutputCommitMapping, PaymentProof, ScannedBlockInfo, Slatepack, SlatepackAddress, Slatepacker, - SlatepackerArgs, TxLogEntryType, ViewWallet, WalletInitStatus, WalletInst, WalletLCProvider, + OutputCommitMapping, PaymentProof, RetrieveTxQueryArgs, ScannedBlockInfo, Slatepack, + SlatepackAddress, Slatepacker, SlatepackerArgs, TxLogEntryType, ViewWallet, WalletInitStatus, + WalletInst, WalletLCProvider, }; use ed25519_dalek::PublicKey as DalekPublicKey; use ed25519_dalek::SecretKey as DalekSecretKey; @@ -313,6 +314,7 @@ pub fn retrieve_txs<'a, L, C, K>( refresh_from_node: bool, tx_id: Option, tx_slate_id: Option, + query_args: Option, ) -> Result<(bool, Vec), Error> where L: WalletLCProvider<'a, C, K>, diff --git a/libwallet/src/api_impl/types.rs b/libwallet/src/api_impl/types.rs index f54102d7..362685e4 100644 --- a/libwallet/src/api_impl/types.rs +++ b/libwallet/src/api_impl/types.rs @@ -148,6 +148,34 @@ impl Default for IssueInvoiceTxArgs { } } +/// Retrieve Transaction List Pagination Arguments +#[derive(Clone, Serialize, Deserialize)] +pub struct RetrieveTxQueryArgs { + /// Retrieve transactions with an id lower than the given, inclusive + /// If None, consider items from the latest transaction and earlier + pub before_id_inc: Option, + /// Retrieve tranactions with an id higher than the given, inclusive + /// If None, consider items from the first transaction and later + pub after_id_inc: Option, + /// The maximum number of transactions to return + /// if both `before_id_inc` and `after_id_inc` are supplied, this will apply + /// to the before and earlier set + pub limit: Option, + /// whether to include cancelled transactions in the returned set + pub include_cancelled: Option, +} + +impl Default for RetrieveTxQueryArgs { + fn default() -> Self { + Self { + before_id_inc: None, + after_id_inc: None, + limit: None, + include_cancelled: None, + } + } +} + /// Fees in block to use for coinbase amount calculation #[derive(Serialize, Deserialize, Debug, Clone)] pub struct BlockFees { diff --git a/libwallet/src/lib.rs b/libwallet/src/lib.rs index 9da67f64..ec17cd01 100644 --- a/libwallet/src/lib.rs +++ b/libwallet/src/lib.rs @@ -65,7 +65,7 @@ pub use crate::slatepack::{ pub use api_impl::owner_updater::StatusMessage; pub use api_impl::types::{ Amount, BlockFees, BuiltOutput, InitTxArgs, InitTxSendArgs, IssueInvoiceTxArgs, - NodeHeightResult, OutputCommitMapping, PaymentProof, VersionInfo, + NodeHeightResult, OutputCommitMapping, PaymentProof, RetrieveTxQueryArgs, VersionInfo, }; pub use internal::scan::scan; pub use slate_versions::ser as dalek_ser;