mirror of
https://github.com/serai-dex/serai.git
synced 2024-11-17 01:17:36 +00:00
Have Coin::get_outputs return by transaction, not by block
This commit is contained in:
parent
b303649f9d
commit
9662e9e1af
2 changed files with 26 additions and 18 deletions
|
@ -69,7 +69,7 @@ pub trait Coin {
|
|||
&self,
|
||||
block: &Self::Block,
|
||||
key: <Self::Curve as Ciphersuite>::G,
|
||||
) -> Result<Vec<Self::Output>, CoinError>;
|
||||
) -> Result<Vec<Vec<Self::Output>>, CoinError>;
|
||||
|
||||
#[allow(clippy::too_many_arguments)]
|
||||
async fn prepare_send(
|
||||
|
|
|
@ -169,25 +169,33 @@ impl Coin for Monero {
|
|||
&self,
|
||||
block: &Self::Block,
|
||||
key: dfg::EdwardsPoint,
|
||||
) -> Result<Vec<Self::Output>, CoinError> {
|
||||
Ok(
|
||||
self
|
||||
) -> Result<Vec<Vec<Self::Output>>, CoinError> {
|
||||
let mut transactions = self
|
||||
.scanner(key)
|
||||
.scan(&self.rpc, block)
|
||||
.await
|
||||
.map_err(|_| CoinError::ConnectionError)?
|
||||
.iter()
|
||||
.flat_map(|outputs| outputs.not_locked())
|
||||
.map(|outputs| outputs.not_locked())
|
||||
.collect::<Vec<_>>();
|
||||
|
||||
// This should be pointless as we shouldn't be able to scan for any other subaddress
|
||||
// This just ensures nothing invalid makes it in
|
||||
.filter_map(|output| {
|
||||
if ![EXTERNAL_SUBADDRESS, BRANCH_SUBADDRESS, CHANGE_SUBADDRESS]
|
||||
// This just ensures nothing invalid makes it through
|
||||
for transaction in transactions.iter_mut() {
|
||||
*transaction = transaction
|
||||
.drain(..)
|
||||
.filter(|output| {
|
||||
[EXTERNAL_SUBADDRESS, BRANCH_SUBADDRESS, CHANGE_SUBADDRESS]
|
||||
.contains(&output.output.metadata.subaddress)
|
||||
{
|
||||
return None;
|
||||
}
|
||||
Some(Output::from(output))
|
||||
})
|
||||
.collect();
|
||||
}
|
||||
transactions = transactions.drain(..).filter(|outputs| !outputs.is_empty()).collect();
|
||||
|
||||
Ok(
|
||||
transactions
|
||||
.drain(..)
|
||||
.map(|mut transaction| transaction.drain(..).map(Output::from).collect())
|
||||
.collect(),
|
||||
)
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue