Merge pull request #9 from vincenzopalazzo/macros/check-forvalidity

plugin: check if the offer is valid
This commit is contained in:
Vincenzo Palazzo 2024-03-23 18:37:44 +01:00 committed by GitHub
commit 997ae766bf
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
1 changed files with 5 additions and 1 deletions

View File

@ -12,7 +12,7 @@ func OceanPay(cln *plugin.Plugin[*State], request map[string]any) (map[string]an
cln.Log("debug", fmt.Sprintf("ocean-pay: %s", request))
clnRequest := struct {
Invstr string `mapstructure:"invstr"`
Amount_msat string `mapstructure:"amount_msat"`
Amount_msat any `mapstructure:"amount_msat"`
}{}
if err := json.Decode(request, &clnRequest); err != nil {
return nil, err
@ -35,6 +35,10 @@ func OceanPay(cln *plugin.Plugin[*State], request map[string]any) (map[string]an
return nil, err
}
if !clnDecode.Valid {
return nil, fmt.Errorf("invoice not valid")
}
cln.Log("debug", fmt.Sprintf("decode offer: %s", invstrDecode))
var payInvoice map[string]any
var invoice string