diff --git a/transports/graphql.go b/transports/graphql.go index b4ddff6..949815d 100644 --- a/transports/graphql.go +++ b/transports/graphql.go @@ -129,6 +129,12 @@ func (g *TransportGraphQL) NewPaymail(_ context.Context, _, _, _, _ string, _ *b return nil } +// DeletePaymail will delete a paymail address +func (g *TransportGraphQL) DeletePaymail(_ context.Context, _ string) ResponseError { + // TODO: Implement this + return nil +} + // GetXpub will get an xPub func (g *TransportGraphQL) GetXpub(_ context.Context, _ string) (*buxmodels.Xpub, ResponseError) { // TODO: Implement this diff --git a/transports/http.go b/transports/http.go index e4d2c5f..4bbc507 100644 --- a/transports/http.go +++ b/transports/http.go @@ -78,6 +78,27 @@ func (h *TransportHTTP) NewPaymail(ctx context.Context, rawXpub, paymailAddress, ) } +// DeletePaymail will delete a paymail address +func (h *TransportHTTP) DeletePaymail(ctx context.Context, paymailAddress string) ResponseError { + jsonStr, err := json.Marshal(map[string]interface{}{ + FieldAddress: paymailAddress, + }) + if err != nil { + return WrapError(err) + } + + if err := h.doHTTPRequest( + ctx, http.MethodDelete, "/paymail", jsonStr, h.xPriv, true, nil, + ); err != nil { + return WrapError(err) + } + if h.debug { + log.Printf("delete paymail: %v\n", paymailAddress) + } + + return nil +} + // GetXPub will get the xpub of the current xpub func (h *TransportHTTP) GetXPub(ctx context.Context) (*buxmodels.Xpub, ResponseError) { var xPub buxmodels.Xpub diff --git a/transports/interface.go b/transports/interface.go index 06d2416..b1d339f 100644 --- a/transports/interface.go +++ b/transports/interface.go @@ -50,6 +50,7 @@ type TransactionService interface { // PaymailService is the paymail related requests type PaymailService interface { NewPaymail(ctx context.Context, rawXpub, paymailAddress, avatar, publicName string, metadata *buxmodels.Metadata) ResponseError + DeletePaymail(ctx context.Context, paymailAddress string) ResponseError } // AdminService is the admin related requests