-
Notifications
You must be signed in to change notification settings - Fork 29
Add missing v18 wallet methods #237
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
Conversation
b760893
to
be1d9b3
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.
In general I don't think we should have arguments to client functions that are optional, unless we need them for some test. E.g I hacked impl_client_v18__list_received_by_label
and was able to remove all three args.
integration_test/tests/wallet.rs
Outdated
let node = Node::with_wallet(Wallet::Default, &[]); | ||
node.fund_wallet(); | ||
let label = "test-label"; | ||
let _ = node.client.new_address_with_label(label).unwrap(); | ||
|
||
// Send some coins to the label | ||
let amount = Amount::from_sat(10_000); | ||
let address = node.client.new_address_with_label(label).unwrap(); | ||
let address = address.assume_checked(); | ||
let _ = node.client.send_to_address(&address, amount).unwrap(); | ||
node.mine_a_block(); | ||
|
||
let json: ListReceivedByLabel = node.client.list_received_by_label(None, None, None).expect("listreceivedbylabel"); | ||
let model: Result<mtype::ListReceivedByLabel, ListReceivedByLabelError> = json.into_model(); | ||
let model = model.unwrap(); | ||
assert!(model.0.iter().any(|item| item.label == label)); |
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 this cleaner?
let node = Node::with_wallet(Wallet::Default, &[]);
node.fund_wallet();
let label = "test-label";
// Send some coins to the label
let amount = Amount::from_sat(10_000);
let address = node.client.new_address_with_label(label).unwrap().assume_checked();
let _ = node.client.send_to_address(&address, amount).unwrap();
node.mine_a_block();
let json: ListReceivedByLabel = node.client.list_received_by_label().expect("listreceivedbylabel");
let model: Result<mtype::ListReceivedByLabel, ListReceivedByLabelError> = json.into_model();
let model = model.unwrap();
assert!(model.0.iter().any(|item| item.label == label));
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, changed.
types/src/model/wallet.rs
Outdated
#[derive(Clone, Debug, PartialEq, Eq, Deserialize, Serialize)] | ||
pub struct ListReceivedByLabelItem { | ||
/// Only returned if imported addresses were involved in transaction. | ||
pub involves_watchonly: 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.
pub involves_watchonly: Option<bool>, | |
pub involves_watch_only: 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.
I was unsure of this but we have one instance already: is_watch_only
. If you feel strongly you could change them both.
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.
Yeah core is inconsistent e.g. as one word This functionality is only intended for use with non-watchonly addresses.
, but also with a dash enforced watch-only wallet
. And also as involvesWatchonly
even though all other RPC return variables are all lowercase.
I think with an _
fits better with the rest of the crate, so I changed it as suggested.
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.
Yeah we shouldn't follow too closely what Core does re word splitting, we have a totally different philosophy here.
be1d9b3
to
cd60513
Compare
integration_test/tests/wallet.rs
Outdated
let node = Node::with_wallet(Wallet::Default, &[]); | ||
node.fund_wallet(); | ||
let label = "test-label"; | ||
let _ = node.client.new_address_with_label(label).unwrap(); |
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.
Why make this call?
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.
It was from a previous version of the test, removed now.
integration_test/tests/wallet.rs
Outdated
let address = node.client.new_address_with_label(label).unwrap(); | ||
let address = address.assume_checked(); |
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.
let address = node.client.new_address_with_label(label).unwrap(); | |
let address = address.assume_checked(); | |
let address = node.client.new_address_with_label(label).unwrap().assume_checked(); |
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.
Done
integration_test/tests/wallet.rs
Outdated
let model = model.unwrap(); | ||
assert!(model.0 == amount); |
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.
let model = model.unwrap(); | |
assert!(model.0 == amount); | |
assert!(model.unwrap().0 == amount); |
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 changed it to assert_eq! too, the assert! was from a previous iteration that was >= amount
in case there were already funds before the send to address.
let model: Result<mtype::ListReceivedByLabel, ListReceivedByLabelError> = json.into_model(); | ||
let model = model.unwrap(); | ||
assert!(model.0.iter().any(|item| item.label == label)); | ||
} |
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.
Oh, you used my suggestion here but didn't follow along in wallet__get_received_by_label__modelled
, my bad I thought you'd notice that.
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 got thoroughly confused just then, I swear I changed this, but then realised that it was wallet__list_received_by_label__modelled. They are so similar I think my brain just merged them into one. Definitely my bad I missed 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.
No stress, I got confused too actually when checking it.
Add `getreceivedbylabel`, `listreceivedbylabel` and `getdescriptorinfo` methods, models and tests.
Reorganising the reexports alphabetically, no other changes.
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.
Suggested changes all made
cd60513
to
ef5dda8
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.
ACK ef5dda8
Add
getreceivedbylabel
,listreceivedbylabel
andgetdescriptorinfo
methods, models and tests.