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:
parent
7ea9e7cf4c
commit
b635b83abd
@ -161,6 +161,10 @@ type fundingConfig struct {
|
|||||||
// funds from on-chain transaction outputs into Lightning channels.
|
// funds from on-chain transaction outputs into Lightning channels.
|
||||||
Wallet *lnwallet.LightningWallet
|
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
|
// FeeEstimator calculates appropriate fee rates based on historical
|
||||||
// transaction information.
|
// transaction information.
|
||||||
FeeEstimator lnwallet.FeeEstimator
|
FeeEstimator lnwallet.FeeEstimator
|
||||||
@ -422,6 +426,22 @@ func (f *fundingManager) Start() error {
|
|||||||
|
|
||||||
f.localDiscoverySignals[chanID] = make(chan struct{})
|
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)
|
confChan := make(chan *lnwire.ShortChannelID)
|
||||||
timeoutChan := make(chan struct{})
|
timeoutChan := make(chan struct{})
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user