walletrpc: parameterize output lease duration

This commit is contained in:
Joost Jager committed 2021-03-13 08:45:52 +01:00
1 parent 5ba0f8e355
commit 927f17be32
4 files changed
+141 -115

No files matched your search

+7 -1
View File
@@ -368,12 +368,18 @@ func (w *WalletKit) LeaseOutput(ctx context.Context,
return nil, err
}
// Use the specified lock duration or fall back to the default.
duration := DefaultLockDuration
if req.ExpirationSeconds != 0 {
duration = time.Duration(req.ExpirationSeconds) * time.Second
}
// Acquire the global coin selection lock to ensure there aren't any
// other concurrent processes attempting to lease the same UTXO.
var expiration time.Time
err = w.cfg.CoinSelectionLocker.WithCoinSelectLock(func() error {
expiration, err = w.cfg.Wallet.LeaseOutput(
lockID, *op, DefaultLockDuration,
lockID, *op, duration,
)
return err
})