-
Notifications
You must be signed in to change notification settings - Fork 67
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
gui: add listcoins
filters
#967
Changes from all commits
6c7ca2c
f3fdb96
4612159
aa578ba
4641d9e
ddd1e84
21f8704
685f83b
4509bd6
c9fcfae
85b053f
982220d
daf9f85
1c99376
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -7,6 +7,7 @@ use std::{ | |
|
||
use iced::Command; | ||
use liana::{ | ||
commands::CoinStatus, | ||
miniscript::bitcoin::{OutPoint, Txid}, | ||
spend::{SpendCreationError, MAX_FEERATE}, | ||
}; | ||
|
@@ -146,23 +147,23 @@ impl State for TransactionsPanel { | |
if let Some(tx) = &self.selected_tx { | ||
if tx.fee_amount.is_some() { | ||
let tx = tx.clone(); | ||
let txid = tx.tx.txid(); | ||
let outpoints: Vec<_> = (0..tx.tx.output.len()) | ||
.map(|vout| { | ||
OutPoint::new( | ||
tx.tx.txid(), | ||
vout.try_into() | ||
.expect("number of transaction outputs must fit in u32"), | ||
) | ||
}) | ||
.collect(); | ||
return Command::perform( | ||
async move { | ||
daemon | ||
// TODO: filter for spending coins when this is possible: | ||
// https://github.com/wizardsardine/liana/issues/677 | ||
.list_coins() | ||
.list_coins(&[CoinStatus::Spending], &outpoints) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. we use the outpoint, it is enough, you can remove the status filter. My fear is that the coin exists, just is not yet marked as spending There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. As with the other comment, I've kept the status filter. |
||
.map(|res| { | ||
res.coins | ||
.iter() | ||
.filter_map(|c| { | ||
if c.outpoint.txid == txid { | ||
c.spend_info.map(|info| info.txid) | ||
} else { | ||
None | ||
} | ||
}) | ||
.filter_map(|c| c.spend_info.map(|info| info.txid)) | ||
.collect() | ||
}) | ||
.map_err(|e| e.into()) | ||
|
@@ -248,7 +249,6 @@ impl State for TransactionsPanel { | |
self.selected_tx = None; | ||
let daemon1 = daemon.clone(); | ||
let daemon2 = daemon.clone(); | ||
let daemon3 = daemon.clone(); | ||
let now: u32 = SystemTime::now() | ||
.duration_since(UNIX_EPOCH) | ||
.unwrap() | ||
|
@@ -257,7 +257,7 @@ impl State for TransactionsPanel { | |
.unwrap(); | ||
Command::batch(vec![ | ||
Command::perform( | ||
async move { daemon3.list_pending_txs().map_err(|e| e.into()) }, | ||
async move { daemon2.list_pending_txs().map_err(|e| e.into()) }, | ||
Message::PendingTransactions, | ||
), | ||
Command::perform( | ||
|
@@ -268,15 +268,6 @@ impl State for TransactionsPanel { | |
}, | ||
Message::HistoryTransactions, | ||
), | ||
Command::perform( | ||
async move { | ||
daemon2 | ||
.list_coins() | ||
.map(|res| res.coins) | ||
.map_err(|e| e.into()) | ||
}, | ||
Message::Coins, | ||
), | ||
]) | ||
} | ||
} | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
we use the outpoint, it is enough, you can remove the status filter. My fear is that the coin exists, just is not yet marked as spending
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think it's OK to keep the status filter here as the previous
filter_map
was already filtering for coins with a non-null spend txid.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ah you may right, I think we are good then.