fix linking

This commit is contained in:
boufni95 2024-10-16 16:11:40 +00:00
parent fb17b05441
commit 24e0c67775
10 changed files with 227 additions and 4 deletions

View file

@ -85,6 +85,7 @@ type Client struct {
GetLnurlWithdrawInfo func(query GetLnurlWithdrawInfo_Query) (*LnurlWithdrawInfoResponse, error)
GetLnurlWithdrawLink func() (*LnurlLinkResponse, error)
GetMigrationUpdate func() (*MigrationUpdate, error)
GetNPubLinkingState func(req GetNPubLinking) (*NPubLinking, error)
GetPaymentState func(req GetPaymentStateRequest) (*PaymentState, error)
GetSeed func() (*LndSeed, error)
GetUsageMetrics func() (*UsageMetrics, error)
@ -834,6 +835,35 @@ func NewClient(params ClientParams) *Client {
return &res, nil
},
// server streaming method: GetMigrationUpdate not implemented
GetNPubLinkingState: func(req GetNPubLinking) (*NPubLinking, error) {
auth, err := params.RetrieveAppAuth()
if err != nil {
return nil, err
}
finalRoute := "/api/app/user/npub/token"
body, err := json.Marshal(req)
if err != nil {
return nil, err
}
resBody, err := doPostRequest(params.BaseURL+finalRoute, body, auth)
if err != nil {
return nil, err
}
result := ResultError{}
err = json.Unmarshal(resBody, &result)
if err != nil {
return nil, err
}
if result.Status == "ERROR" {
return nil, fmt.Errorf(result.Reason)
}
res := NPubLinking{}
err = json.Unmarshal(resBody, &res)
if err != nil {
return nil, err
}
return &res, nil
},
GetPaymentState: func(req GetPaymentStateRequest) (*PaymentState, error) {
auth, err := params.RetrieveUserAuth()
if err != nil {