From b8e54fffbf093ddb53d87f8dd0beecac755a49b0 Mon Sep 17 00:00:00 2001 From: Joost Jager Date: Fri, 12 Mar 2021 09:17:30 +0100 Subject: [PATCH] walletrpc: extract leases marshall function --- lnrpc/walletrpc/walletkit_server.go | 17 ++++++++++++----- 1 file changed, 12 insertions(+), 5 deletions(-) diff --git a/lnrpc/walletrpc/walletkit_server.go b/lnrpc/walletrpc/walletkit_server.go index 45c0b569..1e796716 100644 --- a/lnrpc/walletrpc/walletkit_server.go +++ b/lnrpc/walletrpc/walletkit_server.go @@ -1078,6 +1078,17 @@ func (w *WalletKit) FundPsbt(_ context.Context, } // Convert the lock leases to the RPC format. + rpcLocks := marshallLeases(locks) + + return &FundPsbtResponse{ + FundedPsbt: rawPsbt.Bytes(), + ChangeOutputIndex: changeIndex, + LockedUtxos: rpcLocks, + }, nil +} + +// marshallLeases converts the lock leases to the RPC format. +func marshallLeases(locks []*wtxmgr.LockedOutput) []*UtxoLease { rpcLocks := make([]*UtxoLease, len(locks)) for idx, lock := range locks { rpcLocks[idx] = &UtxoLease{ @@ -1091,11 +1102,7 @@ func (w *WalletKit) FundPsbt(_ context.Context, } } - return &FundPsbtResponse{ - FundedPsbt: rawPsbt.Bytes(), - ChangeOutputIndex: changeIndex, - LockedUtxos: rpcLocks, - }, nil + return rpcLocks } // FinalizePsbt expects a partial transaction with all inputs and outputs fully