lnwallet + funding: move funding tx publish to fundingmgr
This commit moves the responsibility for publishing the funding tx to the network from the wallet to the funding manager. This is done to distinguish the failure of completing the reservation within the wallet and failure of publishing the transaction. Earlier we could fail to broadcast the transaction, which would cause us to fail the funding flow. This is not something we can do directly, since the CompeteReservation call will mark the channel IsPending in the databas.e
This commit is contained in:
3 files changed
+35
-26
No files matched your search
+7
-17
@@ -8,20 +8,20 @@ import (
|
||||
"sync"
|
||||
"sync/atomic"
|
||||
|
||||
"github.com/btcsuite/btcd/blockchain"
|
||||
"github.com/btcsuite/btcd/chaincfg/chainhash"
|
||||
"github.com/btcsuite/btcutil/hdkeychain"
|
||||
"github.com/davecgh/go-spew/spew"
|
||||
"github.com/lightningnetwork/lnd/channeldb"
|
||||
"github.com/lightningnetwork/lnd/keychain"
|
||||
"github.com/lightningnetwork/lnd/lnwire"
|
||||
"github.com/btcsuite/btcd/blockchain"
|
||||
"github.com/btcsuite/btcd/chaincfg/chainhash"
|
||||
"github.com/btcsuite/btcutil/hdkeychain"
|
||||
|
||||
"github.com/lightningnetwork/lnd/shachain"
|
||||
"github.com/btcsuite/btcd/btcec"
|
||||
"github.com/btcsuite/btcd/txscript"
|
||||
"github.com/btcsuite/btcd/wire"
|
||||
"github.com/btcsuite/btcutil"
|
||||
"github.com/btcsuite/btcutil/txsort"
|
||||
"github.com/lightningnetwork/lnd/shachain"
|
||||
)
|
||||
|
||||
const (
|
||||
@@ -262,15 +262,15 @@ type LightningWallet struct {
|
||||
// is removed from limbo. Each reservation is tracked by a unique
|
||||
// monotonically integer. All requests concerning the channel MUST
|
||||
// carry a valid, active funding ID.
|
||||
fundingLimbo map[uint64]*ChannelReservation
|
||||
limboMtx sync.RWMutex
|
||||
fundingLimbo map[uint64]*ChannelReservation
|
||||
limboMtx sync.RWMutex
|
||||
|
||||
// lockedOutPoints is a set of the currently locked outpoint. This
|
||||
// information is kept in order to provide an easy way to unlock all
|
||||
// the currently locked outpoints.
|
||||
lockedOutPoints map[wire.OutPoint]struct{}
|
||||
|
||||
quit chan struct{}
|
||||
quit chan struct{}
|
||||
|
||||
wg sync.WaitGroup
|
||||
|
||||
@@ -1086,16 +1086,6 @@ func (l *LightningWallet) handleFundingCounterPartySigs(msg *addCounterPartySigs
|
||||
return
|
||||
}
|
||||
|
||||
walletLog.Infof("Broadcasting funding tx for ChannelPoint(%v): %v",
|
||||
res.partialState.FundingOutpoint, spew.Sdump(fundingTx))
|
||||
|
||||
// Broadcast the finalized funding transaction to the network.
|
||||
if err := l.PublishTransaction(fundingTx); err != nil {
|
||||
msg.err <- err
|
||||
msg.completeChan <- nil
|
||||
return
|
||||
}
|
||||
|
||||
msg.completeChan <- res.partialState
|
||||
msg.err <- nil
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user