fundingmanager: rebroadcast iniatior's funding txn on restart

This commit alters the behavior of the fundingmanager to
rebroadcast the funding transaction of all pending-open
channels upon restart. This is applied only to single-funder
channels for which we are the initiator, and helps ensure that
funding txns do not get stuck in the face of failures or restarts.
This commit is contained in:
Conner Fromknecht 2018-03-10 17:28:00 -08:00
parent 7ea9e7cf4c
commit b635b83abd
No known key found for this signature in database
GPG Key ID: 39DE78FBE6ACB0EF
1 changed files with 20 additions and 0 deletions

View File

@ -161,6 +161,10 @@ type fundingConfig struct {
// funds from on-chain transaction outputs into Lightning channels.
Wallet *lnwallet.LightningWallet
// PublishTransaction facilitates the process of broadcasting a
// transaction to the network.
PublishTransaction func(*wire.MsgTx) error
// FeeEstimator calculates appropriate fee rates based on historical
// transaction information.
FeeEstimator lnwallet.FeeEstimator
@ -422,6 +426,22 @@ func (f *fundingManager) Start() error {
f.localDiscoverySignals[chanID] = make(chan struct{})
// Rebroadcast the funding transaction for any pending channel
// that we initiated. If this operation fails due to a reported
// double spend, we treat this as an indicator that we have
// already broadcast this transaction. Otherwise, we simply log
// the error as there isn't anything we can currently do to
// recover.
if channel.ChanType == channeldb.SingleFunder &&
channel.IsInitiator {
err := f.cfg.PublishTransaction(channel.FundingTxn)
if err != nil && err != lnwallet.ErrDoubleSpend {
fndgLog.Warnf("unable to rebroadcast funding "+
"txn: %v", err)
}
}
confChan := make(chan *lnwire.ShortChannelID)
timeoutChan := make(chan struct{})