lnwallet: ensure ConfirmedBalance holds the coin select mutex

In this commit, we make a new wrapper method around the internal
`WalletController` method to ensure it holds the coin select mutex while
the balance is being computed.
This commit is contained in:
Olaoluwa Osuntokun 2020-08-13 13:01:00 -07:00
parent bb2e7358cf
commit e860a9e23d
No known key found for this signature in database
GPG Key ID: BC13F65E2DC84465

@ -377,6 +377,16 @@ func (l *LightningWallet) Shutdown() error {
return nil
}
// ConfirmedBalance returns the current confirmed balance of the wallet. This
// methods wraps the interal WalletController method so we're able to properly
// hold the coin select mutex while we compute the balance.
func (l *LightningWallet) ConfirmedBalance(confs int32) (btcutil.Amount, error) {
l.coinSelectMtx.Lock()
defer l.coinSelectMtx.Unlock()
return l.WalletController.ConfirmedBalance(confs)
}
// LockedOutpoints returns a list of all currently locked outpoint.
func (l *LightningWallet) LockedOutpoints() []*wire.OutPoint {
outPoints := make([]*wire.OutPoint, 0, len(l.lockedOutPoints))