Join GitHub today
GitHub is home to over 20 million developers working together to host and review code, manage projects, and build software together.
Properly document target_confirmations in listsinceblock #10655
Conversation
fanquake
added the
Docs and Output
label
Jun 23, 2017
|
utACK I know this is a super old issue but I find the current docs astoundingly confusing, can we try for 15? |
|
@kallewoof I think you have experience with this call? documentation sounds reasonable, but I don't actually know how it's used. |
|
The way the API is designed to be used is like this: Let's say I care about only rescanning of 10:
It's a pretty sweet work flow for handling deposits. Just unfortunately listsinceblock is too buggy and ill-defined (I'll create some bug reports when I can). But this PR fixes the docs, that makes it a bit clearer what it does. Most people when they read the docs think it's a filter, when it's not. |
| @@ -1690,7 +1690,7 @@ UniValue listsinceblock(const JSONRPCRequest& request) | ||
| "\nGet all transactions in blocks since block [blockhash], or all transactions if omitted\n" | ||
| "\nArguments:\n" | ||
| "1. \"blockhash\" (string, optional) The block hash to list transactions since\n" | ||
| - "2. target_confirmations: (numeric, optional) The confirmations required, must be 1 or more\n" | ||
| + "2. target_confirmations: (numeric, optional, default=1) Return the nth block hash from the main chain. 1 would mean the bestblockhash (see lastblock in return value)\n" |
TheBlueMatt
Jul 14, 2017
Contributor
Maybe add a note that transactions with fewer confirmations than this are still included in the response, only lastblock is changed by this argument.
|
NACK as is The documentation is very misleading. But it needs to be made even more clear than this. |
Is that what it actually does? o.0 If so thats ....bizarre and wtf. |
|
Yes, thats what it appears to have always done...docs need to be a shitload clearer here. |
|
I pushed another stab at documenting it based on what @morcos said, but it honestly makes no sense to me. I assume I'm misunderstanding. Let's imagine I have the blocks:
Where E is the main chain tip. And C is orphaned. So you're saying if I call |
|
Yes it will return between B and E |
|
Hm, so when you said:
You mean that just the But this is independent to the transaction filtering stuff? |
| @@ -1690,7 +1690,7 @@ UniValue listsinceblock(const JSONRPCRequest& request) | ||
| "\nGet all transactions in blocks since block [blockhash], or all transactions if omitted\n" | ||
| "\nArguments:\n" | ||
| "1. \"blockhash\" (string, optional) The block hash to list transactions since\n" | ||
| - "2. target_confirmations: (numeric, optional) The confirmations required, must be 1 or more\n" | ||
| + "2. target_confirmations: (numeric, optional, default=1) Return the nth block hash from the main chain. e.g. 1 would mean the bestblockhash, unless [blockhash] is not on the current chain, in which case it would return be the common ancestor block between it an the main chain). Note: this is not used as a filter, but only affects [lastblock] in the return value\n" |
TheBlueMatt
Jul 14, 2017
Contributor
No, the value returned is always the Nth-from-top block on the best chain.
|
CBlockIndex *pblockLast = chainActive[chainActive.Height() + 1 - target_confirms];i.e. to determine the block hash of he last block. Correct me if I'm wrong. |
|
@kallewoof you are correct, but that behavior long predates the documentation for the function. I have no idea if anyone uses its previous behavior, but assuming people test things before putting them in production, best to fix the docs and leave the behavior IMO. |
|
@TheBlueMatt That makes sense to me. |
|
I don't think the behavior is a bug at all, it was intentionally designed for use in a loop like I describe in an earlier comment. It's actually a really nice and simple way to handle deposits, and I know a few people who do it that way. Note how it works really well if your depositor goes down, because you keep storing the hash you want to scan from. Changing the behavior at this point would be totally unreasonable. (The only reason I don't handle deposits myself that way, is how it handles double spend (attempts) are weird and inconsistent, which make it very difficult to work with when you're showing unconfirmed stuff) |
|
ACK 52295ba I think that language is clear and accurate (except I'm not sure about putting brackets around the argument names in the help text, is that something we do anywhere else?) |
I just copied it from the original. It's a bit messy, but it's pretty clear and makes things a lot less ambiguous. |
The reason why double spends are weird and inconsistent is probably because you are using target_confs > 1. This means if there's a 1-2 block fork, and your target_confs = 10 or something, you will not be told of the differences caused by the orphan since you're listing a block that preceded the fork point. That's how I interpret this, anyway. |
fanquake
deleted a comment
from Mr-Paradox
Jul 15, 2017
|
My initial expectation was that transactions with less than target_confs confirmations (i.e. transactions in blocks newer than the returned lastblock at the end) would be excluded from the results. This would give you a buffer of 0-confs and 1-confs that are still at risk. That's not what is happening though. |
| @@ -1717,7 +1718,7 @@ UniValue listsinceblock(const JSONRPCRequest& request) | ||
| " \"label\" : \"label\" (string) A comment for the address/transaction, if any\n" | ||
| " \"to\": \"...\", (string) If a comment to is associated with the transaction.\n" | ||
| " ],\n" | ||
| - " \"lastblock\": \"lastblockhash\" (string) The hash of the last block\n" | ||
| + " \"lastblock\": \"lastblockhash\" (string) The hash of the block (target_confirmations-1) from the best block on the main chain. This is typically used to feed back into listsinceblock the next time you call it. So you would generally use a target_confirmations of say 6, so you can keep rescanning the last 6 blocks plus any new ones\n" |
TheBlueMatt
Jul 15, 2017
Contributor
"rescanning" means something specific, maybe "so you will be continually re-notified of transactions until they've reached 6 confirmations"
laanwj
added this to the
0.15.0
milestone
Jul 19, 2017
|
Needs rebase and addressing of @TheBlueMatt 's nit, if this is still to make 0.15 |
|
Ok, rebased and addressed Matt's nit |
| - "listsinceblock ( \"blockhash\" target_confirmations include_watchonly include_removed )\n" | ||
| - "\nGet all transactions in blocks since block [blockhash], or all transactions if omitted.\n" | ||
| - "If \"blockhash\" is no longer a part of the main chain, transactions from the fork point onward are included.\n" | ||
| - "Additionally, if include_removed is set, transactions affecting the wallet which were removed are returned in the \"removed\" array.\n" |
| - "\nGet all transactions in blocks since block [blockhash], or all transactions if omitted.\n" | ||
| - "If \"blockhash\" is no longer a part of the main chain, transactions from the fork point onward are included.\n" | ||
| - "Additionally, if include_removed is set, transactions affecting the wallet which were removed are returned in the \"removed\" array.\n" | ||
| + "listsinceblock ( \"blockhash\" target_confirmations include_watchonly)\n" |
TheBlueMatt
Jul 25, 2017
Contributor
Looks like a rebase error - you've removed the include_removed parameter here.
| - "2. target_confirmations: (numeric, optional, default=1) The confirmations required, must be 1 or more\n" | ||
| - "3. include_watchonly: (bool, optional, default=false) Include transactions to watch-only addresses (see 'importaddress')\n" | ||
| + "2. target_confirmations: (numeric, optional, default=1) Return the nth block hash from the main chain. e.g. 1 would mean the bestblockhash. Note: this is not used as a filter, but only affects [lastblock] in the return value\n" | ||
| + "3. include_watchonly: (bool, optional, default=false) Include transactions to watch-only addresses (see 'importaddress')" |
|
Ok, fixed my rebase fail... |
| "Additionally, if include_removed is set, transactions affecting the wallet which were removed are returned in the \"removed\" array.\n" | ||
| "\nArguments:\n" | ||
| "1. \"blockhash\" (string, optional) The block hash to list transactions since\n" | ||
| - "2. target_confirmations: (numeric, optional, default=1) The confirmations required, must be 1 or more\n" | ||
| + "2. target_confirmations: (numeric, optional, default=1) Return the nth block hash from the main chain. e.g. 1 would mean the bestblockhash. Note: this is not used as a filter, but only affects [lastblock] in the return value\n" |
|
utACK |
|
utACK 9f8a46f |
laanwj
merged commit 9f8a46f
into
bitcoin:master
Jul 26, 2017
1 check passed
laanwj
added a commit
that referenced
this pull request
Jul 26, 2017
|
|
laanwj |
78f307b
|
RHavar commentedJun 23, 2017
There seems to be some misunderstandings about this, but it's a heavily used function so I'd like to make sure the docs are clear about how it works.
For a later issue: