joinmarket icon indicating copy to clipboard operation
joinmarket copied to clipboard

History and balance mismatch

Open yhaenggi opened this issue 8 years ago • 21 comments

I've tried the history mode of wallet-tool and it came up with this (values replaced with meaningful text)

BUG ERROR: wallet balance (BIGGERNUMBER) does not match balance from history (SMALLERNUMBER)
BUG ERROR: wallet utxo count (HIGHERCOUNT) does not match utxo count from history (LOWERCOUNT)

yhaenggi avatar May 23 '16 08:05 yhaenggi

I had this while testing. It happened to me because two joinmarket transactions actually belonged to the "" account instead of "joinmarket-wallet-whatever".

When I made it search "" as well as the other account, all transactions appears.

https://github.com/JoinMarket-Org/joinmarket/blob/master/wallet-tool.py#L293

You could try debugging by adding a likely wallet name to the list of accounts to search. Maybe you used two joinmarket wallets in the lifetime of that wallet.dat. Ideally there's be a way to obtain all wallet transactions regardless of which account they're in.

chris-belcher avatar May 23 '16 11:05 chris-belcher

I havent used multiple joinmarket wallets. there is only "" and "joinmarket-wallet-random" as accounts.

yhaenggi avatar May 23 '16 12:05 yhaenggi

i just checked and saw i deleted the yigen logfile some time ago, i'll have to recover it for proper results. this would cause less utxo in history and also much less balance (which both are the case). im closing this therefore, sry for the trouble.

yhaenggi avatar May 23 '16 14:05 yhaenggi

wallet-tool history doesnt read from the yigen log file at all. It only reads from the blockchain. You can delete your log file and wallet-tool history will work in exactly the same way

Reopening

chris-belcher avatar May 24 '16 00:05 chris-belcher

i also have a case where this happend, i moved some coins via the sendpayment.py and the transaction is missing in the history and now the balance differ

Onefox avatar Aug 23 '16 19:08 Onefox

It's confirmed I assume(?) If you open Bitcoin-Qt, does the transaction appear in the transactions tab?

chris-belcher avatar Aug 24 '16 11:08 chris-belcher

Yes it is, i am on console only, but with the normal joinmarket command where i can see all the addresses in the different mix depths and balances. There is the right balance. Only with the history command i get the wrong one and this error.

Its console only i don't think bitcoin-qt would work there or?

Onefox avatar Aug 24 '16 12:08 Onefox

I'd say I see it ~60% of the time when running python wallet-tool.py wallet.json history.

Also, which might be related(?), when I was trying to add notifications somewhat like here. I've noticed that my confirm_callback() fn is never called, even though I do have coinjoins happening.

Basically, while potentially earned is logged many times:

