Skip to content

Commit

Permalink
Merge #686: doc: Document that list_transactions() might return unsor…
Browse files Browse the repository at this point in the history
…ted txs

7fdacdb doc: Document that list_transactions() might return unsorted txs, show how to sort them if needed (w0xlt)

Pull request description:

  This PR documents that `list_transactions()` might return unsorted transaction and shows how to sort them if needed.

  Closes #518.

ACKs for top commit:
  danielabrozzoni:
    re-ACK 7fdacdb

Tree-SHA512: 83bec98e1903d6dc6b8933e8994cb9d04aad059cee8a7b8e1e3a322cf52511364b36d0cd6be1c8cb1fd82c67f8be5a262bbd2c76e30b24eb4097c30f38aa8b10
  • Loading branch information
danielabrozzoni committed Aug 3, 2022
2 parents 9c0a769 + 7fdacdb commit 85bd126
Showing 1 changed file with 12 additions and 1 deletion.
13 changes: 12 additions & 1 deletion src/wallet/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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<bdk::TransactionDetails> = 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<Vec<TransactionDetails>, Error> {
Expand Down

0 comments on commit 85bd126

Please sign in to comment.