A bunch of little errors, including a fix to the balancehash computation
[Trubanc.git] / doc / client.txt
blobbe70c014e08d708f1c9625760fe75b0a4684dbd0
1 The sample trubanc client handles multiple users of multiple banks.
2 More details in db.txt, the description of the server database and protocol.
4 $dbdir is the base of the database in the file system. Here's how the
5 client directory is structured.
7 Items in angle brackets are variables
8 Items not in angle brackets are literals
9 "--" comment to the end of the line
10 <dir>/ is a directory
11 <key>=<value> is a file named <key> with contents <value>
12 Items whose names end with "#" are sequence numbers.
13 name:<item> denotes an optional item, passed by position or name
14 Items in parens  are signed. Signature omitted here.
16 $dbdir/
17   privkey/            -- private keys indexed by the hash of their passphrases
18     <hash>=<privkey>
19   pubkey/  -- for fast lookup. Must verify that <id> = hash(<pubkey>)
20     <id>=<pubkey>
21   bank/               -- banks
22     bankid/
23       sha1(<url>)=<bankid>
24     <bankid>/
25       url=<url>       -- web address of the server
26       name=<name>     -- Bank's name
27       tokenid=(<bankid>,tokenid,<tokenid>)
28       regfee=(<bankid>,regfee,<time#>,<tokenid>,<amount>)
29       tranfee=(<bankid>,tranfee,<bankid>,<time#>,<tokenid>,<amount>)
30       fee/
31         spend=(<bankid>,fee|spend,<fee#>,<assetid>,<amount>)[...]
32         selfspend=(<bankid>,fee|spend,<fee#>,<assetid>,<amount>)[...]
33         createasset=(<bankid>,fee|createasset,<fee#>,<assetid>,<amount>)[...]
34       asset/
35         <assetid>=(<bankid>,@asset,(<id>,asset,<bankid>,<assetid>,<scale>,<precision>,<assetname>))
36   session/
37     <sessionhash>=<encrypted_passphrase>
38   account/
39     <id>/
40       session=<sessionhash>
41       preference
42         <pref>=<value>
43       bank
44         <bankid>/
45           time=<time#>[,<time#>]
46           req=<req#>
47           pubkeysig/
48             <id>=(<bankid>,@register,(<id>,register,<bankid>,<pubkey>,name=<name>))
49           contact/
50             <otherid>/
51               nickname=<nickname>
52               note=<note>
53               name=<name>
54               pubkeysig=<pubkeysig>
55           fraction/     -- fractional amounts due to storage fees
56             <assetid>=(<bankid>,@fraction,(<id>,fraction,<bankid>,<time#>,<assetid>,<amount>))
57           balancehash=(<bankid>,@balancehash,(<id>,balancehash,<bankid>,<time#>,<count>,<hash>))
58           balance/
59             <acct>/  -- "main" is the default acct name
60               <assetid>=(<bankid>,@balance,(<id>,balance,<bankid>,<time#>,<assetid>,<amount>,acct:<acct>))
61           outboxhash=(<bankid>,@outboxhash,(<id>,outboxhash,<bankid>,<time#>,<count>,<hash>))
62           outbox/
63             <time2#>=(<bankid>,@spend,(<id>,spend,<bankid>,<time2#>,<id2>,<assetid2>,<amount2>,note:<note2>,acct:<acct2>)).
64                      (<bankid>,@tranfee,(<id>,tranfee,<bankid>,<time2#>,<tokenid>,<amount2fee>))
65             <time3#>=(<bankid>,@spend,(<id>,spend,<bankid>,<time3#>,<id3>,<assetid3>,<amount3>,note:<note3>,acct:<acct3>)).
66                      (<bankid>,@tranfee,(<id>,tranfee,<bankid>,<time3#>,<tokenid>,<amount3fee>))
67           inbox/
68             <time5#>=(<bankid>,inbox,<time5#>,(<id2>,spend|accept,<bankid>,<time2#>,<id>,note:<note22>))
69             <time6#>=(<bankid>,inbox,<time6#>,(<id3>,spend|reject,<bankid>,<time3#>,<id>,note:<note32>))
70             <time7#>=(<bankid>,inbox,<time7#>,(<id4>,spend,<bankid>,<time4#>,<id>,<assetid4>,<amount4>,note:<note4>)).
71                      (<bankid>,@tranfee,(<id>,tranfee,<bankid>,<time4#>,<tokenid>,<amount4fee>))
72           transaction/
73             (<bankid>,@spend,(<id>,spend,<time#>,<id2>,<bankid>,<assetid>,<amount>,note:<note>,acct:<acct>))...
74               or
75             (<bankid,@processinbox,(<id>,processinbox,<bankid>,<time11#>,<time7#>|<time8#>|<time9#>)...
76           history/
77             -- Needs more work. Likely wants to be indexed multiple ways
78             -- and probably organized in directories to keep any one listing
79             -- from getting too long to handle
80             <time>=<message>...
82 // Copyright 2008-2009 Bill St. Clair
84 // Licensed under the Apache License, Version 2.0 (the "License");
85 // you may not use this file except in compliance with the License.
86 // You may obtain a copy of the License at
88 //     http://www.apache.org/licenses/LICENSE-2.0
90 // Unless required by applicable law or agreed to in writing, software
91 // distributed under the License is distributed on an "AS IS" BASIS,
92 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
93 // See the License for the specific language governing permissions
94 // and limitations under the License.