jl777 / SuperNET

57 stars 222 forks source link

listaccount and getbalance rpc shows wrong balance with multiple accounts #82

Open kashifali007 opened 8 years ago

kashifali007 commented 8 years ago

listaccount and getbalance rpc shows wrong balance with multiple accounts

initially account balances are

[11:54]
kashif@ubuntu:~/tests$ ./listaccount_ALL {"result":{"default":0.00078000,"IGUANA":1,"test":0,"test1":0.00002000,"test2":0,"test3":0,"test4":0,"test5":0,"test6":0,"test7":0},"tag":"1590819563650659941"}

[11:55]
when performed sendtoaddress to test3 account, the default account balance has gone vanished

[11:56]
./listaccount_ALL {"result":{"default":0,"IGUANA":1,"test":0,"test1":0,"test2":0.00002000,"test3":0,"test4":0,"test5":0,"test6":0,"test7":0},"tag":"17738116709786867334"}

[11:56]
the listunspent rpc

[11:56]
[ {

"txid":"5e6169ed003ba9a4345e25b5ece53174c952b52ebadf0f8fd2bff8892e447bbc", "vout"1, "address":"RP2tciau3K53XS9hdGY5jjvA2K883mimGX", "scriptPubKey":"76a91496dd5c660363fad9b7668242c08ca3696d273be088ac", "amount":0.00068000, "timestamp":1474568759, "height":1306651, "confirmations":20, "checkind":0, "account":"default", "spendable":true },

{ "txid":"9c40ed620b67c427cdaacd921b73a1a1a974047ac29b3137e0d1b5d34996c071", "vout"1, "address":"RLAyH6zCypa4Ke3Ezokrz93d41shbXi84m", "scriptPubKey":"76a914777c33e91c0cde7c08a7ab3ed07cd4e6a79cb11088ac", "amount":1, "timestamp":1474546885, "height":1306278, "confirmations":393, "checkind":1078, "account":"IGUANA", "spendable":true, "unspent": { "hdrsi":2612, "pkind":114, "unspentind":1078, "prevunspentind":0, "satoshis":"100000000", "txidind":560, "vout":1, "type":2, "fileid":0, "scriptpos":0, "scriptlen":25 }

},

{ "txid":"5e6169ed003ba9a4345e25b5ece53174c952b52ebadf0f8fd2bff8892e447bbc", "vout"0, "address":"RQ3gk2umDggguLWJvZk1Ya6eMjeoYUkNMi", "scriptPubKey":"76a914a1fbfdaa05ba086b8b086ce17bd3104c56dd901c88ac", "amount":0.00002000, "timestamp":1474568759, "height":1306651, "confirmations":20, "checkind":0, "account":"test2", "spendable":true } ]

[11:57]
RP2tciau3K53XS9hdGY5jjvA2K883mimGX belongs to default and it still have some balance "amount":0.00068000,

[11:57]
but listaccount rpc shows it has 0 balance

kashifali007 commented 8 years ago

backwallet rpc results

2016-09-22T19:09:40Z
default= addr=RP2tciau3K53XS9hdGY5jjvA2K883mimGX

2016-09-22T19:09:40Z
IGUANA= addr=RLAyH6zCypa4Ke3Ezokrz93d41shbXi84m

2016-09-22T19:09:40Z
test=3 addr=RN5tXNu5AJweSau2urxKVxDZcmT6z6A2FL

2016-09-22T19:09:40Z
test1= addr=RFfiDHxigsjwHS5NQtvHLEBiTYePr9XgVY

2016-09-22T19:09:40Z
test2= addr=RQ3gk2umDggguLWJvZk1Ya6eMjeoYUkNMi

2016-09-22T19:09:40Z
test3= addr=RPFDh74ymxvH2dgvTzBtCV9A3TkDkLfy7k

2016-09-22T19:09:40Z
test4= addr=RChgjHrBiFAE3ZC8urkhsRYZqKrxa9cb2E 2016-09-22T19:09:40Z
test5= addr=RFCCxFGtdrRxQ7Bg3dF431dYs745pgp1te

2016-09-22T19:09:40Z
test6= addr=RCDNddzib96ApWNnjSPBb4oy583uARfaAR

2016-09-22T19:09:40Z
test7= addr=RGVroEAdWfmkTbdPPSPzSSx8C5vmHgWwfZ

kashifali007 commented 7 years ago

but after restarting the iguana, listaccount rpc works fine.

Steps to Reproduce:

  1. launch iguana and suffice btcd coin curl -s --url "http://127.0.0.1:7778" --data "{\"agent\":\"iguana\",\"method\":\"addcoin\",\"newcoin\":\"BTCD\",\"services\":0,\"portp2p\":14631}"
  2. create a fresh wallet curl -s --url "http://127.0.0.1:7778" --data "{\"agent\":\"bitcoinrpc\",\"method\":\"walletpassphrase\",\"password\":\"your password\",\"timeout\":900}"
  3. create some accounts curl -s --url "http://127.0.0.1:14630" --data "{\"agent\":\"bitcoinrpc\",\"method\":\"getaccountaddress\",\"account\":\"test1\"}"

curl -s --url "http://127.0.0.1:14630" --data "{\"agent\":\"bitcoinrpc\",\"method\":\"getaccountaddress\",\"account\":\"test2\"}"

curl -s --url "http://127.0.0.1:14630" --data "{\"agent\":\"bitcoinrpc\",\"method\":\"getaccountaddress\",\"account\":\"test3\"}"

  1. perform test transaction between any accounts (test1,test2 and test3) with sendtoaddress or sendfrom

curl --url "http://127.0.0.1:14630" --data "{\"agent\":\"bitcoinrpc\",\"method\":\"sendfrom\",\"fromaccount\":\"default\",\"toaddress\":\"RLAyH6zCypa4Ke3Ezokrz93d41shbXi84m\",\"amount\":\"0.00020000\",\"minconf\":\"1\",\"comment\":\"kashifali\",\"comment2\":\"sendingFrom abbottabad\"}"

  1. wait for transaction block to be synced
  2. execute listaccount transaction to see balances of account

here you will be observing wrong balances being displayed but after restart listaccount rpc works well