@@ -9,8 +9,8 @@ use cln_lsps::lsps0::{
99} ;
1010use cln_lsps:: lsps2:: cln:: tlv:: encode_tu64;
1111use cln_lsps:: lsps2:: cln:: {
12- HtlcAcceptedRequest , HtlcAcceptedResponse , InvoicePaymentRequest , TLV_FORWARD_AMT ,
13- TLV_PAYMENT_SECRET ,
12+ HtlcAcceptedRequest , HtlcAcceptedResponse , InvoicePaymentRequest , OpenChannelRequest ,
13+ TLV_FORWARD_AMT , TLV_PAYMENT_SECRET ,
1414} ;
1515use cln_lsps:: lsps2:: model:: {
1616 compute_opening_fee, Lsps2BuyRequest , Lsps2BuyResponse , Lsps2GetInfoRequest ,
@@ -636,15 +636,11 @@ async fn on_openchannel(
636636 p : cln_plugin:: Plugin < State > ,
637637 v : serde_json:: Value ,
638638) -> Result < serde_json:: Value , anyhow:: Error > {
639- #[ derive( Deserialize ) ]
640- struct Request {
641- id : String ,
642- }
639+ let req: OpenChannelRequest = ok_or_continue ! (
640+ serde_json:: from_value( v) . context( "failed to deserialize open_channel request JSON" )
641+ ) ;
643642
644- let req: Request = ok_or_continue ! ( serde_json:: from_value(
645- v. get( "openchannel" ) . unwrap( ) . clone( )
646- )
647- . context( "failed to deserialize open_channel request JSON" ) ) ;
643+ // Fixme: Check that channel parameters are as negotiated.
648644
649645 let dir = p. configuration ( ) . lightning_dir ;
650646 let rpc_path = Path :: new ( & dir) . join ( & p. configuration ( ) . rpc_file ) ;
@@ -656,7 +652,7 @@ async fn on_openchannel(
656652 key : Some ( vec ! [
657653 "lsps" . to_string( ) ,
658654 "client" . to_string( ) ,
659- req. id. clone( ) ,
655+ req. openchannel . id. clone( ) ,
660656 ] ) ,
661657 } ;
662658 let ds_res = ok_or_continue ! ( cln_client
@@ -665,10 +661,17 @@ async fn on_openchannel(
665661 . context( "failed to get datastore record" ) ) ;
666662
667663 if let Some ( _rec) = ds_res. datastore . iter ( ) . next ( ) {
668- info ! ( "Allowing zero-conf channel from LSP {}" , & req. id) ;
664+ info ! (
665+ "Allowing zero-conf channel from LSP {}" ,
666+ & req. openchannel. id
667+ ) ;
669668 let ds_req = DeldatastoreRequest {
670669 generation : None ,
671- key : vec ! [ "lsps" . to_string( ) , "client" . to_string( ) , req. id. clone( ) ] ,
670+ key : vec ! [
671+ "lsps" . to_string( ) ,
672+ "client" . to_string( ) ,
673+ req. openchannel. id. clone( ) ,
674+ ] ,
672675 } ;
673676 if let Some ( err) = cln_client. call_typed ( & ds_req) . await . err ( ) {
674677 // We can do nothing but report that there was an issue deleting the
0 commit comments