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
- Variables
- func ParseNftVoutScript(pkScript []byte) (btcutil.Address, error)
- func ToJSONStr(i interface{}) string
- func UserAgent() string
- func Version() string
- type AddressBadgeCodePair
- type AddressIndexPair
- type Client
- func (c *Client) DeserializeRawTx(rawTx string) (*wire.MsgTx, error)
- func (c *Client) GetAuthorizeURL(state string, scopes []string) string
- func (c *Client) GetMerkleProof(txHash *chainhash.Hash) (*MerkelProof, error)
- func (c *Client) GetMerkleProofByHashStr(txID string) (*MerkelProof, error)
- func (c *Client) GetMsgTx(hash *chainhash.Hash) (*wire.MsgTx, error)
- func (c *Client) GetMsgTxByStr(txID string) (*wire.MsgTx, error)
- func (c *Client) GetNft(txID string) (*NftData, error)
- func (c *Client) GetNftReceiveAddresses(msgTx *wire.MsgTx) ([]*AddressBadgeCodePair, error)
- func (c *Client) GetNftReceiveAddressesByTxidStr(txID string) ([]*AddressBadgeCodePair, 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) SerializeRawTx(tx *wire.MsgTx) string
- func (c *Client) Token() *DotAccessToken
- func (c *Client) TransferNftToAddress(txID string, address string, name string, description string, picURL string) (*TransferNftToAddressData, error)
- func (c *Client) UpdateApplicationAccessToken() error
- func (c *Client) UserInfo(userToken *DotAccessToken) (*User, error)
- func (c *Client) UserReceiveAddress(userID string, coinType coinType) (*Wallets, error)
- func (c *Client) VerifyCastingNftTransaction(msgTx *wire.MsgTx) (bool, error)
- func (c *Client) VerifyCastingNftTransactionByRawTx(rawTx string) (bool, error)
- func (c *Client) VerifyCastingNftTransactionByTxid(txID string) (bool, error)
- func (c *Client) VerifyMerkleProof(txID string, nIndex int, nodes []string, exceptMerkleRoot string) bool
- func (c *Client) VerifyNftCastingOpReturn(msgTx *wire.MsgTx) bool
- 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 GetMerkleProofRequest
- type GetMerkleProofResponse
- type GetRawTransactionRequest
- type GetRawTransactionResponse
- type MerkelProof
- type MsgTxInfo
- type NftAuthInfo
- type NftData
- type NftMintData
- type NftTxInfo
- type StandardResponse
- type Target
- type TransferNftToAddressData
- type TxIDIndexPair
- 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 ( NftVoutLen = 2188 NftVinPushedDataCount = 11 )
NFT constants
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
const ( NftTxTypeCasting = 1 NftTxTypeTransfer = 2 NftTxTypeDestroy = 3 NftTxTypeError = 4 NftTxTypeIrrelevant = 5 )
NFT Types
Variables ¶
var NftVoutScriptPrefix = []byte{} /* 2168 elements not displayed */
NftVoutScriptPrefix is the prefix
Functions ¶
func ParseNftVoutScript ¶ added in v0.0.6
ParseNftVoutScript will parse th NFT script
Types ¶
type AddressBadgeCodePair ¶ added in v0.0.6
type AddressBadgeCodePair struct { Address string `json:"address"` BadgeCode string `json:"badge_code"` }
AddressBadgeCodePair is the badge code pair
type AddressIndexPair ¶ added in v0.0.6
AddressIndexPair is the index pair
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.2.0
func (*Client) DeserializeRawTx ¶ added in v0.0.6
DeserializeRawTx deserialize the raw tx
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) GetMerkleProof ¶ added in v0.0.6
func (c *Client) GetMerkleProof(txHash *chainhash.Hash) (*MerkelProof, error)
GetMerkleProof get merkle proof
func (*Client) GetMerkleProofByHashStr ¶ added in v0.0.6
func (c *Client) GetMerkleProofByHashStr(txID string) (*MerkelProof, error)
GetMerkleProofByHashStr get merkle proof by hash string
func (*Client) GetMsgTxByStr ¶ added in v0.0.6
GetMsgTxByStr get message tx by string
func (*Client) GetNft ¶ added in v0.0.5
GetNft can obtain information authorized by DotWallet users via their user access_token
func (*Client) GetNftReceiveAddresses ¶ added in v0.0.6
func (c *Client) GetNftReceiveAddresses(msgTx *wire.MsgTx) ([]*AddressBadgeCodePair, error)
GetNftReceiveAddresses get nft addresses
func (*Client) GetNftReceiveAddressesByTxidStr ¶ added in v0.0.6
func (c *Client) GetNftReceiveAddressesByTxidStr(txID string) ([]*AddressBadgeCodePair, error)
GetNftReceiveAddressesByTxidStr get address by tx id
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) SerializeRawTx ¶ added in v0.0.6
SerializeRawTx serialize the raw tx
func (*Client) Token ¶
func (c *Client) Token() *DotAccessToken
Token will return the token for the application
func (*Client) TransferNftToAddress ¶ added in v0.0.6
func (c *Client) TransferNftToAddress(txID string, address string, name string, description string, picURL string) (*TransferNftToAddressData, error)
TransferNftToAddress can obtain information authorized by DotWallet users via their user access_token
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
func (*Client) VerifyCastingNftTransaction ¶ added in v0.0.6
VerifyCastingNftTransaction verify the tx
func (*Client) VerifyCastingNftTransactionByRawTx ¶ added in v0.0.6
VerifyCastingNftTransactionByRawTx will verify the casting
func (*Client) VerifyCastingNftTransactionByTxid ¶ added in v0.0.6
VerifyCastingNftTransactionByTxid get by tx id
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 GetMerkleProofRequest ¶ added in v0.0.6
type GetMerkleProofRequest struct {
Txid string `json:"txid"`
}
GetMerkleProofRequest is the request
type GetMerkleProofResponse ¶ added in v0.0.6
type GetMerkleProofResponse struct { Data struct { MerkelProof } // contains filtered or unexported fields }
GetMerkleProofResponse is the response
type GetRawTransactionRequest ¶ added in v0.0.6
type GetRawTransactionRequest struct {
TxID string `json:"txid"`
}
GetRawTransactionRequest is the request
type GetRawTransactionResponse ¶ added in v0.0.6
type GetRawTransactionResponse struct { Data struct { MsgTxInfo } // contains filtered or unexported fields }
GetRawTransactionResponse is the response
type MerkelProof ¶ added in v0.0.6
type MerkelProof struct { Flags int `json:"flags"` Index int `json:"index"` Nodes []string `json:"nodes"` Target *Target `json:"target"` TxOrID string `json:"txOrId"` }
MerkelProof is the merkle proof
type MsgTxInfo ¶ added in v0.0.6
type MsgTxInfo struct { MsgTx *wire.MsgTx Height int64 BlockHash string Timestamp int64 RawTx string }
MsgTxInfo is the msg tx info
type NftAuthInfo ¶ added in v0.0.6
NftAuthInfo is the auth info
type NftMintData ¶ added in v0.0.5
type NftMintData struct { Fee int64 `json:"fee"` FeeStr string `json:"fee_str"` TxID string `json:"txid"` BadgePath []string `json:"badge_path"` }
NftMintData is the data struct
type NftTxInfo ¶ added in v0.0.6
type NftTxInfo struct { TxID string NftPreOutPoints []*TxIDIndexPair NftOutPoints []*AddressIndexPair Type int }
NftTxInfo is the tx info
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 Target ¶ added in v0.0.6
type Target struct { Hash string `json:"hash"` Confirmations int `json:"confirmations"` Height int `json:"height"` Version int `json:"version"` VersionHex string `json:"versionHex"` Merkleroot string `json:"merkleroot"` NumTx int `json:"num_tx"` Time int `json:"time"` Mediantime int `json:"mediantime"` Nonce int `json:"nonce"` Bits string `json:"bits"` Difficulty float64 `json:"difficulty"` Chainwork string `json:"chainwork"` Previousblockhash string `json:"previousblockhash"` Nextblockhash string `json:"nextblockhash"` }
Target is the target
type TransferNftToAddressData ¶ added in v0.0.6
TransferNftToAddressData is the transfer to address struct
type TxIDIndexPair ¶ added in v0.0.6
TxIDIndexPair is the pair
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