@@ -46,6 +46,7 @@ import (
4646 "github.com/lightninglabs/loop"
4747 "github.com/lightninglabs/loop/labels"
4848 "github.com/lightninglabs/loop/loopdb"
49+ "github.com/lightninglabs/loop/loopdb/sqlc"
4950 clientrpc "github.com/lightninglabs/loop/looprpc"
5051 "github.com/lightninglabs/loop/swap"
5152 "github.com/lightningnetwork/lnd/clock"
@@ -229,13 +230,15 @@ type Config struct {
229230 //
230231 // NOTE: the params are encoded using `proto.Marshal` over an RPC
231232 // request.
232- PutLiquidityParams func (ctx context.Context , params []byte ) error
233+ PutLiquidityParams func (ctx context.Context , assetId string ,
234+ params []byte ) error
233235
234236 // FetchLiquidityParams reads the serialized `Parameters` from db.
235237 //
236238 // NOTE: the params are decoded using `proto.Unmarshal` over a
237239 // serialized RPC request.
238- FetchLiquidityParams func (ctx context.Context ) ([]byte , error )
240+ FetchLiquidityParams func (ctx context.Context ) ([]sqlc.LiquidityParam ,
241+ error )
239242}
240243
241244// Manager contains a set of desired liquidity rules for our channel
@@ -392,7 +395,8 @@ func (m *Manager) saveParams(ctx context.Context, req proto.Message) error {
392395 }
393396
394397 // Save the params on disk.
395- if err := m .cfg .PutLiquidityParams (ctx , paramsBytes ); err != nil {
398+ err = m .cfg .PutLiquidityParams (ctx , swap .DefaultBtcAssetID , paramsBytes )
399+ if err != nil {
396400 return fmt .Errorf ("failed to save params: %v" , err )
397401 }
398402
@@ -404,19 +408,24 @@ func (m *Manager) saveParams(ctx context.Context, req proto.Message) error {
404408func (m * Manager ) loadParams (ctx context.Context ) (
405409 * clientrpc.LiquidityParameters , error ) {
406410
407- paramsBytes , err := m .cfg .FetchLiquidityParams (ctx )
411+ params , err := m .cfg .FetchLiquidityParams (ctx )
408412 if err != nil {
409413 return nil , fmt .Errorf ("failed to read params: %v" , err )
410414 }
411415
412416 // Return early if there's nothing saved.
413- if paramsBytes == nil {
417+ if params == nil {
414418 return nil , nil
415419 }
416420
421+ if len (params ) != 1 {
422+ return nil , fmt .Errorf ("expected 1 param, got %v" , len (params ))
423+ }
424+
417425 // Unmarshal the params.
418426 req := & clientrpc.LiquidityParameters {}
419- err = proto .Unmarshal (paramsBytes , req )
427+
428+ err = proto .Unmarshal (params [0 ].Params , req )
420429 if err != nil {
421430 return nil , fmt .Errorf ("failed to unmarshal params: %v" , err )
422431 }
0 commit comments