28 lines
670 B
Go
28 lines
670 B
Go
package plugin
|
|
|
|
import (
|
|
"fmt"
|
|
|
|
json "github.com/mitchellh/mapstructure"
|
|
|
|
"github.com/vincenzopalazzo/cln4go/plugin"
|
|
)
|
|
|
|
// / FetchOffer - Fetch the offer invoice
|
|
func FetchOffer(cln *plugin.Plugin[*State], fetchInfo map[string]any) (map[string]any, error) {
|
|
fetchInvoice, err := cln.State.Rpc("fetchinvoice", fetchInfo)
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
cln.Log("debug", fmt.Sprintf("fetch offer result: %s", fetchInvoice))
|
|
clnFetchInvoice := struct {
|
|
Invoice string `mapstructure:"invoice"`
|
|
}{}
|
|
if err := json.Decode(fetchInvoice, &clnFetchInvoice); err != nil {
|
|
return nil, err
|
|
}
|
|
return map[string]any{
|
|
"bolt11": clnFetchInvoice.Invoice,
|
|
}, nil
|
|
}
|