$ grep "potentially earned" logs/*.log | wc -l
A_NONZERO_NUMBER

then just earned, that should be logged by this happens never…

$ grep "earned" logs/*.log | grep -v "potentially" | wc -l
0

meeDamian avatar Dec 23 '16 19:12 meeDamian

That's very strange mmDamian, obviously you're getting unconfirmed notifies but not confirmed notifies, so -walletnotify isn't the problem. I wonder if there's a crash or bug somewhere in confirm_fun(), maybe your log file can tell us what happened?

chris-belcher avatar Dec 25 '16 15:12 chris-belcher

@chris-belcher Here are some scrubbed logs that do contain potentially earned, but not earned.

Also, something I should probably also mention, is that I'm using pruned Bitcoin Core.

meeDamian avatar Dec 25 '16 17:12 meeDamian

@meeDamian Double check your -walletnotify config. I'm 80% sure that's the problem. Since the 'potentially earned' print can happen even if your -walletnotify config is wrong.

I use a pruned node too, that shouldn't make a difference.

chris-belcher avatar Dec 26 '16 22:12 chris-belcher

This is my ~/.bitcoin/bitcoin.conf (minus user and password):

$ grep -v rpc ~/.bitcoin/bitcoin.conf
server=1
prune=10240
dbcache=1111
daemon=1

# for JoinMarket
walletnotify=curl -sI --connect-timeout 1 http://localhost:62602/walletnotify?%s
alertnotify=curl -sI --connect-timeout 1 http://localhost:62602/alertnotify?%s

I've restarted all: bitcoin node, joinmarket and machine couple of times since applying that config.

meeDamian avatar Dec 29 '16 07:12 meeDamian

I don't know but for some reason the notify messages are not reaching joinmarket.

chris-belcher avatar Dec 29 '16 14:12 chris-belcher

Ok, my machine was allergic to localhost apparently. Swapping it with 127.0.0.1 in walletnotify and alertnotify and adding notify_host = 127.0.0.1 to joinmarket.cfg did the trick.

@chris-belcher But getting back to the original problem, do you thinks this could've been the cause behind balances mismatch?

meeDamian avatar Dec 30 '16 06:12 meeDamian

I doubt it, since wallet-tool history doesn't depend on walletnotify working.

If the balance mismatch happens every time, try changing this line https://github.com/JoinMarket-Org/joinmarket/blob/master/wallet-tool.py#L310

EDIT: it moves over time, here's the link with the SHA https://github.com/JoinMarket-Org/joinmarket/blob/8c2b6d83dfddb85451d185e64f0fe4df62d5c54e/wallet-tool.py#L399

Make it for wn in [wallet_name, "", "*"]:

and see if it fixes it

chris-belcher avatar Dec 30 '16 14:12 chris-belcher

I only have one wallet there.

After doing some digging through, it seems that it only shows if there's a tx in-between being broadcast and confirmed. My best guess would be that, while the wallet, based on its memory pool(?), has already increased its total balance, the relevant transaction is not yet returned by listtransactions, hence not yet summed up in balance, making total_wallet_balance > balance. Same would apply to utxos.

In which case only the BUG ERROR: wording would be misleading :)

meeDamian avatar Dec 30 '16 15:12 meeDamian

I just hit this. I had a previous wallet, but I immediately deleted it without making any transactions at all. Adding * to the wallets does not help.

It began after the very first coinjoin. It happens every time I run history. I don't know if it will persist after further transactions.

The relevant log from yield-generator-basic.py on commit 05b758cf9e12, various data replaced with dashes.

 -----,--- [MCThread    ] [INFO ]  obtained tx
{'ins': [{'outpoint': {'hash':
-----
}
 -----,--- [MCThread    ] [INFO ]  potentially earned = ---
 -----,--- [MCThread    ] [INFO ]  goodtx
 -----,--- [CoreNotifyTh] [INFO ]  started bitcoin core notify listening thread, host=localhost port=62602
 ---,--- [CoreNotifyTh] [INFO ]  saw tx on network, removed_utxos=
{---': {'address': u'---',
                                                                        'value': ---}}
 ---,--- [CoreNotifyTh] [INFO ]  modifying orders. to_cancel=[]
to_announce=[{'ordertype': 'reloffer', 'oid': 0, 'minsize': ---, 'txfee': ---, 'maxsize': ---, 'cjfee': '---'}]

ian-kelling avatar Jan 09 '17 23:01 ian-kelling

Update: I ran history again after at least one more coinjoin, and did not hit this error.

ian-kelling avatar Jan 11 '17 05:01 ian-kelling

We should at least make the error message less scary.

chris-belcher avatar May 06 '17 02:05 chris-belcher

@chris-belcher not to be a nag, but could you please use SHAs when linking to GH since master moves over time? Per: https://github.com/JoinMarket-Org/joinmarket/issues/534#issuecomment-269777534

Thanks, you rock!

mecampbellsoup avatar Dec 22 '17 18:12 mecampbellsoup

That line is this: https://github.com/JoinMarket-Org/joinmarket/blob/8c2b6d83dfddb85451d185e64f0fe4df62d5c54e/wallet-tool.py#L399

I also edited that comment above.

chris-belcher avatar Dec 24 '17 12:12 chris-belcher