Bitcoin Forum
December 05, 2016, 02:42:50 PM *
News: Latest stable version of Bitcoin Core: 0.13.1  [Torrent].
 
   Home   Help Search Donate Login Register  
Pages: [1]
  Print  
Author Topic: Suggestion for listtransactions change wrt account labels...  (Read 1235 times)
CIYAM
Legendary
*
Offline Offline

Activity: 1820


Ian Knowles - CIYAM Lead Developer


View Profile WWW
February 29, 2012, 03:41:19 AM
 #1

I have only recently started playing with bitcoind (which is most likely the way I intend to use Bitcoin in my own software) and got rather confused with the "account" label when using the "listtransactions" command (see https://bitcointalk.org/index.php?topic=66214.0).

After Pieter Wuille's help I was able to understand that the problem I was seeing was that the GUI displays account labels for Sent tx's that have been assigned to the "sent to" address whereas "listtransactions" only shows account labels for "sent" category tx's that have been assigned to the "from" address (or something at least close to that).

So in short you cannot in any easy way get the same output as you see in the Sent tab in the GUI from bitcoind. My proposal is to add an option to listtransactions so you can get the same output (both "account" output and filtering for "send" category tx's to be taken from the "sent to" address). Note of course this is an option and would by default be false.

The change is to the bitcoinrpc command listtransactions whose usage would become as follows:

listtransactions [account] [count=10] [from=0] [usesenttoaddresses=false]

When usesenttoaddresses is set true then the account mapping for "send" category tx's is to the sent to addr (rather than the current behaviour).

Link for suggested commit changes:
https://github.com/ciyam/bitcoin/commits/opt_use_sent_to_addr_for_acc

I don't have an environment set up for compiling Bitcoin (and am flat out doing other work) so for now I would be grateful for any comments or suggestions with the proposed change.


Cheers,

Ian.

With CIYAM anyone can create 100% generated C++ web applications in literally minutes.

GPG Public Key | 1ciyam3htJit1feGa26p2wQ4aw6KFTejU
Advertised sites are not endorsed by the Bitcoin Forum. They may be unsafe, untrustworthy, or illegal in your jurisdiction. Advertise here.
1480948970
Hero Member
*
Offline Offline

Posts: 1480948970

View Profile Personal Message (Offline)

Ignore
1480948970
Reply with quote  #2

1480948970
Report to moderator
1480948970
Hero Member
*
Offline Offline

Posts: 1480948970

View Profile Personal Message (Offline)

Ignore
1480948970
Reply with quote  #2

1480948970
Report to moderator
Pieter Wuille
Legendary
*
qt
Offline Offline

Activity: 1036


View Profile WWW
February 29, 2012, 02:48:12 PM
 #2

After Pieter Wuille's help I was able to understand that the problem I was seeing was that the GUI displays account labels for Sent tx's that have been assigned to the "sent to" address whereas "listtransactions" only shows account labels for "sent" category tx's that have been assigned to the "from" address (or something at least close to that).

No, the *account* they were sent from. Accounts and addresses have nothing to do with eachother, and bitcoin transactions do not have a well-defined "from" address.

aka sipa, core dev team

Tips and donations: 1KwDYMJMS4xq3ZEWYfdBRwYG2fHwhZsipa
Pieter Wuille
Legendary
*
qt
Offline Offline

Activity: 1036


View Profile WWW
February 29, 2012, 02:52:14 PM
 #3

In order to avoid confusion, I'd rather add an extra optional parameter "tolabel", separate from the "account" parameter already present. You really do not want people to confuse accounts and addresses any further (which apparently happened to you).

aka sipa, core dev team

Tips and donations: 1KwDYMJMS4xq3ZEWYfdBRwYG2fHwhZsipa
CIYAM
Legendary
*
Offline Offline

Activity: 1820


Ian Knowles - CIYAM Lead Developer


View Profile WWW
March 01, 2012, 04:34:45 AM
 #4

I guess that my confusion comes from this:

            string account;
            if (pwalletMain->mapAddressBook.count(r.first))
                account = pwalletMain->mapAddressBook[r.first];

this is the code used to provide the "account" in the "receive" category tx's.

I gather now that in fact the string variable is perhaps incorrectly named (should be called "label" I guess).

In that case sure I will change both the optional argument to "tolabel" and will fix up the above code also.

With CIYAM anyone can create 100% generated C++ web applications in literally minutes.

GPG Public Key | 1ciyam3htJit1feGa26p2wQ4aw6KFTejU
CIYAM
Legendary
*
Offline Offline

Activity: 1820


Ian Knowles - CIYAM Lead Developer


View Profile WWW
March 01, 2012, 04:43:43 AM
 #5

Understand that the main thing I am trying to do is implement a General Ledger application which will work with Bitcoin via bitcoind but I would like it to be compatible also with the GUI.

I am also thinking the changes might need to go a little further with the address map (or "label") entries being added for the "to" address when you do a "sendfrom" via bitcoind.

With CIYAM anyone can create 100% generated C++ web applications in literally minutes.

GPG Public Key | 1ciyam3htJit1feGa26p2wQ4aw6KFTejU
CIYAM
Legendary
*
Offline Offline

Activity: 1820


Ian Knowles - CIYAM Lead Developer


View Profile WWW
March 02, 2012, 09:19:35 AM
 #6

I am also thinking the changes might need to go a little further with the address map (or "label") entries being added for the "to" address when you do a "sendfrom" via bitcoind.

I see there is a [comment-to] option for the "sendfrom" - do the comments have any relation to the labels?

With CIYAM anyone can create 100% generated C++ web applications in literally minutes.

GPG Public Key | 1ciyam3htJit1feGa26p2wQ4aw6KFTejU
CIYAM
Legendary
*
Offline Offline

Activity: 1820


Ian Knowles - CIYAM Lead Developer


View Profile WWW
March 06, 2012, 06:21:22 AM
 #7

Please let know me if I'm wrong yet again but would it be correct that for Bitcoin (as far as the RPC interface goes) an "account" is really just a way to divide up the wallet for purposes of perhaps providing a wallet service or similar?

In which case for sure I don't want to confuse accounts as in GL accounts with that. Perhaps it is unfortunate that "getaccount" given an external address returns the "label" that you can put from the GUI (and that "setaccount" even works for external addresses as these by above said definition are *not* accounts).

In any case I think I can work out what I need (by calling "getaccount" and "setaccount") to have the GUI and bitcoind information become aligned (albeit I cannot get what I want out of listtransactions without the modification I mentioned).

With CIYAM anyone can create 100% generated C++ web applications in literally minutes.

GPG Public Key | 1ciyam3htJit1feGa26p2wQ4aw6KFTejU
Gavin Andresen
Legendary
*
qt
Offline Offline

Activity: 1652


Chief Scientist


View Profile WWW
March 06, 2012, 04:35:20 PM
 #8

You should be able to build your GL on top of the accounts feature of bitcoind.

The 'validateaddress' RPC call will tell you the account associated with an address and whether or not it is an address that belongs to you or is external.

Combined with the 'sendfrom' and 'setaccount' RPC calls, you should be able to create a proper general-ledger-type application where all transactions have well-defined "from" and "to" accounts.

Example of one way to do it using my testnet-in-a-box setup:

1. Create a couple of accounts:
Code:
./bitcoind -testnet getaccountaddress "cash"
# ... send some coin to the "cash" account from ... somewhere ...
./bitcoind -testnet setaccount mzDfbJCELPQzHMjJ6ZLFRUxT51FdKezbEZ "hosting_expenses"
# the mzDfb... address would come from my web hosting company, of course

2. Now pay for web hosting out of "cash"
Code:
./bitcoind -testnet sendfrom "cash" mzDfbJCELPQzHMjJ6ZLFRUxT51FdKezbEZ 10

3. All the information about the transaction (from and to accounts) is available, but you'll need 2 RPC calls to get it:
Code:
$ ./bitcoind -testnet listtransactions "cash" 1
[
    {
        "account" : "cash",
        "address" : "mzDfbJCELPQzHMjJ6ZLFRUxT51FdKezbEZ",
        "category" : "send",
        "amount" : -10.00000000,
        "fee" : 0.00000000,
        "confirmations" : 0,
        "txid" : "53a681fd7f6b2cb542d69cb72d18ca780d42df63fcc00cf46b19499ab75540b3",
        "time" : 1331050826
    }
]
$ ./bitcoind -testnet validateaddress mzDfbJCELPQzHMjJ6ZLFRUxT51FdKezbEZ
{
    "isvalid" : true,
    "address" : "mzDfbJCELPQzHMjJ6ZLFRUxT51FdKezbEZ",
    "ismine" : false,
    "account" : "hosting_expenses"
}

The GUI has no notion of a "sendfrom account", so any coins send from the GUI won't play nicely with whatever system you create using the RPC interface. The expectation is the vast majority of GUI users won't go to the trouble of creating a general ledger system to keep track of where their bitcoins are coming from and going to.

How often do you get the chance to work on a potentially world-changing project?
Gavin Andresen
Legendary
*
qt
Offline Offline

Activity: 1652


Chief Scientist


View Profile WWW
March 06, 2012, 04:39:44 PM
 #9

PS: The 'accounts' feature doesn't scale well past a dozen or two accounts each with a few hundred transactions. It could (need to add some indices to the database so looking up transactions by account and/or time is quick), but doing that work hasn't been a high development priority.

How often do you get the chance to work on a potentially world-changing project?
CIYAM
Legendary
*
Offline Offline

Activity: 1820


Ian Knowles - CIYAM Lead Developer


View Profile WWW
March 07, 2012, 02:28:37 AM
 #10

Thanks Gavin for the information (hadn't got to 'validateaddress' yet but it looks very useful).

The GUI has no notion of a "sendfrom account", so any coins send from the GUI won't play nicely with whatever system you create using the RPC interface.

True although the "label" (or whatever the correct term) that you can put in the address book for the sends (after sending) will appear if you do a 'getaccount' (and am guessing for 'validateaddress' also) so I think it is possible to get everything to fit together albeit a little clumsily from the GUI side (IMO would be nicer if the "label" was available in the send dialog).

I am hoping all my GUI tx's will be able to be picked up by my GL application without further manual adjustments. Smiley

With CIYAM anyone can create 100% generated C++ web applications in literally minutes.

GPG Public Key | 1ciyam3htJit1feGa26p2wQ4aw6KFTejU
Pages: [1]
  Print  
 
Jump to:  

Sponsored by , a Bitcoin-accepting VPN.
Powered by MySQL Powered by PHP Powered by SMF 1.1.19 | SMF © 2006-2009, Simple Machines Valid XHTML 1.0! Valid CSS!