From f70c9191648eb33ac38caeac5eb6e037a82293d9 Mon Sep 17 00:00:00 2001 From: yyforyongyu Date: Thu, 1 Aug 2024 02:44:48 +0800 Subject: [PATCH] lnrpc: fetch utxo info in `lockInputs` This commit prepares the following commit where we change the `LeaseOutput` to be more efficient. --- lnrpc/walletrpc/psbt.go | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/lnrpc/walletrpc/psbt.go b/lnrpc/walletrpc/psbt.go index 19b102473..4d3e8641a 100644 --- a/lnrpc/walletrpc/psbt.go +++ b/lnrpc/walletrpc/psbt.go @@ -56,7 +56,13 @@ func lockInputs(w lnwallet.WalletController, }, } - expiration, pkScript, value, err := w.LeaseOutput( + // Get the details about this outpoint. + utxo, err := w.FetchOutpointInfo(&lock.Outpoint) + if err != nil { + return nil, fmt.Errorf("fetch outpoint info: %w", err) + } + + expiration, _, _, err := w.LeaseOutput( lock.LockID, lock.Outpoint, chanfunding.DefaultLockDuration, ) @@ -80,8 +86,8 @@ func lockInputs(w lnwallet.WalletController, } lock.Expiration = expiration - lock.PkScript = pkScript - lock.Value = int64(value) + lock.PkScript = utxo.PkScript + lock.Value = int64(utxo.Value) locks[idx] = lock }