lnwallet+htlcswitch: Introduce a fee buffer.
We take into account a fee buffer of twice the current fee rate of the commitment transaction plus an additional htlc output when we are the opener of the channel hence pay when publishing the commitment transaction. This buffer is not consensus critical because we only consider it when we are in control of adding a new htlc to the state. The goal is to prevent situations where we push our local balance below our channel reserve due to parallel adding of htlcs to the state. Its not a panacea for these situations but until we have __option_simplified_update__ deployed widely on the network its a good precaution to protect against fee spikes and parallel adding of htlcs to the update log. Moreover the way the available balance for a channel changed. We now need to account for a fee buffer when we are the channel opener. Therefore all the tests had to be adopted.
This commit is contained in:
5 files changed
+1197
-218
No files matched your search
@@ -278,14 +278,14 @@ func addTestHtlcs(t *testing.T, remote, local *LightningChannel,
|
||||
PaymentHash: hash,
|
||||
}
|
||||
if htlc.incoming {
|
||||
htlcID, err := remote.AddHTLC(msg, nil)
|
||||
htlcID, err := remote.addHTLC(msg, nil, NoBuffer)
|
||||
require.NoError(t, err, "unable to add htlc")
|
||||
|
||||
msg.ID = htlcID
|
||||
_, err = local.ReceiveHTLC(msg)
|
||||
require.NoError(t, err, "unable to recv htlc")
|
||||
} else {
|
||||
htlcID, err := local.AddHTLC(msg, nil)
|
||||
htlcID, err := local.addHTLC(msg, nil, NoBuffer)
|
||||
require.NoError(t, err, "unable to add htlc")
|
||||
|
||||
msg.ID = htlcID
|
||||
|
||||
Reference in new issue
Block a user