Fix unconfirmed balance, accurately report fees #32
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Problem:
Wallet may report incorrect balance before all transactions are confirmed. This is because dust amounts from change are added to fee by default, but not subtracted from the change amount when counting the wallet balance. The reported fee in the confirmation message of simplewallet also does not take this into account.
For example, try sending 1.123456 from one wallet to another.
Suggested fix:
In wallet2::transfer, after transaction details and dust amount from change has been determined,
record dust, fee and change amount according to the dust policy:
-ptx.fee += dust if dust is added to fee
-ptx.dust = dust only if dust is not added to fee and not kept in change according to dust policy;
otherwise ptx.dust = 0.
-change_dts.amount -= dust if dust is added to fee or sent elsewhere according to dust policy
-modify wallet confirmation message to accurately report fees and account for different dust policies
I removed the if statement around the confirm message in simplewallet since I prefer alway-confirm behaviour, but that is just my preference.