From 6ac1b1ca8925e7771384fd3f80329fc7a24a7311 Mon Sep 17 00:00:00 2001 From: jakubmkowalski Date: Tue, 3 Dec 2024 17:04:36 +0100 Subject: [PATCH 1/2] feat(SPV-1225): add confirm contacts admin api function --- http.go | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/http.go b/http.go index 29c8c1a..f98d01e 100644 --- a/http.go +++ b/http.go @@ -1106,6 +1106,17 @@ func (wc *WalletClient) AdminRejectContact(ctx context.Context, id string) (*mod return &contact, WrapError(err) } +// AdminConfirmContacts executes an HTTP POST request to confirm a contact using their xPubs IDs and paymails. +func (wc *WalletClient) AdminConfirmContacts(ctx context.Context, contacts []*models.ContactConfirmationData) error { + jsonBytes, err := json.Marshal(contacts) + if err != nil { + return WrapError(err) + } + + err = wc.doHTTPRequest(ctx, http.MethodPost, "/admin/contacts/confirmations", jsonBytes, wc.adminXPriv, true, nil) + return WrapError(err) +} + // FinalizeTransaction will finalize the transaction func (wc *WalletClient) FinalizeTransaction(draft *models.DraftTransaction) (string, error) { res, err := GetSignedHex(draft, wc.xPriv) From e7a486a604393b969103cb754df2bd5b1b682a16 Mon Sep 17 00:00:00 2001 From: jakubmkowalski Date: Tue, 10 Dec 2024 17:19:11 +0100 Subject: [PATCH 2/2] fix(SPV-1225): update AdminConfirmContacts parameter type --- http.go | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/http.go b/http.go index f98d01e..bcb4d87 100644 --- a/http.go +++ b/http.go @@ -1107,13 +1107,16 @@ func (wc *WalletClient) AdminRejectContact(ctx context.Context, id string) (*mod } // AdminConfirmContacts executes an HTTP POST request to confirm a contact using their xPubs IDs and paymails. -func (wc *WalletClient) AdminConfirmContacts(ctx context.Context, contacts []*models.ContactConfirmationData) error { - jsonBytes, err := json.Marshal(contacts) +func (wc *WalletClient) AdminConfirmContacts(ctx context.Context, paymailA, paymailB string) error { + jsonStr, err := json.Marshal(map[string]interface{}{ + "paymailA": paymailA, + "paymailB": paymailB, + }) if err != nil { return WrapError(err) } - err = wc.doHTTPRequest(ctx, http.MethodPost, "/admin/contacts/confirmations", jsonBytes, wc.adminXPriv, true, nil) + err = wc.doHTTPRequest(ctx, http.MethodPost, "/admin/contacts/confirmations", jsonStr, wc.adminXPriv, true, nil) return WrapError(err) }