Skip to content

Commit 9ed4c50

Browse files
authored
payjoin-cli: Include err context on bitcoind fail (#251)
Simply wrapping an error and passing it up does not provide context to a cli caller. Supplying enough context helps them diagnose the issue.
2 parents eec1835 + b7b04b3 commit 9ed4c50

2 files changed

Lines changed: 6 additions & 0 deletions

File tree

payjoin-cli/src/app/v1.rs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,9 @@ impl AppTrait for App {
2929
fn new(config: AppConfig) -> Result<Self> {
3030
let seen_inputs = Arc::new(Mutex::new(SeenInputs::new()?));
3131
let app = Self { config, seen_inputs };
32+
app.bitcoind()?
33+
.get_blockchain_info()
34+
.context("Failed to connect to bitcoind. Check config RPC connection.")?;
3235
Ok(app)
3336
}
3437

payjoin-cli/src/app/v2.rs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,9 @@ impl AppTrait for App {
3030
let receive_store = Arc::new(AsyncMutex::new(ReceiveStore::new()?));
3131
let send_store = Arc::new(AsyncMutex::new(SendStore::new()?));
3232
let app = Self { config, receive_store, send_store, seen_inputs };
33+
app.bitcoind()?
34+
.get_blockchain_info()
35+
.context("Failed to connect to bitcoind. Check config RPC connection.")?;
3336
Ok(app)
3437
}
3538

0 commit comments

Comments
 (0)