autopilot: use subtractFees when funding channel

To make the autopilot able to account for fees, we let it use the
subtractFees option when opening channels.

This makes sure that each channel we attempt to open will eat at most
Amt out of our budget. Previously fees would eat into our funds in
addition, causing us to deplete our funds more than expected on each
channel opening.
This commit is contained in:
Johan T. Halseth 2019-07-11 13:14:38 +02:00
parent 0405703019
commit bf7f392c11
No known key found for this signature in database
GPG Key ID: 15BAADA29DA20D26
3 changed files with 7 additions and 4 deletions

View File

@ -584,6 +584,7 @@ func (a *Agent) openChans(availableFunds btcutil.Amount, numChans uint32,
// Use the heuristic to calculate a score for each node in the
// graph.
log.Debugf("Scoring %d nodes for chan_size=%v", len(nodes), chanSize)
scores, err := a.cfg.Heuristic.NodeScores(
a.cfg.Graph, totalChans, chanSize, nodes,
)

View File

@ -188,10 +188,11 @@ func init() {
// open a channel within the graph to a target peer, close targeted channels,
// or add/remove funds from existing channels via a splice in/out mechanisms.
type ChannelController interface {
// OpenChannel opens a channel to a target peer, with a capacity of the
// specified amount. This function should un-block immediately after
// the funding transaction that marks the channel open has been
// broadcast.
// OpenChannel opens a channel to a target peer, using at most amt
// funds. This means that the resulting channel capacity might be
// slightly less to account for fees. This function should un-block
// immediately after the funding transaction that marks the channel
// open has been broadcast.
OpenChannel(target *btcec.PublicKey, amt btcutil.Amount) error
// CloseChannel attempts to close out the target channel.

View File

@ -100,6 +100,7 @@ func (c *chanController) OpenChannel(target *btcec.PublicKey,
req := &openChanReq{
targetPubkey: target,
chainHash: *activeNetParams.GenesisHash,
subtractFees: true,
localFundingAmt: amt,
pushAmt: 0,
minHtlc: minHtlc,