walletrpc: extract leases marshall function

This commit is contained in:
Joost Jager 2021-03-12 09:17:30 +01:00
parent 37331a5ab2
commit b8e54fffbf

@ -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