Bitcoin Forum

Bitcoin => Development & Technical Discussion => Topic started by: ultralisks on January 20, 2014, 09:58:46 PM



Title: Two transactions for "1" operation?
Post by: ultralisks on January 20, 2014, 09:58:46 PM
1 "move" command...

Code:
move('', 'person-5', 2.5, 0, 'play-money')

Creates two transactions...

Code:
[
  {"account"=>"",         "category"=>"move", "time"=>1390254155, "amount"=>-2.5, "otheraccount"=>"person-5", "comment"=>"play-money"},
  {"account"=>"person-5", "category"=>"move", "time"=>1390254155, "amount"=>2.5,  "otheraccount"=>"",         "comment"=>"play-money"}
]

The balances appear correct...

Code:
getbalance('') -> -2.5
getbalance('person-5') -> 2.5

The results look correct, but I don't understand why two transactions are needed for one operation. Is this common practice among "ledger" systems?

I suppose... if I think about the first transaction as a "debit", it makes sense that a corresponding "credit" exists. Is the "otheraccount" attribute used as a form of connecting the two transactions?

Example... if I made a debit object like the one above, minus the "otheraccount" attribute, I would know that a debit was made on account "", but I'd have no indication of where that bitcoin was to be moved to.

Okay. I guess I answered my own question. Cool.

Also, if "account" is meant to mean "from this account", and "otheraccount" is meant to mean "to this account", I think the existing labels are terrible. Not a question, just a complaint.