diff --git a/cln-integration/src/main.rs b/cln-integration/src/main.rs index 8f7bab5..d8b1a6e 100644 --- a/cln-integration/src/main.rs +++ b/cln-integration/src/main.rs @@ -91,7 +91,8 @@ async fn test_ocean_simple_payout() -> anyhow::Result<()> { ); if payout.is_err() { let _ = ocean_ln.print_logs()?; - payout.unwrap(); } + let payout = payout.unwrap(); + log::info!("ocean-pay response {}", serde_json::to_string_pretty(&payout)?); Ok(()) } diff --git a/go.mod b/go.mod index 84ea3bd..3308cd9 100644 --- a/go.mod +++ b/go.mod @@ -4,12 +4,12 @@ go 1.18 require ( github.com/mitchellh/mapstructure v1.5.0 - github.com/vincenzopalazzo/cln4go/client v0.0.0-20240225150542-fa830ceeae65 - github.com/vincenzopalazzo/cln4go/plugin v0.0.0-20240225150542-fa830ceeae65 + github.com/vincenzopalazzo/cln4go/client v0.0.0-20240229133517-f6b60e643fc6 + github.com/vincenzopalazzo/cln4go/plugin v0.0.0-20240229133517-f6b60e643fc6 ) require ( github.com/vincenzopalazzo/cln4go v0.0.1-beta.8 // indirect - github.com/vincenzopalazzo/cln4go/comm v0.0.0-20240225150542-fa830ceeae65 // indirect + github.com/vincenzopalazzo/cln4go/comm v0.0.0-20240229123929-875e15a5a917 // indirect github.com/vincenzopalazzo/cpstl/go v0.0.0-20221204131531-d0659db4dd2a // indirect ) diff --git a/go.sum b/go.sum index 1b4b309..494332f 100644 --- a/go.sum +++ b/go.sum @@ -8,6 +8,8 @@ github.com/vincenzopalazzo/cln4go/client v0.0.0-20230413130716-35626bd3b34b h1:W github.com/vincenzopalazzo/cln4go/client v0.0.0-20230413130716-35626bd3b34b/go.mod h1:7C64iH2eVEE7WkIMQa8fmtQmFNzprDt6rIZOxG57Thg= github.com/vincenzopalazzo/cln4go/client v0.0.0-20240225150542-fa830ceeae65 h1:fW3un3bcVFgWc1+n9U/rU49JwKol6LPnvaG/s9Drlto= github.com/vincenzopalazzo/cln4go/client v0.0.0-20240225150542-fa830ceeae65/go.mod h1:7C64iH2eVEE7WkIMQa8fmtQmFNzprDt6rIZOxG57Thg= +github.com/vincenzopalazzo/cln4go/client v0.0.0-20240229133517-f6b60e643fc6 h1:eBhxX7nL8Jz/QNvC6ChHUorU8pLXoRj/e4xMTHGe2UA= +github.com/vincenzopalazzo/cln4go/client v0.0.0-20240229133517-f6b60e643fc6/go.mod h1:7C64iH2eVEE7WkIMQa8fmtQmFNzprDt6rIZOxG57Thg= github.com/vincenzopalazzo/cln4go/comm v0.0.0-20220802085837-fb816fecb890 h1:NvP9FlygyCWYaZizyxTdGBe3yRuzPzdnoxz3g28PAps= github.com/vincenzopalazzo/cln4go/comm v0.0.0-20220802085837-fb816fecb890/go.mod h1:zyOWcz5aSHCsLuZLaVBTjbRnxlf5Ac+Rfhu5Ciuyy2c= github.com/vincenzopalazzo/cln4go/comm v0.0.0-20220818123810-7039d15d24ca h1:BkPn3LskgTCmMsgW9pZ9ZZc5nObZF0lo+hIl5mz0Wak= @@ -16,6 +18,8 @@ github.com/vincenzopalazzo/cln4go/comm v0.0.0-20230413130716-35626bd3b34b h1:tg6 github.com/vincenzopalazzo/cln4go/comm v0.0.0-20230413130716-35626bd3b34b/go.mod h1:zyOWcz5aSHCsLuZLaVBTjbRnxlf5Ac+Rfhu5Ciuyy2c= github.com/vincenzopalazzo/cln4go/comm v0.0.0-20240225150542-fa830ceeae65 h1:tcjluTHscWMynrF3Jlufi5ue8WdPKXCh7Nr9rPpMJuY= github.com/vincenzopalazzo/cln4go/comm v0.0.0-20240225150542-fa830ceeae65/go.mod h1:zyOWcz5aSHCsLuZLaVBTjbRnxlf5Ac+Rfhu5Ciuyy2c= +github.com/vincenzopalazzo/cln4go/comm v0.0.0-20240229123929-875e15a5a917 h1:p1Ch05kywTJWdpBubj5+wYZjdU5vr2POQcoShyPXI98= +github.com/vincenzopalazzo/cln4go/comm v0.0.0-20240229123929-875e15a5a917/go.mod h1:zyOWcz5aSHCsLuZLaVBTjbRnxlf5Ac+Rfhu5Ciuyy2c= github.com/vincenzopalazzo/cln4go/plugin v0.0.0-20220802085837-fb816fecb890 h1:L32YhQYlO2CeIp7AvjfN8ozuEba1R5/vi2bpH91B5mM= github.com/vincenzopalazzo/cln4go/plugin v0.0.0-20220802085837-fb816fecb890/go.mod h1:vb+knVG7/MR+oTnDRRwDH7WqO6U0FbcRNWjQeu0xdds= github.com/vincenzopalazzo/cln4go/plugin v0.0.0-20220818123810-7039d15d24ca h1:wgoFUhwXvQxbsxsrJE6+jMr1sagIHRD/f7F5irHxkaA= @@ -24,5 +28,7 @@ github.com/vincenzopalazzo/cln4go/plugin v0.0.0-20230413130716-35626bd3b34b h1:h github.com/vincenzopalazzo/cln4go/plugin v0.0.0-20230413130716-35626bd3b34b/go.mod h1:vb+knVG7/MR+oTnDRRwDH7WqO6U0FbcRNWjQeu0xdds= github.com/vincenzopalazzo/cln4go/plugin v0.0.0-20240225150542-fa830ceeae65 h1:lsmN/x6H3h3Np0Wxyio0p0o76NfcLJFo+ECO/EDDSqM= github.com/vincenzopalazzo/cln4go/plugin v0.0.0-20240225150542-fa830ceeae65/go.mod h1:vb+knVG7/MR+oTnDRRwDH7WqO6U0FbcRNWjQeu0xdds= +github.com/vincenzopalazzo/cln4go/plugin v0.0.0-20240229133517-f6b60e643fc6 h1:Ex2XRQGVr5Fsn/cNVBEep4vntZ3DQnOwhZWxb2/1qzs= +github.com/vincenzopalazzo/cln4go/plugin v0.0.0-20240229133517-f6b60e643fc6/go.mod h1:vb+knVG7/MR+oTnDRRwDH7WqO6U0FbcRNWjQeu0xdds= github.com/vincenzopalazzo/cpstl/go v0.0.0-20221204131531-d0659db4dd2a h1:eh427yzx/JbkOuLjSS2bPop/14HMq7eYGWC1bp29mzU= github.com/vincenzopalazzo/cpstl/go v0.0.0-20221204131531-d0659db4dd2a/go.mod h1:VNETfpfs0pZQKEg9qwSm7M1gfVrliFFzxKVVppNaxbM= diff --git a/pkg/plugin/pay.go b/pkg/plugin/pay.go index 0bf37c9..7e76ad8 100644 --- a/pkg/plugin/pay.go +++ b/pkg/plugin/pay.go @@ -37,12 +37,14 @@ func OceanPay(cln *plugin.Plugin[*State], request map[string]any) (map[string]an cln.Log("debug", fmt.Sprintf("decode offer: %s", invstrDecode)) var payInvoice map[string]any + var invoice string switch clnDecode.InvType { case "bolt12 offer", "bolt12 invoice_request", "bolt12 invoice": payInvoice, err = FetchOffer(cln, map[string]any{ "offer": clnRequest.Invstr, "amount_msat": clnRequest.Amount_msat, }) + invoice = payInvoice["bolt11"].(string) if err != nil { return nil, err } @@ -56,5 +58,19 @@ func OceanPay(cln *plugin.Plugin[*State], request map[string]any) (map[string]an return nil, err } - return payResponse, nil + invoiceDecode, err := cln.State.Rpc("decode", map[string]any{ + "string": invoice, + }) + if err != nil { + return nil, err + } + + response := map[string]any{ + "offer_invoice": clnRequest.Invstr, + "offer_decode": invstrDecode, + "invoice": invoice, + "invoice_decode": invoiceDecode, + "pay": payResponse, + } + return response, nil }