Skip to content

Commit f3a27c7

Browse files
committed
Merge #143: add revaultd::get_vaults
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
2 parents ca5e591 + dacefc1 commit f3a27c7

File tree

7 files changed

+23
-8
lines changed

7 files changed

+23
-8
lines changed

src/app/state/cmd.rs

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,8 +24,11 @@ pub async fn get_blockheight(revaultd: Arc<RevaultD>) -> Result<u64, RevaultDErr
2424
pub async fn list_vaults(
2525
revaultd: Arc<RevaultD>,
2626
statuses: Option<&[VaultStatus]>,
27+
outpoints: Option<Vec<String>>,
2728
) -> Result<Vec<Vault>, RevaultDError> {
28-
revaultd.list_vaults(statuses).map(|res| res.vaults)
29+
revaultd
30+
.list_vaults(statuses, outpoints.as_ref())
31+
.map(|res| res.vaults)
2932
}
3033

3134
pub async fn get_onchain_txs(

src/app/state/emergency.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -100,6 +100,7 @@ impl State for EmergencyState {
100100
VaultStatus::Unvaulting,
101101
VaultStatus::Unvaulted,
102102
]),
103+
None,
103104
),
104105
Message::Vaults,
105106
)])

src/app/state/manager.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -251,7 +251,7 @@ impl State for ManagerHomeState {
251251
Command::batch(vec![
252252
Command::perform(get_blockheight(self.revaultd.clone()), Message::BlockHeight),
253253
Command::perform(
254-
list_vaults(self.revaultd.clone(), Some(&VaultStatus::CURRENT)),
254+
list_vaults(self.revaultd.clone(), Some(&VaultStatus::CURRENT), None),
255255
Message::Vaults,
256256
),
257257
Command::perform(
@@ -670,7 +670,7 @@ impl State for ManagerCreateSendTransactionState {
670670

671671
fn load(&self) -> Command<Message> {
672672
Command::batch(vec![Command::perform(
673-
list_vaults(self.revaultd.clone(), Some(&[VaultStatus::Active])),
673+
list_vaults(self.revaultd.clone(), Some(&[VaultStatus::Active]), None),
674674
Message::Vaults,
675675
)])
676676
}

src/app/state/spend_transaction.rs

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,11 @@ impl State for SpendTransactionState {
7474
self.deposit_outpoints = tx.deposit_outpoints;
7575
self.psbt = tx.psbt;
7676
return Command::perform(
77-
list_vaults(self.revaultd.clone(), None),
77+
list_vaults(
78+
self.revaultd.clone(),
79+
None,
80+
Some(self.deposit_outpoints.clone()),
81+
),
7882
|res| Message::SpendTx(SpendTxMessage::Inputs(res)),
7983
);
8084
}

src/app/state/stakeholder.rs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -151,6 +151,7 @@ impl State for StakeholderHomeState {
151151
list_vaults(
152152
self.revaultd.clone(),
153153
Some(&VaultStatus::DEPOSIT_AND_CURRENT),
154+
None,
154155
),
155156
Message::Vaults,
156157
),
@@ -347,7 +348,7 @@ impl State for StakeholderCreateVaultsState {
347348
Message::DepositAddress,
348349
),
349350
Command::perform(
350-
list_vaults(self.revaultd.clone(), Some(&[VaultStatus::Funded])),
351+
list_vaults(self.revaultd.clone(), Some(&[VaultStatus::Funded]), None),
351352
Message::Vaults,
352353
),
353354
])
@@ -502,6 +503,7 @@ impl State for StakeholderDelegateFundsState {
502503
VaultStatus::Activating,
503504
VaultStatus::Active,
504505
]),
506+
None,
505507
),
506508
Message::Vaults,
507509
)

src/app/state/vaults.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -98,7 +98,7 @@ impl State for VaultsState {
9898
self.loading = true;
9999
self.vault_status_filter = statuses;
100100
return Command::perform(
101-
list_vaults(self.revaultd.clone(), Some(self.vault_status_filter)),
101+
list_vaults(self.revaultd.clone(), Some(self.vault_status_filter), None),
102102
Message::Vaults,
103103
);
104104
}
@@ -128,7 +128,7 @@ impl State for VaultsState {
128128
Command::batch(vec![
129129
Command::perform(get_blockheight(self.revaultd.clone()), Message::BlockHeight),
130130
Command::perform(
131-
list_vaults(self.revaultd.clone(), Some(self.vault_status_filter)),
131+
list_vaults(self.revaultd.clone(), Some(self.vault_status_filter), None),
132132
Message::Vaults,
133133
),
134134
])

src/revaultd/mod.rs

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -112,8 +112,13 @@ impl RevaultD {
112112
pub fn list_vaults(
113113
&self,
114114
statuses: Option<&[VaultStatus]>,
115+
outpoints: Option<&Vec<String>>,
115116
) -> Result<ListVaultsResponse, RevaultDError> {
116-
self.call("listvaults", statuses.map(|s| vec![s]))
117+
let mut args = vec![json!(statuses.unwrap_or(&[]))];
118+
if let Some(outpoints) = outpoints {
119+
args.push(json!(outpoints));
120+
}
121+
self.call("listvaults", Some(args))
117122
}
118123

119124
pub fn list_onchain_transactions(

0 commit comments

Comments
 (0)