Documentation ¶
Overview ¶
Package dotwallet is the official golang implementation for the DotWallet API
If you have any suggestions or comments, please feel free to open an issue on this GitHub repository!
By DotWallet (https://dotwallet.com)
Index ¶
- Constants
- func UserAgent() string
- func Version() string
- type Client
- func (c *Client) GetAuthorizeURL(state string, scopes []string) string
- func (c *Client) GetNft(Txid string) (*NftData, error)
- func (c *Client) GetUserAgent() string
- func (c *Client) GetUserToken(code string) (*DotAccessToken, error)
- func (c *Client) IsTokenExpired(token *DotAccessToken) bool
- func (c *Client) MintNft(CodeHash string, Param string) (*NftMintData, error)
- func (c *Client) NewState() (string, error)
- func (c *Client) RefreshUserToken(token *DotAccessToken) (*DotAccessToken, error)
- func (c *Client) Request(httpMethod string, requestEndpoint string, data interface{}, expectedCode int, ...) (response *StandardResponse, err error)
- func (c *Client) Token() *DotAccessToken
- func (c *Client) UpdateApplicationAccessToken() error
- func (c *Client) UserInfo(userToken *DotAccessToken) (*User, error)
- func (c *Client) UserReceiveAddress(userID string, coinType coinType) (*Wallets, error)
- type ClientOps
- func WithApplicationAccessToken(token DotAccessToken) ClientOps
- func WithAutoLoadToken() ClientOps
- func WithCredentials(clientID, clientSecret string) ClientOps
- func WithCustomHTTPClient(client *resty.Client) ClientOps
- func WithCustomHeaders(headers map[string][]string) ClientOps
- func WithHTTPTimeout(timeout time.Duration) ClientOps
- func WithHost(host string) ClientOps
- func WithRedirectURI(redirectURI string) ClientOps
- func WithRequestTracing() ClientOps
- func WithRetryCount(retries int) ClientOps
- func WithUserAgent(userAgent string) ClientOps
- type DotAccessToken
- type Error
- type NftData
- type NftMintData
- type StandardResponse
- type User
- type Wallets
Examples ¶
Constants ¶
const ( // ScopeUserInfo is for getting user info ScopeUserInfo = "user.info" // ScopeAutoPayBSV is for auto-pay with a BSV balance ScopeAutoPayBSV = "autopay.bsv" // ScopeAutoPayBTC is for auto-pay with a BTC balance ScopeAutoPayBTC = "autopay.btc" // ScopeAutoPayETH is for auto-pay with a ETH balance ScopeAutoPayETH = "autopay.eth" )
const ( CoinTypeBSV coinType = "BSV" // BitcoinSV CoinTypeBTC coinType = "BTC" // BitcoinCore CoinTypeETH coinType = "ETH" // Ethereum )
These are used for the accepted coin types in regard to wallet functions
Variables ¶
This section is empty.
Functions ¶
Types ¶
type Client ¶
type Client struct {
// contains filtered or unexported fields
}
Client is the TonicPow client/configuration
func NewClient ¶
NewClient creates a new client for all TonicPow requests
If no options are given, it will use the DefaultClientOptions() If there is no client is supplied, it will use a default Resty HTTP client.
Example ¶
ExampleNewClient example using NewClient()
See more examples in /examples/
client, err := NewClient( WithCredentials("your-client-id", "your-secret-id"), WithRedirectURI("http://localhost:3000/v1/auth/dotwallet/callback"), ) if err != nil { fmt.Printf("error loading client: %s", err.Error()) return } fmt.Printf("loaded client: %s", client.options.userAgent)
Output: loaded client: dotwallet-go-sdk: v0.0.5
func (*Client) GetAuthorizeURL ¶
GetAuthorizeURL will return a new url for starting the user oauth2 authorization process
For more information: https://developers.dotwallet.com/documents/en/#user-authorization
func (*Client) GetNft ¶ added in v0.0.5
GetNft can obtain information authorized by DotWallet users via their user access_token
func (*Client) GetUserAgent ¶
GetUserAgent will return the user agent string of the client
func (*Client) GetUserToken ¶
func (c *Client) GetUserToken(code string) (*DotAccessToken, error)
GetUserToken will get the user's access_token for the first time given the "code" from the oauth2 callback This will also store the user's token on the client for easy access (c.options.userToken)
For more information: https://developers.dotwallet.com/documents/en/#user-authorization
func (*Client) IsTokenExpired ¶
func (c *Client) IsTokenExpired(token *DotAccessToken) bool
IsTokenExpired will check if the token is expired
func (*Client) MintNft ¶ added in v0.0.5
func (c *Client) MintNft(CodeHash string, Param string) (*NftMintData, error)
MintNft can obtain information authorized by DotWallet users via their user access_token
func (*Client) NewState ¶
NewState returns a new state key for CSRF protection It is not required to use this method, you can use your own UUID() for state validation
For more information: https://developers.dotwallet.com/documents/en/#user-authorization
func (*Client) RefreshUserToken ¶
func (c *Client) RefreshUserToken(token *DotAccessToken) (*DotAccessToken, error)
RefreshUserToken will refresh the user's auth_token using the refresh_token This will also store the user's token on the client for easy access (c.options.userToken)
For more information: https://developers.dotwallet.com/documents/en/#user-authorization
func (*Client) Request ¶
func (c *Client) Request(httpMethod string, requestEndpoint string, data interface{}, expectedCode int, authorization *DotAccessToken) (response *StandardResponse, err error)
Request is a standard GET / POST / PUT / DELETE request for all outgoing HTTP requests Omit the data attribute if using a GET request
func (*Client) Token ¶
func (c *Client) Token() *DotAccessToken
Token will return the token for the application
func (*Client) UpdateApplicationAccessToken ¶
UpdateApplicationAccessToken will update the application access token This will also store the token on the client for easy access (c.options.token)
For more information: https://developers.dotwallet.com/documents/en/#application-authorization
func (*Client) UserInfo ¶
func (c *Client) UserInfo(userToken *DotAccessToken) (*User, error)
UserInfo can obtain information authorized by DotWallet users via their user access_token
For more information: https://developers.dotwallet.com/documents/en/#user-info
func (*Client) UserReceiveAddress ¶
UserReceiveAddress will return the wallets for the user based on the given coin_type Currently supported: BSV, BTC and ETH Paymail is currently only supported on BSV
For more information: https://developers.dotwallet.com/documents/en/#get-user-receive-address
type ClientOps ¶
type ClientOps func(c *clientOptions)
ClientOps allow functional options to be supplied that overwrite default client options.
func WithApplicationAccessToken ¶
func WithApplicationAccessToken(token DotAccessToken) ClientOps
WithApplicationAccessToken will override the token on the client
func WithAutoLoadToken ¶
func WithAutoLoadToken() ClientOps
WithAutoLoadToken will load the application token when spawning a new client By default, this is disabled, so you can make a new client without making an HTTP request
func WithCredentials ¶
WithCredentials will set the ClientID and ClientSecret There is no default
func WithCustomHTTPClient ¶
func WithCustomHTTPClient(client *resty.Client) ClientOps
WithCustomHTTPClient will overwrite the default client with a custom client.
func WithCustomHeaders ¶
WithCustomHeaders will add custom headers to outgoing requests Custom headers is empty by default
func WithHTTPTimeout ¶
WithHTTPTimeout can be supplied to adjust the default http client timeouts. The http client is used when creating requests Default timeout is 10 seconds.
func WithRedirectURI ¶
WithRedirectURI will set the redirect URI for user authentication callbacks There is no default
func WithRequestTracing ¶
func WithRequestTracing() ClientOps
WithRequestTracing will enable tracing. Tracing is disabled by default.
func WithRetryCount ¶
WithRetryCount will overwrite the default retry count for http requests. Default retries is 2.
func WithUserAgent ¶
WithUserAgent will overwrite the default useragent. Default is package name + version.
type DotAccessToken ¶
type DotAccessToken struct { AccessToken string `json:"access_token"` // Access token from the API ExpiresAt int64 `json:"expires_at,omitempty"` // Friendly unix time from UTC when the access_token expires ExpiresIn int64 `json:"expires_in"` // Seconds from now that the token expires RefreshToken string `json:"refresh_token,omitempty"` // Refresh token for the user RefreshTokenExpiresIn int64 `json:"refresh_token_expires_in,omitempty"` // Seconds from now that the token expires RefreshTokenExpiresAt int64 `json:"refresh_token_expires_at,omitempty"` // Friendly unix time from UTC when the refresh_token expires Scopes []string `json:"scopes,omitempty"` // Scopes for the user token TokenType string `json:"token_type"` // Token type }
DotAccessToken is the access token information
For more information: https://developers.dotwallet.com/documents/en/#user-authorization
type Error ¶
type Error struct { Data interface{} `json:"data"` Method string `json:"method"` RequestID string `json:"req_id"` URL string `json:"url"` // contains filtered or unexported fields }
Error is the universal Error response from the API
For more information: https://developers.dotwallet.com/documents/en/#errors
type NftMintData ¶ added in v0.0.5
type NftMintData struct { Fee int64 `json:"fee"` FeeStr string `json:"fee_str"` Txid string `json:"txid"` }
NftMintData is the data struct
type StandardResponse ¶
type StandardResponse struct { Body []byte `json:"-"` // Body of the response request Error *Error `json:"-"` // API error response StatusCode int `json:"-"` // Status code returned on the request Tracing resty.TraceInfo `json:"-"` // Trace information if enabled on the request }
StandardResponse is the standard fields returned on all responses from Request()
type User ¶
type User struct { Avatar string `json:"avatar"` ID string `json:"id"` Nickname string `json:"nickname"` WebWalletAddress *webWalletAddress `json:"web_wallet_address"` }
User is the DotWallet user profile information
For more information: https://developers.dotwallet.com/documents/en/#user-info