-
Notifications
You must be signed in to change notification settings - Fork 273
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
CreateWallet update+ListWallets+GetWalletInfo #121
CreateWallet update+ListWallets+GetWalletInfo #121
Conversation
9548c67
to
3616145
Compare
Fixed for version 18 (and also fixed defaults). |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Besides my one comment this looks very good!
#[serde(rename = "hdmasterkeyid")] | ||
pub hd_master_key_id: Option<String>, | ||
pub private_keys_enabled: bool, | ||
pub avoid_reuse: Option<bool>, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Does hd_master_key_id
exist? I don't see it in docs or source ...
Seems like avoid_reuse
can just be a bool
, right?
This implementation is also missing the scanning
field:
"scanning" : { (json object) current scanning details, or false if no scan is in progress
"duration" : n, (numeric) elapsed seconds since scan start
"progress" : n (numeric) scanning progress percentage [0.0, 1.0]
}
But I'm not sure how to implement that because it could be either a bool or a struct. Similar scenario to #124 where you have mixed content. We could always add this later, too.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Those are possible to implement, but not easy. I don't know if serde does it automatically if you create an enum. I don't think it does because there is an implied false. I can try do a custom serde implementation after this is merged if you want. (I'll create a ticket for it when we merge this.)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The hdmasterkeyid
field seems to have been removed in 0.18. Since we only support 0.18 and 0.19, we shouldn't have it.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Does hd_master_key_id exist? I don't see it in docs or source ...
Thanks, as @stevenroose pointed out it was removed so I deleted it.
Seems like avoid_reuse can just be a bool, right?
It didn't exist in v0.18 which is why I put it as an Option<>
, but if there is a better way of handling this let me know (IIRC CI fails for v0.18 if it's not an option).
This implementation is also missing the scanning field:
I was curious so I gave it a try and it seems to work. It cannot be properly tested through CI though because rescanning in regtest is too fast. I gave it a try on testnet and it seems to work as expected. I put it as a separate commit for now, so if you're not happy with the implementation I'll just drop it and someone else can take care of it later. If you're happy with it I can squash it. One downside with this implementation is that it's not really explicit about the fact that the boolean part of the enum can only be false
, not sure if there is a better way.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ah yeah it's unfortunate that it has this bool that is always false. But well. I'm ok with this.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Perhaps add a line of documentation on "NotScanning(bool)" that the bool will always be false?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice!
#[serde(rename = "hdmasterkeyid")] | ||
pub hd_master_key_id: Option<String>, | ||
pub private_keys_enabled: bool, | ||
pub avoid_reuse: Option<bool>, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Those are possible to implement, but not easy. I don't know if serde does it automatically if you create an enum. I don't think it does because there is an implied false. I can try do a custom serde implementation after this is merged if you want. (I'll create a ticket for it when we merge this.)
integration_test/src/main.rs
Outdated
avoid_reuse: Option<bool>, | ||
} | ||
|
||
fn build_wallet_params<'a>( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is a little bit of a silly utility method that I'd personally not have created, but I don't bother because it's test stuff :)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Removed, didn't have very strong feelings about it :)
integration_test/src/main.rs
Outdated
|
||
assert_eq!(wallet_info.wallet_name, wallet_param.name); | ||
|
||
fn option_to_bool(option: Option<bool>) -> bool { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Isn't this just .unwrap_or(false)
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes thanks fixed.
integration_test/src/main.rs
Outdated
} | ||
|
||
for param in wallet_params { | ||
test_create_single_wallet(&cl, param); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This method is only used here, right? I wouldn't mind just having it expanded inside this for loop. Than the WalletParams
type can also be made method-local. It's just a suggestion won't be blocking for this.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Expanded in loop and put WalletParams
as method-local.
#[serde(rename = "hdmasterkeyid")] | ||
pub hd_master_key_id: Option<String>, | ||
pub private_keys_enabled: bool, | ||
pub avoid_reuse: Option<bool>, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The hdmasterkeyid
field seems to have been removed in 0.18. Since we only support 0.18 and 0.19, we shouldn't have it.
3616145
to
1240252
Compare
@stevenroose @Tibo-lg do you consider this PR ready for another round of review? |
@sgeisler I think I addressed all the comments so I would say yes. If I missed something let me know. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good, some minor nits, but if someone is annoyed by these there can be a separate PR I guess. We don't need to block on these imo, but feel free to fix them if you want and I'll re-ACK.
json/src/lib.rs
Outdated
pub keypool_size: usize, | ||
#[serde(rename = "keypoolsize_hd_internal")] | ||
pub keypool_size_hd_internal: usize, | ||
pub unlocked_until: Option<usize>, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Would SystemTime
make more sense here?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I double checked but all the timestamps seem to be either usize
or u64
. Changed to u64
as it might be better and I don't mind changing to SystemTime
but I feel it might be inconsistent.
json/src/lib.rs
Outdated
#[serde(rename = "paytxfee", with = "bitcoin::util::amount::serde::as_btc")] | ||
pub pay_tx_fee: Amount, | ||
#[serde(rename = "hdseedid")] | ||
pub hd_seed_id: Option<String>, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
How do we handle binary data elsewhere? Should this be decoded to [u8; 20]
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for pointing this out, I checked and actually there was already a hd_seed_id
field defined for GetAddressInfoResult
so I reused the type (bitcoin::XpubIdentifier
).
0244b98
to
0e203cf
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM, I'll add the line of comment.
Originally I was only planning on updating
create_wallet
with the extra parameters (mainly wanted the passphrase), but as I wanted to test that it was working properly I ended up needinglist_wallets
andget_wallet_info
as well.Some notes:
list_wallets
andget_wallet_info
are implicitly tested through thecreate_wallet
test, I hope that's ok.GetWalletInfoResult
I had to makeunlocked_until
optional even though it is not marked as optional in the docs (https://bitcoincore.org/en/doc/0.19.0/rpc/wallet/getwalletinfo/). I checked manually withbitcoin-cli
and I could see that it was not always present, not sure why.scanning
from the wallet info result because I was not sure how to represent something that can be false or an object.get_rpc_url
andget_auth
in the integration tests so that it can be reused to create clients for the "sub" wallets.