[PATCH] implement 'xlisttransactions'

12 messages BitcoinTalk Jeff Garzik, Gavin Andresen, Satoshi Nakamoto, lachesis, throughput, knightmb, ByteCoin July 29, 2010 — August 15, 2010
Jeff Garzik (jgarzik) July 29, 2010 00:34 UTC Source ·

Here is a patch against SVN 117, implementing ‘xlisttransactions’ RPC: http://pastebin.ca/1910553 At present, the options are ignored, and it dumps all transactions it finds.

Raw patch: http://pastebin.ca/raw/1910553

Edit: Patch’s current home is http://yyz.us/bitcoin/patch.bitcoin-listtransactions

Edit2: RPC command has been renamed to ‘xlisttransactions’

Gavin Andresen July 30, 2010 13:18 UTC Source ·

Couple of quick suggestions:

Using the key name “class” will cause problems for, at least, JavaScript, and probably other languages where “class” is a reserved word. “type” or “variety” or some other synonym will cause fewer problems later.

Or, maybe better, get rid of that field and just report credits as positive numbers and debits as negative. And add a separate “generated” field (boolean true or false).

Since each entry refers to a transaction, I’d suggest adding a “tx_id” SHA256 hex-encoded transaction id. Then listtransactions would play nicely with the refundtransaction JSON-RPC extension (and maybe a future gettransactiondetails that let you get transaction parents, which block the transaction was in, and so on).

Code to get that would look something like:

            uint256 tx_hash = transaction.GetHash();
            string tx_id = tx_hash.GetHex();
            mapJSONResponse.push_back(Pair("tx_id", tx_id));
Jeff Garzik (jgarzik) July 30, 2010 18:30 UTC Source ·
Quote from: gavinandresen on July 30, 2010, 4:18:06 AM UTC

Couple of quick suggestions:

Using the key name “class” will cause problems for, at least, JavaScript, and probably other languages where “class” is a reserved word. “type” or “variety” or some other synonym will cause fewer problems later.

Can you be more specific? All mainstream programming language seem sensibly insensitive to abitrary string contents, JS included. String content can certainly include language-reserved keywords and parsing tokens.

Quote from: gavinandresen on July 30, 2010, 4:18:06 AM UTC

Since each entry refers to a transaction, I’d suggest adding a “tx_id” SHA256 hex-encoded transaction id. Then listtransactions would play nicely with the refundtransaction JSON-RPC extension (and maybe a future gettransactiondetails that let you get transaction parents, which block the transaction was in, and so on).

Code to get that would look something like: Code: uint256 tx_hash = transaction.GetHash(); string tx_id = tx_hash.GetHex(); mapJSONResponse.push_back(Pair(“tx_id”, tx_id));

Added, thanks for the suggestion.

Jeff Garzik (jgarzik) July 30, 2010 18:43 UTC Source ·

Here is ‘listtransaction’ version 7: http://gtf.org/garzik/bitcoin/patch.bitcoin-listtransactions

This adds the suggested txn_id field — very nice suggestion, gavin! I wanted a unique transaction id, and now I have one 😊

Satoshi Nakamoto July 30, 2010 19:40 UTC Source ·

What are you needing to use listtransactions for?

The reason I didn’t implement listtransactions is I want to make sure web programmers don’t use it.  It would be very easy to latch onto that for watching for received payments.  There is no reliable way to do it that way and make sure nothing can slip through the cracks.  Until we have solid example code using getreceivedbyaddress and getreceivedbylabel to point to and say “use this! use this! don’t use listtransactions!”, I don’t think we should implement listtransactions.

When we do implement listtransactions, maybe one way to fight that is to make it all text.  It should not break down the fields into e.g. comment, confirmations, credit, debit.  It could be one pretty formatted string like “0/unconfirmed   0:0:0 date   comment      debit 4  credit 0” or something so it’s hard for programmers to do the wrong thing and process it.  It’s only for viewing the status of your server.  I guess that would be kinda annoying for web interfaces that would rather format it into html columns though.

Jeff Garzik (jgarzik) July 30, 2010 19:45 UTC Source ·
Quote from: satoshi on July 30, 2010, 7:40:54 PM UTC

It would be very easy to latch onto that for watching for received payments. There is no reliable way to do it that way and make sure nothing can slip through the cracks. Until we have solid example code using getreceivedbyaddress and getreceivedbylabel to point to and say “use this! use this! don’t use listtransactions!”, I don’t think we should implement listtransactions.

Can you be more specific about “no reliable way”?

The existing facility getreceivedby* is provably unreliable. It combines transactions into summarized totals. When you go to the bank ATM and perform two deposits, the second immediately following the first, you do not see “ATM deposit $80” on your bank statement, you see two transactions with different transaction IDs for “ATM deposit $40”.

I am missing something here? listtransaction seems more reliable than getreceivedby* summaries.

Gavin Andresen July 30, 2010 19:48 UTC Source ·
Quote from: Jeff Garzik on July 30, 2010, 6:30:40 PM UTC
Quote from: gavinandresen on July 30, 2010, 1:18:06 PM UTC

Couple of quick suggestions:

Using the key name “class” will cause problems for, at least, JavaScript, and probably other languages where “class” is a reserved word. “type” or “variety” or some other synonym will cause fewer problems later.

