@@ -6,8 +6,8 @@ use rustyline::error::ReadlineError;
66
77use orange_sdk:: bitcoin_payment_instructions:: amount:: Amount ;
88use orange_sdk:: {
9- ChainSource , Event , ExtraConfig , LoggerType , Mnemonic , PaymentInfo , Seed , SparkWalletConfig ,
10- StorageConfig , Tunables , Wallet , WalletConfig , bitcoin:: Network ,
9+ CashuConfig , ChainSource , CurrencyUnit , Event , ExtraConfig , LoggerType , Mnemonic , PaymentInfo ,
10+ Seed , SparkWalletConfig , StorageConfig , Tunables , Wallet , WalletConfig , bitcoin:: Network ,
1111} ;
1212use rand:: RngCore ;
1313use std:: fs;
@@ -23,6 +23,15 @@ const NETWORK: Network = Network::Bitcoin; // Supports Bitcoin and Regtest
2323#[ derive( Parser ) ]
2424#[ command( author, version, about, long_about = None ) ]
2525struct Cli {
26+ /// Use Cashu wallet instead of Spark
27+ #[ arg( long) ]
28+ cashu : bool ,
29+ /// Cashu mint URL (requires --cashu)
30+ #[ arg( long, requires = "cashu" ) ]
31+ mint_url : String ,
32+ /// npub.cash URL for lightning address support (requires --cashu)
33+ #[ arg( long, requires = "cashu" ) ]
34+ npubcash_url : Option < String > ,
2635 #[ command( subcommand) ]
2736 command : Option < Commands > ,
2837}
@@ -74,12 +83,22 @@ struct WalletState {
7483 shutdown : Arc < AtomicBool > ,
7584}
7685
77- fn get_config ( network : Network ) -> Result < WalletConfig > {
86+ fn get_config ( network : Network , cli : & Cli ) -> Result < WalletConfig > {
7887 let storage_path = format ! ( "./wallet_data/{network}" ) ;
7988
8089 // Generate or load seed
8190 let seed = generate_or_load_seed ( & storage_path) ?;
8291
92+ let extra_config = if cli. cashu {
93+ ExtraConfig :: Cashu ( CashuConfig {
94+ mint_url : cli. mint_url . clone ( ) ,
95+ unit : CurrencyUnit :: Sat ,
96+ npubcash_url : cli. npubcash_url . clone ( ) ,
97+ } )
98+ } else {
99+ ExtraConfig :: Spark ( SparkWalletConfig :: default ( ) )
100+ } ;
101+
83102 match network {
84103 Network :: Regtest => {
85104 let lsp_address = "185.150.162.100:3551"
@@ -103,7 +122,7 @@ fn get_config(network: Network) -> Result<WalletConfig> {
103122 network,
104123 seed,
105124 tunables : Tunables :: default ( ) ,
106- extra_config : ExtraConfig :: Spark ( SparkWalletConfig :: default ( ) ) ,
125+ extra_config,
107126 } )
108127 } ,
109128 Network :: Bitcoin => {
@@ -132,17 +151,17 @@ fn get_config(network: Network) -> Result<WalletConfig> {
132151 network,
133152 seed,
134153 tunables : Tunables :: default ( ) ,
135- extra_config : ExtraConfig :: Spark ( SparkWalletConfig :: default ( ) ) ,
154+ extra_config,
136155 } )
137156 } ,
138157 _ => Err ( anyhow:: anyhow!( "Unsupported network: {network:?}" ) ) ,
139158 }
140159}
141160
142161impl WalletState {
143- async fn new ( ) -> Result < Self > {
162+ async fn new ( cli : & Cli ) -> Result < Self > {
144163 let shutdown = Arc :: new ( AtomicBool :: new ( false ) ) ;
145- let config = get_config ( NETWORK )
164+ let config = get_config ( NETWORK , cli )
146165 . with_context ( || format ! ( "Failed to get wallet config for network: {NETWORK:?}" ) ) ?;
147166
148167 println ! ( "{} Initializing wallet..." , "⚡" . bright_yellow( ) ) ;
@@ -241,7 +260,7 @@ async fn main() -> Result<()> {
241260 println ! ( ) ;
242261
243262 // Initialize wallet once at startup
244- let mut state = WalletState :: new ( ) . await ?;
263+ let mut state = WalletState :: new ( & cli ) . await ?;
245264
246265 // Set up signal handling for graceful shutdown
247266 let shutdown_state = state. shutdown . clone ( ) ;
0 commit comments