19a12c11e2eb9334d975543ee041ddf5b2943c14 test(handler): test error propagation in create_sp_tx (Brendon Votteler)
d73e0c8f13985113ce580a56fc198d749d469de4 fix(handler): replace panics with propagated errors (Brendon Votteler)
Pull request description:
### Description
Fixes #380.
Propagate an error rather than panic when `derive_sp` returns an error inside `create_sp_tx`.
This is done by:
- adding implementation for trait: `From<SpSendError>` for `BDKCliError`
- replacing `derive_sp([..]).expect([..]);` with `derive_sp([..])?;`
- adding a test for the scenario described in #380
<details>
<summary>Expand: output before & after</summary>
Output before:
```sh
$ target/debug/bdk-cli wallet --wallet wsh_wallet create_sp_tx \
--to-sp sprt1qqtnxgt7kn0fpr7fl0u0ndjj35f499y8t9hgmpkp8n2rmkr2gpjzyxqe3qp5n5apt0c5fas9xwy7002l0zqsuhrv7y9clz8yvhnmvut83lypguwer:20000
thread 'main' (
3008870) panicked at src/handlers/offline.rs:508:76:
will fix later: MissingInputsForSharedSecretDerivation
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace
```
(For output with backtrace, see issue description for #380)
Output after:
```sh
$ target/debug/bdk-cli wallet --wallet wsh_wallet create_sp_tx \
--to-sp sprt1qqtnxgt7kn0fpr7fl0u0ndjj35f499y8t9hgmpkp8n2rmkr2gpjzyxqe3qp5n5apt0c5fas9xwy7002l0zqsuhrv7y9clz8yvhnmvut83lypguwer:20000
Error: Cannot create silent payment transaction: No available inputs for shared secret derivation
```
</details>
### Notes to the reviewers
- I wasn't readily able to come up with a test setup to hit the other branches ([SinglePubKey::XOnly](https://github.com/bitcoindevkit/bdk-cli/blob/
9ba78013bdfab7c268b6575442e881db63c242cb/src/handlers/offline.rs#L510-L514) and [DescriptorSecretKey::XPrv](https://github.com/bitcoindevkit/bdk-cli/blob/
9ba78013bdfab7c268b6575442e881db63c242cb/src/handlers/offline.rs#L518)), either.
The propagation method will do the same, either way. Therefore, I didn't try too hard to fabricate those scenarios. Happy to address that if preferred.
- I added tests to `tests/integration/online.rs` despite the handler being in `src/handlers/offline.rs`, simply because that is where the currently existing silent payment tests live.
Happy to move the test to `tests/integrtion/offline` if that is preferable.
### Checklists
#### All Submissions:
* [x] I've signed all my commits
* [x] I followed the [contribution guidelines](https://github.com/bitcoindevkit/bdk-cli/blob/master/CONTRIBUTING.md)
* [x] I ran `cargo fmt` and `cargo clippy` before committing
#### Bugfixes:
* [x] I've added tests to reproduce the issue which are now passing
* [x] I'm linking the issue being fixed by this PR
ACKs for top commit:
emma31-dev:
ACK [
19a12c1](https://github.com/bitcoindevkit/bdk-cli/pull/388/commits/
19a12c11e2eb9334d975543ee041ddf5b2943c14)
vadim-anfv:
ACK
19a12c11e2eb9334d975543ee041ddf5b2943c14
tvpeter:
reACK
19a12c11e2eb9334d975543ee041ddf5b2943c14
Tree-SHA512: aeb8b5983fe698ecc8ab1222278ebccfcb362e4e37069eb47941c88e82487009875cd38c1cded144f398f9f0a8e8b21057c408f336ae734467d1e0e2662ebad2