Fixes #311
The issue was that the "delete invoice" call didn't work and this was not noticed because the error wasn't logged.
We reproduced this but the real fix is to postpone the invoice db entry creation until after preliminary checks have taken place (amount, user balance, invoice expiry (todo #315 )).
In order to do this, this PR does the following things:
Move the duplicated BalanceCheck code to the service package
Move the CalcFeeLimit code from the invoice struct to the service struct
Move the AddOutgoingInvoice call in all 4 payment controllers behind the BalanceCheck block, which should look the same everywhere.
Add a test to make sure the invoice isn't there when we try to pay an invoice that we can't afford. You can verify that this test currently fails on main by cherry-picking commit 03a20148322005e952ef4105bbe5635f9edcf104
Fixes #311 The issue was that the "delete invoice" call didn't work and this was not noticed because the error wasn't logged. We reproduced this but the real fix is to postpone the invoice db entry creation until after preliminary checks have taken place (amount, user balance, invoice expiry (todo #315 )).
In order to do this, this PR does the following things:
BalanceCheck
code to the service packageCalcFeeLimit
code from the invoice struct to the service structAddOutgoingInvoice
call in all 4 payment controllers behind theBalanceCheck
block, which should look the same everywhere.