Uh oh!
There was an error while loading. Please reload this page.
Initial implementation of wallet functionality - #33
Conversation
5264c2a to
cca2687Compare71c560d to
a919af3Comparetnull
commented
Dec 15, 2022
Now includes a custom |
7d54c61 to
4fd40d8CompareUh oh!
There was an error while loading. Please reload this page.
a05b1f0 to
35a25ffCompare7d7d108 to
c1c43f2CompareUh oh!
There was an error while loading. Please reload this page.
| pub(crate) fn set_runtime(&self, tokio_runtime: Arc<tokio::runtime::Runtime>) { | ||
| *self.tokio_runtime.write().unwrap() = Some(tokio_runtime); | ||
| } | ||
| pub(crate) fn drop_runtime(&self) { | ||
| *self.tokio_runtime.write().unwrap() = None; | ||
| } |
There was a problem hiding this comment.
Not sure how well this fits into the larger picture -- but related to #10 (comment) -- another approach to avoid these may be to have any functions needing a runtime take it as a parameter. For sync traits, implement them on something like (Wallet<D>, Arc<tokio::runtime::Runtime>) if the implementation needs to call those functions.
There was a problem hiding this comment.
Unfortunately the latter wouldn't work I think, as we need to give the BroadcasterInterface / FeeEstimator impls to ChannelManager and ChainMonitor. However, as we want to make parameters of them and/or Wallet configurable (e.g., wallet entropy source, Filter impl) based on chain data source, etc., we'd need to instantiate these in the Builder, where we do however not have access to a tokio runtime.
Uh oh!
There was an error while loading. Please reload this page.
| // We double-check that no inputs try to spend non-witness outputs. As we use a SegWit | ||
| // wallet descriptor this technically shouldn't ever happen, but better safe than sorry. |
There was a problem hiding this comment.
This is guaranteed as we're using a Bip84 descriptor template for the BDK wallet, which happens currently in lib.rs.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
| fn get_destination_script(&self) -> Script { | ||
| let address = | ||
| self.wallet.get_new_address().expect("Failed to retrieve new address from wallet."); | ||
| address.script_pubkey() | ||
| } |
There was a problem hiding this comment.
Wish there were a better way of doing this without needing all the boilerplate to override / delegate. Wonder if we should think about parameterizing KeysManager in some way to make this simpler.
There was a problem hiding this comment.
Yes, I'm not a fan of this solution either, also because we now have an redundant unused key in KeysManager, which could be used directly by any future code change. I'd be +1 to introducing some upstream changes to let us override that key.
However, last time I spoke to @TheBlueMatt about the matter he thought the current solution would be the cleanest way.
There was a problem hiding this comment.
Yea, if we're trying to wrap an inner there's not much else we can do. If we wanted to drop the boilerplate we could have expose the KeysManager to the user and have them use that when they need a NodeSigner/EntropySource, but that's maybe even worse.
There was a problem hiding this comment.
Seems like you could parameterize KeysManager with a strategy for generating the scripts. Either from keys derived from the seed or from some other wallet. Then you wouldn't wrap at all but rather have Wallet implement a trait that this new parameter is bounded by.
There was a problem hiding this comment.
Are we fine going ahead with the current version, until we decide on some upstream changes and have them implemented?
829eab3 to
876403eCompare
TheBlueMatt
left a comment
There was a problem hiding this comment.
The new commits on top of #10 look good in isolation.
| } | ||
| } | ||
| pub(crate) fn set_runtime(&self, tokio_runtime: Arc<tokio::runtime::Runtime>) { |
There was a problem hiding this comment.
Curious to see how this works once we get everything landed :)
876403e to
6fe5475Comparetnull
commented
Jan 16, 2023
Uh, rebased. |
Uh oh!
There was an error while loading. Please reload this page.
| fn get_destination_script(&self) -> Script { | ||
| let address = | ||
| self.wallet.get_new_address().expect("Failed to retrieve new address from wallet."); | ||
| address.script_pubkey() | ||
| } |
There was a problem hiding this comment.
Seems like you could parameterize KeysManager with a strategy for generating the scripts. Either from keys derived from the seed or from some other wallet. Then you wouldn't wrap at all but rather have Wallet implement a trait that this new parameter is bounded by.
77ce8ce to
bf9bcc2Comparea11268a to
4728f13Comparetnull
commented
Jan 26, 2023
Squashed without further changes. |
jkczyz
left a comment
There was a problem hiding this comment.
LGTM modulo some minor comments.
| fn get_destination_script(&self) -> Script { | ||
| let address = | ||
| self.wallet.get_new_address().expect("Failed to retrieve new address from wallet."); | ||
| address.script_pubkey() | ||
| } |
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
This implementation of `KeysInterface` allows to override the shutdown/destination scripts and forwards any other calls to an inner instance of `KeysManager` otherwise.
4728f13 to
97716a4Comparetnull
commented
Jan 27, 2023
Squashed again with the following changes: > git diff-tree -U2 4728f13 97716a4diff --git a/src/wallet.rs b/src/wallet.rs
index 598d627..dab6cdc 100644
--- a/src/wallet.rs+++ b/src/wallet.rs@@ -111,5 +111,10 @@ where
}
Err(e) => {
- log_error!(self.logger, "Failed to update fee rate estimation: {}", e);+ log_error!(+ self.logger,+ "Failed to update fee rate estimation for {:?}: {}",+ target,+ e+ );
}
}
@@ -223,5 +228,5 @@ where
D: BatchDatabase,
{
- /// Constructs a `WalletKeysManager` that+ /// Constructs a `WalletKeysManager` that overrides the destination and shutdown scripts.
///
/// See [`KeysManager::new`] for more information on `seed`, `starting_time_secs`, and |
Uh oh!
There was an error while loading. Please reload this page.
…-help-command server: Handle --help command
This PR implements the initial wallet functionality, which was previously included in
access.rs.