Split bitcoin::Wallet functions into various impl blocks

This allows us to construct instances of bitcoin::Wallet for test
purposes that use a different blockchain and database implementation.

We also parameterize the electrum-client to make it possible to
construct a bitcoin::Wallet for tests that doesn't have one. This
is necessary because the client validates the connection as it is
constructed and we don't want to provide an Electrum backend for
unit tests.
This commit is contained in:
Thomas Eizinger 2021-03-24 18:16:58 +11:00
parent b9d8cbeaa2
commit 8576894c10
No known key found for this signature in database
GPG key ID: 651AC83A6C6C8B96
2 changed files with 126 additions and 107 deletions

View file

@ -21,7 +21,7 @@ impl TxLock {
pub async fn new(wallet: &Wallet, amount: Amount, A: PublicKey, B: PublicKey) -> Result<Self> {
let lock_output_descriptor = build_shared_output_descriptor(A.0, B.0);
let address = lock_output_descriptor
.address(wallet.get_network().await)
.address(wallet.get_network())
.expect("can derive address from descriptor");
let psbt = wallet.send_to_address(address, amount).await?;