From 7fdacdbad40f4e9f6726b064d8eb4d93789e9990 Mon Sep 17 00:00:00 2001 From: w0xlt Date: Wed, 3 Aug 2022 12:08:50 -0300 Subject: [PATCH] doc: Document that list_transactions() might return unsorted txs, show how to sort them if needed --- src/wallet/mod.rs | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/src/wallet/mod.rs b/src/wallet/mod.rs index 4ee3835d9..15f8fcc55 100644 --- a/src/wallet/mod.rs +++ b/src/wallet/mod.rs @@ -438,11 +438,22 @@ where self.database.borrow().get_tx(txid, include_raw) } - /// Return the list of transactions made and received by the wallet + /// Return an unsorted list of transactions made and received by the wallet /// /// Optionally fill the [`TransactionDetails::transaction`] field with the raw transaction if /// `include_raw` is `true`. /// + /// To sort transactions, the following code can be used: + /// ```no_run + /// # let mut tx_list: Vec = vec![]; + /// tx_list.sort_by(|a, b| { + /// b.confirmation_time + /// .as_ref() + /// .map(|t| t.height) + /// .cmp(&a.confirmation_time.as_ref().map(|t| t.height)) + /// }); + /// ``` + /// /// Note that this methods only operate on the internal database, which first needs to be /// [`Wallet::sync`] manually. pub fn list_transactions(&self, include_raw: bool) -> Result, Error> {