Skip to content

Commit

Permalink
Merge pull request #229 from bitcoin-sv/SPV-807/sharedConfig
Browse files Browse the repository at this point in the history
feat(SPV-807): shared config
  • Loading branch information
Nazarii-4chain authored May 28, 2024
2 parents 7ea6895 + 4e7b827 commit 2fefddd
Showing 1 changed file with 20 additions and 12 deletions.
32 changes: 20 additions & 12 deletions http.go
Original file line number Diff line number Diff line change
Expand Up @@ -715,6 +715,26 @@ func (wc *WalletClient) UpsertContactForPaymail(ctx context.Context, paymail, fu
return &result, nil
}

// GetSharedConfig gets the shared config
func (wc *WalletClient) GetSharedConfig(ctx context.Context) (*models.SharedConfig, ResponseError) {
var model *models.SharedConfig

key := wc.xPriv
if wc.adminXPriv != nil {
key = wc.adminXPriv
}
if key == nil {
return nil, WrapError(errors.New("neither xPriv nor adminXPriv is provided"))
}
if err := wc.doHTTPRequest(
ctx, http.MethodGet, "/shared-config", nil, key, true, &model,
); err != nil {
return nil, err
}

return model, nil
}

// AdminNewXpub will register an xPub
func (wc *WalletClient) AdminNewXpub(ctx context.Context, rawXPub string, metadata *models.Metadata) ResponseError {
// Adding a xpub needs to be signed by an admin key
Expand Down Expand Up @@ -1012,18 +1032,6 @@ func (wc *WalletClient) AdminRecordTransaction(ctx context.Context, hex string)
return &transaction, nil
}

// AdminGetSharedConfig gets the shared config
func (wc *WalletClient) AdminGetSharedConfig(ctx context.Context) (*models.SharedConfig, ResponseError) {
var model *models.SharedConfig
if err := wc.doHTTPRequest(
ctx, http.MethodGet, "/admin/shared-config", nil, wc.adminXPriv, true, &model,
); err != nil {
return nil, err
}

return model, nil
}

// AdminGetContacts executes an HTTP POST request to search for contacts based on specified conditions, metadata, and query parameters.
func (wc *WalletClient) AdminGetContacts(ctx context.Context, conditions map[string]interface{}, metadata *models.Metadata, queryParams *QueryParams) (*models.SearchContactsResponse, ResponseError) {
jsonStr, err := json.Marshal(map[string]interface{}{
Expand Down

0 comments on commit 2fefddd

Please sign in to comment.