Skip to content
This repository was archived by the owner on Sep 8, 2026. It is now read-only.

Commit 30da7fc

Browse files
cli: default shreds list to funder keypair, add --all and -k flags (#328)
## Summary - Default `shreds list` to filter by the local keypair's pubkey (withdraw authority), so users see only their own seats - Add `--all` flag to opt out and show every seat (previous default) - Add `-k` / `--keypair` to specify a non-default keypair for the funder filter - Rename `--withdraw-authority` to `--funder` Closes malbeclabs/infra#872
1 parent 9278e02 commit 30da7fc

2 files changed

Lines changed: 36 additions & 8 deletions

File tree

crates/solana-cli/CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
99

1010
- `shreds pay`: block duplicate client IP across devices — prevent creating a seat for an IP that already has an active seat on a different device
1111
- `shreds validator-client-rewards`: add hidden command to set validator client rewards proportion
12+
- `shreds list`: filter by funder (withdraw-authority) by default, add `--all` flag
1213

1314
## [0.5.0](https://github.com/doublezerofoundation/doublezero-offchain/releases/tag/doublezero-solana/v0.5.0)
1415

crates/solana-cli/src/command/shreds/list.rs

Lines changed: 35 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -3,14 +3,17 @@ use std::{collections::HashMap, net::Ipv4Addr};
33
use anyhow::Result;
44
use clap::Args;
55
use doublezero_serviceability::state::device::Device;
6-
use doublezero_solana_client_tools::rpc::{SolanaConnection, SolanaConnectionOptions};
6+
use doublezero_solana_client_tools::{
7+
payer::try_load_keypair,
8+
rpc::{SolanaConnection, SolanaConnectionOptions},
9+
};
710
use doublezero_solana_sdk::shred_subscription::{self, state};
811
use solana_account_decoder_client_types::UiAccountEncoding;
912
use solana_client::{
1013
rpc_config::{RpcAccountInfoConfig, RpcProgramAccountsConfig},
1114
rpc_filter::{Memcmp, RpcFilterType},
1215
};
13-
use solana_sdk::{account::Account, pubkey::Pubkey};
16+
use solana_sdk::{account::Account, pubkey::Pubkey, signer::Signer};
1417
use tabled::{Table, Tabled, settings::Style};
1518

1619
use super::make_dz_connection;
@@ -25,14 +28,20 @@ pub struct ListCommand {
2528
#[command(flatten)]
2629
device_args: super::DeviceArgs,
2730

28-
/// Filter seats by withdraw authority (wallets that have payment escrows).
29-
#[arg(long)]
30-
withdraw_authority: Option<Pubkey>,
31+
/// Filter seats by funder (withdraw authority). Accepts a public key or a
32+
/// path to a keypair file. When omitted, defaults to the default keypair's
33+
/// public key (use --all to show every seat instead).
34+
#[arg(long, short = 'k')]
35+
funder: Option<String>,
3136

3237
/// Filter seats by client IPv4 address.
3338
#[arg(long)]
3439
client_ip: Option<Ipv4Addr>,
3540

41+
/// Show all seats regardless of funder.
42+
#[arg(long)]
43+
all: bool,
44+
3645
#[command(flatten)]
3746
connection_options: SolanaConnectionOptions,
3847
}
@@ -116,9 +125,23 @@ impl ListCommand {
116125
})
117126
.collect();
118127

128+
// Resolve the funder (withdraw authority) filter.
129+
let funder: Option<Pubkey> = if let Some(ref funder_str) = self.funder {
130+
if let Ok(pubkey) = funder_str.parse::<Pubkey>() {
131+
Some(pubkey)
132+
} else {
133+
let keypair = try_load_keypair(Some(funder_str.into()))?;
134+
Some(keypair.pubkey())
135+
}
136+
} else if !self.all {
137+
let keypair = try_load_keypair(None)?;
138+
Some(keypair.pubkey())
139+
} else {
140+
None
141+
};
142+
119143
// Fetch escrow balances.
120-
let (escrow_balances, filtered_seats) = if let Some(ref authority) = self.withdraw_authority
121-
{
144+
let (escrow_balances, filtered_seats) = if let Some(ref authority) = funder {
122145
let escrow_keys: Vec<Pubkey> = parsed_seats
123146
.iter()
124147
.map(|(seat_key, _, _, _)| {
@@ -160,7 +183,11 @@ impl ListCommand {
160183
balances.insert(seat_key, balance);
161184
}
162185
}
163-
(balances, parsed_seats)
186+
let matching_seats: Vec<_> = parsed_seats
187+
.into_iter()
188+
.filter(|(seat_key, _, _, _)| balances.contains_key(seat_key))
189+
.collect();
190+
(balances, matching_seats)
164191
};
165192

166193
if filtered_seats.is_empty() {

0 commit comments

Comments
 (0)