gui: optionally filter spend transactions by txids

This commit is contained in:
jp1ac4 2023-12-07 23:22:59 +00:00
parent 4846a0b05a
commit ce50dd8c41
No known key found for this signature in database
GPG Key ID: A7ACD32423568D7B
3 changed files with 13 additions and 3 deletions

View File

@ -120,7 +120,7 @@ impl State for PsbtsPanel {
fn load(&self, daemon: Arc<dyn Daemon + Sync + Send>) -> Command<Message> {
let daemon = daemon.clone();
Command::perform(
async move { daemon.list_spend_transactions().map_err(|e| e.into()) },
async move { daemon.list_spend_transactions(None).map_err(|e| e.into()) },
Message::SpendTxs,
)
}

View File

@ -87,11 +87,21 @@ pub trait Daemon: Debug {
fn update_labels(&self, labels: &HashMap<LabelItem, Option<String>>)
-> Result<(), DaemonError>;
fn list_spend_transactions(&self) -> Result<Vec<model::SpendTx>, DaemonError> {
// List spend transactions, optionally filtered to the specified `txids`.
// Set `txids` to `None` for no filter (passing an empty slice returns no transactions).
fn list_spend_transactions(
&self,
txids: Option<&[Txid]>,
) -> Result<Vec<model::SpendTx>, DaemonError> {
let info = self.get_info()?;
let coins = self.list_coins()?.coins;
let mut spend_txs = Vec::new();
for tx in self.list_spend_txs()?.spend_txs {
if let Some(txids) = txids {
if !txids.contains(&tx.psbt.unsigned_tx.txid()) {
continue;
}
}
let coins = coins
.iter()
.filter(|coin| {

View File

@ -370,7 +370,7 @@ pub async fn load_application(
Wallet::new(info.descriptors.main).load_settings(&gui_config, &datadir_path, network)?;
let coins = daemon.list_coins().map(|res| res.coins)?;
let spend_txs = daemon.list_spend_transactions()?;
let spend_txs = daemon.list_spend_transactions(None)?;
let cache = Cache {
datadir_path,