simple_setup/
simple_setup.rs1use std::sync::Arc;
2
3use bitcoin::Network;
4
5use bark::{Config, SqliteClient, Wallet};
6
7async fn example() -> anyhow::Result<()> {
8 let mnemonic = "super secret ...".parse()?;
9 let cfg = Config {
10 server_address: "https://ark.signet.2nd.dev".into(),
11 esplora_address: Some("https://esplora.signet.2nd.dev".into()),
12 ..Config::network_default(Network::Signet)
13 };
14 let db = Arc::new(SqliteClient::open("./bark_db")?);
15 let wallet = Wallet::create(&mnemonic, Network::Signet, cfg, db, false).await?;
16
17 let address = wallet.new_address()?;
18 println!("My first Ark address: {}", address);
19
20 let invoice = wallet.bolt11_invoice("10000sat".parse()?).await?;
21 println!("Send me some sats: {}", invoice);
22
23 wallet.try_claim_all_lightning_receives(true).await?;
25
26 let balance = wallet.balance()?;
27 println!("I now have sats: {}!", balance.spendable);
28
29 let invoice = "lnbc1... get this from someone you like";
31 wallet.pay_lightning_invoice(invoice, None).await?;
32
33 Ok(())
34}
35
36
37#[tokio::main]
38async fn main() {
39 example().await.unwrap();
40}