helium / blockchain-core

Apache License 2.0
214 stars 85 forks source link

handling txn fees in balance clearing #1398

Closed jeffgrunewald closed 2 years ago

jeffgrunewald commented 2 years ago

This change should allow the proper handling of transaction fees when making a balance clearing transaction. In this case, the paying address's DC ledger entry balance is checked to cover the expected fee and there is a shortfall, attempts to make up the difference by implicit burning HNT. This is contrary to the previous behavior wherein only a DC balance or an implicit burn would be used to cover transaction fees.

This also properly handling converting the fee to HNT in bones when calculating the paying transaction's balance to deduct and send when making a balance clearing transaction. The previous incorrect behavior was to deduct the exact amount of the transaction fee from the payment amount.

jeffgrunewald commented 2 years ago

Assuming this is merged I will apply the same necessary changes to the balance clearing payment handling in https://github.com/helium/blockchain-core/pull/1377

andymck commented 2 years ago

I implemented the txn fees and am pretty sure that it was deliberate at the time to not split the fee across DC and HNT but to do one or the other. Is there a driver for this change ? I mean it probably is better to split it but I would like to understand the driver

jeffgrunewald commented 2 years ago

@andymck the drive for the change was just that I noticed it when I was fixing the way balance clearing txns handle deducting fees and the response seemed to be that it was a desirable change but I’m not sure how closely anyone has looked at it since I asked in the channel. Will wait for authoritative word but can easily back that part out if I was mistaken.