@@ -64,7 +64,7 @@ orange-sdk = "0.1"
6464
6565### Basic Example
6666
67- ``` rust
67+ ``` rust,no_run
6868use orange_sdk::bitcoin::Network;
6969use orange_sdk::bitcoin_payment_instructions::amount::Amount;
7070use orange_sdk::trusted_wallet::spark::SparkWalletConfig;
@@ -73,55 +73,55 @@ use orange_sdk::{ExtraConfig, LoggerType, Mnemonic, Seed};
7373use std::str::FromStr;
7474
7575#[tokio::main]
76- async fn main () -> Result <(), Box < dyn std :: error :: Error >> {
76+ async fn main() {
7777 // Configure the wallet
7878 let config = WalletConfig {
7979 storage_config: StorageConfig::LocalSQLite("./wallet".to_string()),
8080 logger_type: LoggerType::LogFacade,
8181 chain_source: ChainSource::Electrum(
8282 "ssl://electrum.blockstream.info:60002".to_string(),
8383 ),
84- lsp : (" 127.0.0.1:9735" . parse ()? , " 03abcd..." . parse ()? , None ),
84+ lsp: ("127.0.0.1:9735".parse().unwrap() , "03abcd...".parse().unwrap() , None),
8585 scorer_url: None,
8686 rgs_url: None,
8787 network: Network::Bitcoin,
8888 seed: Seed::Mnemonic {
89- mnemonic : Mnemonic :: from_str (" your mnemonic words here" )? ,
89+ mnemonic: Mnemonic::from_str("your mnemonic words here").unwrap() ,
9090 passphrase: None,
9191 },
9292 tunables: Tunables {
93- trusted_balance_limit : Amount :: from_sats (100_000 )? ,
94- rebalance_min : Amount :: from_sats (5_000 )? ,
95- onchain_receive_threshold : Amount :: from_sats (10_000 )? ,
93+ trusted_balance_limit: Amount::from_sats(100_000).unwrap() ,
94+ rebalance_min: Amount::from_sats(5_000).unwrap() ,
95+ onchain_receive_threshold: Amount::from_sats(10_000).unwrap() ,
9696 enable_amountless_receive_on_chain: true,
9797 },
9898 extra_config: ExtraConfig::Spark(SparkWalletConfig::default()),
9999 };
100100
101101 // Initialize the wallet
102- let wallet = Wallet :: new (config ). await ? ;
102+ let wallet = Wallet::new(config).await.unwrap() ;
103103
104104 // Check balance
105- let balance = wallet . get_balance (). await ? ;
106- println! (" Available: {}" , balance . available_balance ());
107- println! (" Trusted: {}" , balance . trusted);
108- println! (" Lightning: {}" , balance . lightning);
109- println! (" Pending: {}" , balance . pending_balance);
105+ let balance = wallet.get_balance().await.unwrap() ;
106+ println!("Available: {:? }", balance.available_balance());
107+ println!("Trusted: {:? }", balance.trusted);
108+ println!("Lightning: {:? }", balance.lightning);
109+ println!("Pending: {:? }", balance.pending_balance);
110110
111111 // Generate a receive URI
112- let uri = wallet . get_single_use_receive_uri (Some (Amount :: from_sats (50_000 )? )) . await ? ;
112+ let uri = wallet.get_single_use_receive_uri(Some(Amount::from_sats(50_000).unwrap())) .await.unwrap() ;
113113 println!("Pay me: {}", uri);
114114
115115 // Parse and pay an invoice
116- let instructions = wallet . parse_payment_instructions (" lnbc..." ). await ? ;
117- let payment_info = orange_sdk :: PaymentInfo :: build (instructions , Some (Amount :: from_sats (1_000 )? )) ? ;
118- wallet . pay (& payment_info ). await ? ;
116+ let instructions = wallet.parse_payment_instructions("lnbc...").await.unwrap() ;
117+ let payment_info = orange_sdk::PaymentInfo::build(instructions, Some(Amount::from_sats(1_000).unwrap())).unwrap() ;
118+ wallet.pay(&payment_info).await.unwrap() ;
119119
120120 // Listen for events
121121 loop {
122122 let event = wallet.next_event_async().await;
123123 println!("Event: {:?}", event);
124- wallet . event_handled ()? ;
124+ wallet.event_handled().unwrap() ;
125125 }
126126}
127127```
@@ -160,4 +160,4 @@ Contributions are welcome! Please feel free to submit a Pull Request.
160160
161161## License
162162
163- * (Specify the license for the project) *
163+ See [ LICENSE ] ( LICENSE.md ) for details.
0 commit comments