Can you be more specific? All mainstream programming language seem sensibly insensitive to abitrary string contents, JS included. String content can certainly include language-reserved keywords and parsing tokens.

It’s pretty common to turn maps into objects, so you can use syntax like: foo.tx_id … instead of foo[‘tx_id’]. Especially if you’re doing something like passing the data into a templating system (which may ONLY understand the object.field syntax).

And foo.class just doesn’t work out nicely.

Jeff Garzik (jgarzik) July 31, 2010 03:24 UTC Source ·

Updated to version 8 of listtransactions: http://gtf.org/garzik/bitcoin/patch.bitcoin-listtransactions

Includes gavin’s suggestion, renaming ‘class’ to ‘category’.

lachesis July 31, 2010 13:36 UTC Source ·
Quote from: satoshi on July 30, 2010, 7:40:54 PM UTC

The reason I didn’t implement listtransactions is I want to make sure web programmers don’t use it. It would be very easy to latch onto that for watching for received payments. There is no reliable way to do it that way and make sure nothing can slip through the cracks. Until we have solid example code using getreceivedbyaddress and getreceivedbylabel to point to and say “use this! use this! don’t use listtransactions!”, I don’t think we should implement listtransactions.

Why is it unreliable? It provides the same information that the GUI provides, and that works fine for watching for payments…

Quote from: satoshi on July 30, 2010, 7:40:54 PM UTC

When we do implement listtransactions, maybe one way to fight that is to make it all text. It should not break down the fields into e.g. comment, confirmations, credit, debit. It could be one pretty formatted string like “0/unconfirmed 0:0:0 date comment debit 4 credit 0” or something so it’s hard for programmers to do the wrong thing and process it. It’s only for viewing the status of your server. I guess that would be kinda annoying for web interfaces that would rather format it into html columns though.

We really shouldn’t adopt a policy of protecting users from themselves. If we do, there should at least be a “devmode” switch or config line to turn it off.

throughput August 5, 2010 09:12 UTC Source ·
Quote from: satoshi on July 30, 2010, 7:40:54 PM UTC

What are you needing to use listtransactions for?

The reason I didn’t implement listtransactions is I want to make sure web programmers don’t use it. It would be very easy to latch onto that for watching for received payments. There is no reliable way to do it that way and make sure nothing can slip through the cracks. Until we have solid example code using getreceivedbyaddress and getreceivedbylabel to point to and say “use this! use this! don’t use listtransactions!”, I don’t think we should implement listtransactions.

It seems, that you certainly prefer GUI in favor of CLI interfaces. GUI is really awful type of interface, when you have, say 5 nodes with SSH access to them and want to periodically collect some state in a loop like this:

#!/bin/bash
while read host;
do
   ssh "$host" "hostname; bitcoind listtransactions"
   echo =============
done > report.txt < hostlist
Then, report.txt may be emailed to a human.
I hope, that is a valid usecase for you.
knightmb August 5, 2010 10:32 UTC Source ·
Quote from: satoshi on July 30, 2010, 7:40:54 PM UTC

What are you needing to use listtransactions for?

The reason I didn’t implement listtransactions is I want to make sure web programmers don’t use it. It would be very easy to latch onto that for watching for received payments. There is no reliable way to do it that way and make sure nothing can slip through the cracks. Until we have solid example code using getreceivedbyaddress and getreceivedbylabel to point to and say “use this! use this! don’t use listtransactions!”, I don’t think we should implement listtransactions.

I have to agree with Satoshi, other than the extra field of “credit/debit” how is this different than getreceivedbyaddress & getreceivedbylabel? Can someone explain it to me better?

My only beef with all those function calls is that direct IP to IP payments are never shown. As it is right now, if I send a payment via IP to IP, I can’t find it with those commands. I can see the balance is right, but I’m not sure where it came from because neither command will show me any info about the transaction.

If listtransactions (or getreceivedbyaddress & getreceivedbylabel) could list IP to IP transactions, that would be useful.

[edit] I see it will show generated coin, so that is useful actually. Also, the current getreceivedbyaddress & getreceivedbylabel seem to be buggy in which transactions they show to begin with.

ByteCoin August 15, 2010 05:34 UTC Source ·
Quote from: Jeff Garzik on August 09, 2010, 4:51:06 PM UTC

Generated blocks show up as mixed_debit until they “mature”, which is around 120 confirmations. After maturity, you are credited the 50 BTC. This is standard policy for all generated blocks in bitcoin.

I’ve never seen the point of this. Ostensibly it’s to stop the coins being spent until they’re definitely part of the block chain.

Quote from: satoshi on November 22, 2009, 6:34:21 PM UTC

After a block is created, the maturation time of 120 blocks is to make absolutely sure the block is part of the main chain before it can be spent. Your node isn’t doing anything with the block during that time, just waiting for other blocks to be added after yours. You don’t have to be online during that time.

The thing is, if you allowed it to be spent immediately it could only be spent in a branch of the block chain that’s includes it’s own creation. If that branch is not the longest then both the transaction creating it and the transactions spending it will be rolled back anyway! There’s no justification why they should be viewed any more skeptically than a normal transaction especially as they’re so small. A 10000BTC transaction doesn’t take any longer to mature than a 0.01BTC transaction.

ByteCoin