@@ -3,14 +3,17 @@ use std::{collections::HashMap, net::Ipv4Addr};
33use anyhow:: Result ;
44use clap:: Args ;
55use 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+ } ;
710use doublezero_solana_sdk:: shred_subscription:: { self , state} ;
811use solana_account_decoder_client_types:: UiAccountEncoding ;
912use 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 } ;
1417use tabled:: { Table , Tabled , settings:: Style } ;
1518
1619use 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