-
Notifications
You must be signed in to change notification settings - Fork 32
Implement scantxoutset method and test #164
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
base: master
Are you sure you want to change the base?
Conversation
63e4f61
to
67b03b6
Compare
Why is there identical code in the v17 and v18 |
They basically work the same way, the difference is in their return type, v18 has an additional field ( |
Bro I explained this to you already on the other two PRs you did. Perhaps go back over them and see if you can work it out. |
oh, I now understand, I was looking at how For this recent push, I removed the repeated code across all versions having different fields in their type. |
67b03b6
to
43c8b61
Compare
Oh well that would explain your confusion, the |
Done in #169. FTR bugs happen, if you see things that are wrong or look weird just ask (or PR to fix them). Apologies for being so fierce yesterday. |
Returns column needs updating (and Notes). |
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.
Holy moly you picked a difficult one. I'm going to have to come back to this when I can put more thought into it. Feel free to ignore my suggestions until then.
/// > 2. "scanobjects" (array, required) Array of scan objects | ||
#[derive(Deserialize, Debug, Clone, PartialEq)] | ||
#[serde(untagged)] | ||
pub enum ScanTxOutSet { |
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 this is interesting. This is a new idea for the crate, it could be done for all the methods that have verbose results. I'm not sure it adds any value though. I'd just remove this and leave the three individual return types. Plus I'd document 'returned when the foo action as taken'.
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.
after looking at v28 I'm not sure - leave it with me for a bit.
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.
Alright... Noted. That would be great using it for the methods having verbose results.
No problem. I will do this going forward. |
Noted! |
Noted.... |
43c8b61
to
9b7f019
Compare
for the notes, is there any need to change it? since it describes perfectly that the scantxoutset is experimental. |
9b7f019
to
1a3bd20
Compare
Oh you are right, lets leave the notes as they are. |
1a3bd20
to
901bf21
Compare
Man this method is really not that simple to add support for because it changes so often. Can we put this one on hold until you've got a few more easy ones done? |
Understood... sure, let's do that. |
901bf21
to
1bcfa84
Compare
Complete the |
#[serde(rename = "scriptPubKey")] | ||
pub script_pubkey: ScriptBuf, |
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.
model
types don't get renames because they are never used against Core.
} | ||
|
||
#[derive(Deserialize, Debug, Clone, PartialEq)] | ||
pub struct ScanTxOutSetStatus { |
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.
Observation: This struct never changes
Use git grep -A 4 'pub struct ScanTxOutSetStatus'
to see.
} | ||
|
||
#[derive(Clone, Debug, PartialEq, Deserialize, Serialize)] | ||
pub struct ScanTxOutSetStart { |
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 looks wrong. Perhaps add #[serde(deny_unknown_fields)]
to all your structs and that will help find the bugs.
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.
You've done a bunch of work, well done. This one is pretty curly, here are some ideas.
I think it would be more simple if we were to split up the return types for the three different commands (start, abort, status). That way we only have to re-implement the ones that change.
In the client I think it would be more simple to have three methods, one for each command and not have a ScanAction
type.
Instead of ScanObject
I think we can just use a String
and ignore the added complexity of an object (the WithDesc
variant) since it is unused. In general we don't want to add code to the client that we do not use in testing.
That should give you a bit to work on!
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.
There are some missing renames, relates to issue #298. I haven't necessarily highlighted all of them.
/// The current block height (index) | ||
pub height: u64, | ||
/// The hash of the block at the tip of the chain | ||
pub bestblock: 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.
pub bestblock: String, | |
#[serde(rename = "bestblock")] | |
pub best_block: String, |
#[serde(rename = "scriptPubKey")] | ||
pub script_pubkey: String, | ||
/// An output descriptor | ||
pub desc: 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.
pub desc: String, | |
#[serde(rename = "desc")] | |
pub descriptor: String, |
/// The current block height (index) | ||
pub height: u64, | ||
/// The hash of the block at the tip of the chain | ||
pub bestblock: 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.
pub bestblock: String, | |
#[serde(rename = "bestblock")] | |
pub best_block: String, |
/// The current block height (index) | ||
pub height: u64, | ||
/// The hash of the block at the tip of the chain | ||
pub bestblock: 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.
pub bestblock: String, | |
#[serde(rename = "bestblock")] | |
pub best_block: String, |
#[serde(rename = "scriptPubKey")] | ||
pub script_pubkey: String, | ||
/// An output descriptor | ||
pub desc: 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.
pub desc: String, | |
#[serde(rename = "desc")] | |
pub descriptor: String, |
/// Height of the unspent transaction output | ||
pub height: u64, | ||
/// Blockhash of the unspent transaction output | ||
pub blockhash: 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.
pub blockhash: String, | |
#[serde(rename = "blockhash")] | |
pub block_hash: String, |
The JSON-RPC method
scantxoutset
does return a type. We want to test this to catch any changes in behavior in future Core versions.This PR adds a client function that errors if the return value is anything other than the type it returns, along with an integration test that calls this function.
Ref: #116
Closes #115