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 {
select {
case txr := <-w.createTxRequests:
heldUnlock, err := w.holdUnlock()
if err != nil {
txr.resp <- createTxResponse{nil, err}
continue
// If the wallet can be locked because it contains
// private key material, we need to prevent it from
// doing so while we are assembling the transaction.
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(
txr.outputs, txr.keyScope, txr.account,
txr.minconf, txr.feeSatPerKB,
txr.coinSelectionStrategy, txr.dryRun,
)
heldUnlock.release()
release()
txr.resp <- createTxResponse{tx, err}
case <-quit:
break out