Skip to content

Commit

Permalink
Merge #143: add revaultd::get_vaults
Browse files Browse the repository at this point in the history
dacefc1 Add outpoints filter to revaultd::list_vaults (edouard)

Pull request description:

  Retrieve the vaults with a list of outpoints.
  This fix the need to retrieve all vaults and filter
  them by selected outpoints in the spend_transaction panel.

ACKs for top commit:
  danielabrozzoni:
    ACK dacefc1

Tree-SHA512: bd4f6a4d4581e0120cd06ef0d0d0fb41dcc6da9b2dddcfc5c07515f6893ef870ca0c6596a1107bad46e7bad147eaa1d1b06b07f307a4a7aa091fb55c500f8007
  • Loading branch information
edouardparis committed Jun 15, 2021
2 parents ca5e591 + dacefc1 commit f3a27c7
Show file tree
Hide file tree
Showing 7 changed files with 23 additions and 8 deletions.
5 changes: 4 additions & 1 deletion src/app/state/cmd.rs
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,11 @@ pub async fn get_blockheight(revaultd: Arc<RevaultD>) -> Result<u64, RevaultDErr
pub async fn list_vaults(
revaultd: Arc<RevaultD>,
statuses: Option<&[VaultStatus]>,
outpoints: Option<Vec<String>>,
) -> Result<Vec<Vault>, RevaultDError> {
revaultd.list_vaults(statuses).map(|res| res.vaults)
revaultd
.list_vaults(statuses, outpoints.as_ref())
.map(|res| res.vaults)
}

pub async fn get_onchain_txs(
Expand Down
1 change: 1 addition & 0 deletions src/app/state/emergency.rs
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,7 @@ impl State for EmergencyState {
VaultStatus::Unvaulting,
VaultStatus::Unvaulted,
]),
None,
),
Message::Vaults,
)])
Expand Down
4 changes: 2 additions & 2 deletions src/app/state/manager.rs
Original file line number Diff line number Diff line change
Expand Up @@ -251,7 +251,7 @@ impl State for ManagerHomeState {
Command::batch(vec![
Command::perform(get_blockheight(self.revaultd.clone()), Message::BlockHeight),
Command::perform(
list_vaults(self.revaultd.clone(), Some(&VaultStatus::CURRENT)),
list_vaults(self.revaultd.clone(), Some(&VaultStatus::CURRENT), None),
Message::Vaults,
),
Command::perform(
Expand Down Expand Up @@ -670,7 +670,7 @@ impl State for ManagerCreateSendTransactionState {

fn load(&self) -> Command<Message> {
Command::batch(vec![Command::perform(
list_vaults(self.revaultd.clone(), Some(&[VaultStatus::Active])),
list_vaults(self.revaultd.clone(), Some(&[VaultStatus::Active]), None),
Message::Vaults,
)])
}
Expand Down
6 changes: 5 additions & 1 deletion src/app/state/spend_transaction.rs
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,11 @@ impl State for SpendTransactionState {
self.deposit_outpoints = tx.deposit_outpoints;
self.psbt = tx.psbt;
return Command::perform(
list_vaults(self.revaultd.clone(), None),
list_vaults(
self.revaultd.clone(),
None,
Some(self.deposit_outpoints.clone()),
),
|res| Message::SpendTx(SpendTxMessage::Inputs(res)),
);
}
Expand Down
4 changes: 3 additions & 1 deletion src/app/state/stakeholder.rs
Original file line number Diff line number Diff line change
Expand Up @@ -151,6 +151,7 @@ impl State for StakeholderHomeState {
list_vaults(
self.revaultd.clone(),
Some(&VaultStatus::DEPOSIT_AND_CURRENT),
None,
),
Message::Vaults,
),
Expand Down Expand Up @@ -347,7 +348,7 @@ impl State for StakeholderCreateVaultsState {
Message::DepositAddress,
),
Command::perform(
list_vaults(self.revaultd.clone(), Some(&[VaultStatus::Funded])),
list_vaults(self.revaultd.clone(), Some(&[VaultStatus::Funded]), None),
Message::Vaults,
),
])
Expand Down Expand Up @@ -502,6 +503,7 @@ impl State for StakeholderDelegateFundsState {
VaultStatus::Activating,
VaultStatus::Active,
]),
None,
),
Message::Vaults,
)
Expand Down
4 changes: 2 additions & 2 deletions src/app/state/vaults.rs
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ impl State for VaultsState {
self.loading = true;
self.vault_status_filter = statuses;
return Command::perform(
list_vaults(self.revaultd.clone(), Some(self.vault_status_filter)),
list_vaults(self.revaultd.clone(), Some(self.vault_status_filter), None),
Message::Vaults,
);
}
Expand Down Expand Up @@ -128,7 +128,7 @@ impl State for VaultsState {
Command::batch(vec![
Command::perform(get_blockheight(self.revaultd.clone()), Message::BlockHeight),
Command::perform(
list_vaults(self.revaultd.clone(), Some(self.vault_status_filter)),
list_vaults(self.revaultd.clone(), Some(self.vault_status_filter), None),
Message::Vaults,
),
])
Expand Down
7 changes: 6 additions & 1 deletion src/revaultd/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -112,8 +112,13 @@ impl RevaultD {
pub fn list_vaults(
&self,
statuses: Option<&[VaultStatus]>,
outpoints: Option<&Vec<String>>,
) -> Result<ListVaultsResponse, RevaultDError> {
self.call("listvaults", statuses.map(|s| vec![s]))
let mut args = vec![json!(statuses.unwrap_or(&[]))];
if let Some(outpoints) = outpoints {
args.push(json!(outpoints));
}
self.call("listvaults", Some(args))
}

pub fn list_onchain_transactions(
Expand Down

0 comments on commit f3a27c7

Please sign in to comment.