wallet: don't hold unlock in watch-only mode

If we're running in watch-only mode, there is no unlock possible.
Therefore, we also don't need to prevent any unlocks from happening when
doing coin selection in that mode.
This commit is contained in:
Oliver Gugger 2021-09-08 13:52:06 +02:00 committed by Roy Lee
parent cdf737027b
commit 47a13774bb

View file

@ -1169,17 +1169,27 @@ out:
for { for {
select { select {
case txr := <-w.createTxRequests: case txr := <-w.createTxRequests:
heldUnlock, err := w.holdUnlock() // If the wallet can be locked because it contains
if err != nil { // private key material, we need to prevent it from
txr.resp <- createTxResponse{nil, err} // doing so while we are assembling the transaction.
continue release := func() {}
if !w.Manager.WatchOnly() {
heldUnlock, err := w.holdUnlock()
if err != nil {
txr.resp <- createTxResponse{nil, err}
continue
}
release = heldUnlock.release
} }
tx, err := w.txToOutputs( tx, err := w.txToOutputs(
txr.outputs, txr.keyScope, txr.account, txr.outputs, txr.keyScope, txr.account,
txr.minconf, txr.feeSatPerKB, txr.minconf, txr.feeSatPerKB,
txr.coinSelectionStrategy, txr.dryRun, txr.coinSelectionStrategy, txr.dryRun,
) )
heldUnlock.release()
release()
txr.resp <- createTxResponse{tx, err} txr.resp <- createTxResponse{tx, err}
case <-quit: case <-quit:
break out break out