()
| 2 | use bwt::{App, Config, Result}; |
| 3 | |
| 4 | fn main() -> Result<()> { |
| 5 | let my_desc = "wpkh(tpubD6NzVbkrYhZ4Ya1aR2od7JTGK6b44cwKhWzrvrTeTWFrzGokdAGHrZLK6BdYwpx9K7EoY38LzHva3SWwF8yRrXM9x9DQ3jCGKZKt1nQEz7n/0/*)"; |
| 6 | |
| 7 | // Initialize the config |
| 8 | let config = Config { |
| 9 | network: bitcoin::Network::Regtest, |
| 10 | bitcoind_dir: Some("/home/satoshi/.bitcoin".into()), |
| 11 | bitcoind_wallet: Some("bwt".into()), |
| 12 | electrum_addr: Some("127.0.0.1:0".parse().unwrap()), |
| 13 | descriptors: vec![my_desc.parse().unwrap()], |
| 14 | rescan_since: RescanSince::Now, |
| 15 | verbose: 2, |
| 16 | ..Default::default() |
| 17 | }; |
| 18 | config.setup_logger(); // optional |
| 19 | |
| 20 | // Boot up bwt. The thread will be blocked until the initial sync is completed |
| 21 | let app = App::boot(config, None)?; |
| 22 | |
| 23 | // The index is now ready for querying |
| 24 | let query = app.query(); |
| 25 | log::info!("synced up to {:?}", query.get_tip()?); |
| 26 | log::info!("utxos: {:?}", query.list_unspent(None, 0, None)?); |
| 27 | log::info!("electrum running on {}", app.electrum_addr().unwrap()); |
| 28 | |
| 29 | // Start syncing new blocks/transactions in the background |
| 30 | let shutdown_tx = app.sync_background(); |
| 31 | |
| 32 | // To shutdown the syncing thread, send a message to `shutdown_tx` or let it drop out of scope |
| 33 | shutdown_tx.send(()).unwrap(); |
| 34 | |
| 35 | Ok(()) |
| 36 | } |
nothing calls this directly
no test coverage detected