mirror of
https://github.com/lightningnetwork/lnd.git
synced 2024-11-19 18:10:34 +01:00
btcwallet: ensure output isn't locked by in-memory impl in LeaseOutput
The current implementation of LeaseOutput already checked whether the output had already been leased by the persisted implementation, but not the in-memory one used by lnd internally. Without this check, we could potentially end up with a double spend error if lnd acquired the UTXO internally before the LeaseOutput call.
This commit is contained in:
parent
9b8d51231c
commit
9d9e54f83e
@ -379,6 +379,13 @@ func (b *BtcWallet) UnlockOutpoint(o wire.OutPoint) {
|
||||
// wtxmgr.ErrOutputAlreadyLocked is returned.
|
||||
func (b *BtcWallet) LeaseOutput(id wtxmgr.LockID, op wire.OutPoint) (time.Time,
|
||||
error) {
|
||||
|
||||
// Make sure we don't attempt to double lock an output that's been
|
||||
// locked by the in-memory implementation.
|
||||
if b.wallet.LockedOutpoint(op) {
|
||||
return time.Time{}, wtxmgr.ErrOutputAlreadyLocked
|
||||
}
|
||||
|
||||
return b.wallet.LeaseOutput(id, op)
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user