gui: optionally filter spend transactions by txids
This commit is contained in:
parent
4846a0b05a
commit
ce50dd8c41
@ -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,
|
||||
)
|
||||
}
|
||||
|
||||
@ -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| {
|
||||
|
||||
@ -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,
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user