Join GitHub today
GitHub is home to over 20 million developers working together to host and review code, manage projects, and build software together.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
Already on GitHub? Sign in to your account
listreceivedbyaddress Filter Address #9991
Conversation
MarcoFalke
referenced this pull request
Mar 14, 2017
Closed
listreceivedbyaddress Filter Address #9503
|
fanquake
added
RPC/REST/ZMQ
Wallet
labels
Mar 14, 2017
|
@luke-jr @jnewbery @JeremyRubin nit addressed, can you re-ACK? |
| + #Test Address filtering | ||
| + #Only on addr | ||
| + expected = {"address":addr, "account":"", "amount":Decimal("0.1"), "confirmations":10, "txids":[txid,]} | ||
| + res = self.nodes[1].listreceivedbyaddress(0, True, True, addr) |
jnewbery
Mar 16, 2017
Member
Nit: Consider using named arguments here, instead of positional arguments (since the meaning of the arguments is not clear without having to go back to the definition of listreceivedbyaddress).
NicolasDorier
Mar 17, 2017
•
Member
Listreceivedbyaddress is not known at compile time, and thus has no definition in python. This is interpreted at runtime. So I can't really use named argument. Would inline comment be good ?
EDIT: No mid line comments in python
| + {"address":empty_addr}, | ||
| + {"address":empty_addr, "account":"", "amount":0, "confirmations":0, "txids":[]}) | ||
| + | ||
| + #Test Address filtering |
jnewbery
Mar 16, 2017
Member
I'd prefer this test if other_addr (currently declared on line 78) received some funds before you did your tests on listreceivedbyaddress() with a filter address. This isn't currently testing the case where the wallet contains multiple addresses with funds and you want to see the transactions received by one of those addresses. Ideally the test case would be:
- define addr and send funds to it (already done for you in lines 42-43)
- define other_addr and send funds to it
- call
listreceivedbyaddress()filtering onaddr. Assert only one transaction is returned. - call
listreceivedbyaddress()filtering onother_addr. Assert only one transaction is returned. - call
listreceivedbyaddress()with no filtering. Assert both transactions are returned.
| "\nList balances by receiving address.\n" | ||
| "\nArguments:\n" | ||
| "1. minconf (numeric, optional, default=1) The minimum number of confirmations before payments are included.\n" | ||
| "2. include_empty (bool, optional, default=false) Whether to include addresses that haven't received any payments.\n" | ||
| "3. include_watchonly (bool, optional, default=false) Whether to include watch-only addresses (see 'importaddress').\n" | ||
| - | ||
| + "4. only_address (string, optional) If present, only return information on this address. Otherwise, return all information.\n" |
|
Looks good. A couple of nits and a suggestion on improving the test case. |
|
utAck |
|
@jnewbery I improved the tests, and fixed the alignement. I can't use named parameter in the test though. |
|
added named parameters to one call to listreceivedbyaddress in the tests for better readability. |
|
line 73 with that change, tested ACK. Good stuff @NicolasDorier ! |
|
@jnewbery thanks done, @JeremyRubin did the hard work :) |
JeremyRubin
added some commits
Jan 9, 2017
|
utACK - the code looks good and this is very useful functionality. |
|
@TheBlueMatt I fixed nits and added tests, can you re-ACK ? |
nopara73
commented
May 25, 2017
|
ACK - works fine. |
nopara73
referenced this pull request
in NTumbleBit/NTumbleBit
May 25, 2017
Closed
Tumbling is very slow, lot's of Client's redeem broadcasted #34
|
Closing. I am using a workaround now, I am caching the whole |
NicolasDorier
closed this
Jun 14, 2017
|
|
NicolasDorier
reopened this
Jun 15, 2017
|
@jnewbery, if you have interest, I am reopening, I guess it does not hurt to keep it opens, it is not high maintenance PR. I was thinking to allow multiple addresses to be passed in the filter, instead of only one. For NTumbleBit, I changed the design, I have a method called The way I ended up implemeting my need is by caching EDIT: Documenting why I need also all transaction spent from this address: (not only transactions received) In TumbleBit, there is a chain of transaction.
Escrow is confirmed. So the way I am doing it now is adding Offer's ScriptPubKey as WatchOnly. Then fetching all the transactions from the wallet, caching them in internal database, and going through all those transactions to see if there is one input which is spent by the ScriptPubKey of Offer. If yes, then we have [Fulfill]. Watching all transactions related to one address is very useful, not only the received transaction of the address. In Core, however it is not possible, because knowing if a transaction is "from an address" is considered bad practice. |
jnewbery
referenced this pull request
Jun 16, 2017
Open
RPC: Add parameter to addmultisigaddress / createmultisig to sort public keys #8751
|
@NicolasDorier Do you actually need the wallet functionality (balance tracking, UTXO management, coin selection, ...), or just a means to be notified of certain transactions? |
nopara73
commented
Jun 17, 2017
|
@sipa Need the wallet functionality for NTumbleBit. |
|
Can you clarify what functionality it relies on? |
nopara73
commented
Jun 17, 2017
|
A lot, but I am not sure which are relevant to this discussion with the workaround. @NicolasDorier will have a better insight. https://github.com/NTumbleBit/NTumbleBit/tree/master/NTumbleBit.TumblerServer/Services/RPCServices |
| @@ -1206,6 +1206,17 @@ UniValue ListReceived(CWallet * const pwallet, const UniValue& params, bool fByA | ||
| if(params[2].get_bool()) | ||
| filter = filter | ISMINE_WATCH_ONLY; | ||
| + bool fFilterAddress = false; | ||
| + CTxDestination filterAddress = CNoDestination(); | ||
| + if (!fByAccounts && params.size() > 3) { |
jonasschnelli
Aug 15, 2017
Member
Use a simpler check:
CBitcoinAddress address(request.params[3].get_str());
if (!address.IsValid())| + | ||
| + // Create mapAddressBook iterator | ||
| + // If we aren't filtering, go from begin() to end() | ||
| + auto start = pwallet->mapAddressBook.begin(); |
jonasschnelli
Aug 15, 2017
Member
This loop-or-find logic seems to be a bit wired.
I probably would have factored out the JSON object packing and either called the new function from within the range based loop or after the find().
|
Needs rebase. Concept ACK. I think the by address filter is in general useful. |
|
@sipa just saw now your previous question. I am also using Core as a block explorer: There is some well known address on which I would like to be notified is money is sent to it, or sent from. This PR allows me to know when something is sent to the address. Until I have the two features, my only way is to poll periodically We kind of talked about that in Tokyo, and you seemed to think that the best is that I develop my own wallet, unrelated to bitcoin RPC. I don't like it but I think this is the way I will go for future projects. |
NicolasDorier commentedMar 14, 2017
•
Edited 1 time
-
NicolasDorier
Mar 14, 2017
Supersede #9503 created by @JeremyRubin , I will maintain it.