Documentation ¶
Overview ¶
Package walletclient is a Go client for interacting with Spv Wallet.
Index ¶
- Constants
- Variables
- type ClientOps
- func WithAccessKey(accessKeyString string) ClientOps
- func WithAdminKey(adminKey string) ClientOps
- func WithHTTP(serverURL string) ClientOps
- func WithHTTPClient(serverURL string, httpClient *http.Client) ClientOps
- func WithSignRequest(signRequest bool) ClientOps
- func WithXPriv(xPrivString string) ClientOps
- func WithXPub(xPubString string) ClientOps
- type WalletClient
- func (b *WalletClient) AcceptContact(ctx context.Context, paymail string) transports.ResponseError
- func (b *WalletClient) ConfirmContact(ctx context.Context, contact *models.Contact, passcode string, ...) transports.ResponseError
- func (b *WalletClient) CreateAccessKey(ctx context.Context, metadata *models.Metadata) (*models.AccessKey, transports.ResponseError)
- func (b *WalletClient) DraftToRecipients(ctx context.Context, recipients []*transports.Recipients, ...) (*models.DraftTransaction, transports.ResponseError)
- func (b *WalletClient) DraftTransaction(ctx context.Context, transactionConfig *models.TransactionConfig, ...) (*models.DraftTransaction, transports.ResponseError)
- func (b *WalletClient) FinalizeTransaction(draft *models.DraftTransaction) (string, transports.ResponseError)
- func (b *WalletClient) GenerateTotpForContact(contact *models.Contact, period, digits uint) (string, error)
- func (b *WalletClient) GetAccessKey(ctx context.Context, id string) (*models.AccessKey, transports.ResponseError)
- func (b *WalletClient) GetAccessKeys(ctx context.Context, metadataConditions *models.Metadata) ([]*models.AccessKey, transports.ResponseError)
- func (b *WalletClient) GetContacts(ctx context.Context, conditions map[string]interface{}, ...) ([]*models.Contact, transports.ResponseError)
- func (b *WalletClient) GetDestinationByAddress(ctx context.Context, address string) (*models.Destination, transports.ResponseError)
- func (b *WalletClient) GetDestinationByID(ctx context.Context, id string) (*models.Destination, transports.ResponseError)
- func (b *WalletClient) GetDestinationByLockingScript(ctx context.Context, lockingScript string) (*models.Destination, transports.ResponseError)
- func (b *WalletClient) GetDestinations(ctx context.Context, metadataConditions *models.Metadata) ([]*models.Destination, transports.ResponseError)
- func (b *WalletClient) GetTransaction(ctx context.Context, txID string) (*models.Transaction, transports.ResponseError)
- func (b *WalletClient) GetTransactions(ctx context.Context, conditions map[string]interface{}, ...) ([]*models.Transaction, transports.ResponseError)
- func (b *WalletClient) GetTransactionsCount(ctx context.Context, conditions map[string]interface{}, ...) (int64, transports.ResponseError)
- func (b *WalletClient) GetTransport() *transports.TransportService
- func (b *WalletClient) GetXPub(ctx context.Context) (*models.Xpub, transports.ResponseError)
- func (b *WalletClient) IsSignRequest() bool
- func (b *WalletClient) NewDestination(ctx context.Context, metadata *models.Metadata) (*models.Destination, transports.ResponseError)
- func (b *WalletClient) RecordTransaction(ctx context.Context, hex, draftID string, metadata *models.Metadata) (*models.Transaction, transports.ResponseError)
- func (b *WalletClient) RejectContact(ctx context.Context, paymail string) transports.ResponseError
- func (b *WalletClient) RevokeAccessKey(ctx context.Context, id string) (*models.AccessKey, transports.ResponseError)
- func (b *WalletClient) SendToRecipients(ctx context.Context, recipients []*transports.Recipients, ...) (*models.Transaction, transports.ResponseError)
- func (b *WalletClient) SetAdminKey(adminKeyString string) error
- func (b *WalletClient) SetSignRequest(signRequest bool)
- func (b *WalletClient) UpdateDestinationMetadataByAddress(ctx context.Context, address string, metadata *models.Metadata) (*models.Destination, transports.ResponseError)
- func (b *WalletClient) UpdateDestinationMetadataByID(ctx context.Context, id string, metadata *models.Metadata) (*models.Destination, transports.ResponseError)
- func (b *WalletClient) UpdateDestinationMetadataByLockingScript(ctx context.Context, lockingScript string, metadata *models.Metadata) (*models.Destination, transports.ResponseError)
- func (b *WalletClient) UpdateTransactionMetadata(ctx context.Context, txID string, metadata *models.Metadata) (*models.Transaction, transports.ResponseError)
- func (b *WalletClient) UpdateXPubMetadata(ctx context.Context, metadata *models.Metadata) (*models.Xpub, transports.ResponseError)
- func (b *WalletClient) UpsertContact(ctx context.Context, paymail, fullName string, metadata *models.Metadata) (*models.Contact, transports.ResponseError)
- func (b *WalletClient) UpsertContactForPaymail(ctx context.Context, paymail, fullName string, metadata *models.Metadata, ...) (*models.Contact, transports.ResponseError)
- func (b *WalletClient) ValidateTotpForContact(contact *models.Contact, passcode string, period, digits uint) (bool, error)
Constants ¶
const ( // Default number of seconds a TOTP is valid for. TotpDefaultPeriod uint = 30 // Default TOTP length TotpDefaultDigits uint = 2 )
Variables ¶
var ErrClientInitNoXpriv = errors.New("init client with xPriv first")
Functions ¶
This section is empty.
Types ¶
type ClientOps ¶
type ClientOps func(c *WalletClient)
ClientOps are used for client options
func WithAccessKey ¶
WithAccessKey will set the access key on the client
func WithAdminKey ¶
WithAdminKey will set the admin key for admin requests
func WithHTTPClient ¶
WithHTTPClient will overwrite the default client with a custom client
func WithSignRequest ¶
WithSignRequest will set whether to sign all requests
type WalletClient ¶
type WalletClient struct { transports.TransportService // contains filtered or unexported fields }
WalletClient is the spv wallet go client representation.
func (*WalletClient) AcceptContact ¶ added in v0.10.0
func (b *WalletClient) AcceptContact(ctx context.Context, paymail string) transports.ResponseError
AcceptContact will accept the contact associated with the paymail
func (*WalletClient) ConfirmContact ¶ added in v0.10.0
func (b *WalletClient) ConfirmContact(ctx context.Context, contact *models.Contact, passcode string, period, digits uint) transports.ResponseError
ConfirmContact will try to confirm the contact
func (*WalletClient) CreateAccessKey ¶
func (b *WalletClient) CreateAccessKey(ctx context.Context, metadata *models.Metadata) (*models.AccessKey, transports.ResponseError)
CreateAccessKey creates new access key
func (*WalletClient) DraftToRecipients ¶
func (b *WalletClient) DraftToRecipients(ctx context.Context, recipients []*transports.Recipients, metadata *models.Metadata, ) (*models.DraftTransaction, transports.ResponseError)
DraftToRecipients initialize a new P2PKH draft transaction to a list of recipients
func (*WalletClient) DraftTransaction ¶
func (b *WalletClient) DraftTransaction(ctx context.Context, transactionConfig *models.TransactionConfig, metadata *models.Metadata, ) (*models.DraftTransaction, transports.ResponseError)
DraftTransaction initialize a new draft transaction
func (*WalletClient) FinalizeTransaction ¶
func (b *WalletClient) FinalizeTransaction(draft *models.DraftTransaction) (string, transports.ResponseError)
FinalizeTransaction will finalize the transaction
func (*WalletClient) GenerateTotpForContact ¶ added in v0.10.0
func (b *WalletClient) GenerateTotpForContact(contact *models.Contact, period, digits uint) (string, error)
GenerateTotpForContact creates one time-based one-time password based on secret shared between the user and the contact
func (*WalletClient) GetAccessKey ¶
func (b *WalletClient) GetAccessKey(ctx context.Context, id string) (*models.AccessKey, transports.ResponseError)
GetAccessKey gets the access key given by id
func (*WalletClient) GetAccessKeys ¶
func (b *WalletClient) GetAccessKeys(ctx context.Context, metadataConditions *models.Metadata) ([]*models.AccessKey, transports.ResponseError)
GetAccessKeys gets all the access keys filtered by the metadata
func (*WalletClient) GetContacts ¶ added in v0.10.0
func (b *WalletClient) GetContacts(ctx context.Context, conditions map[string]interface{}, metadata *models.Metadata, queryParams *transports.QueryParams) ([]*models.Contact, transports.ResponseError)
GetContacts will get contacts by conditions
func (*WalletClient) GetDestinationByAddress ¶
func (b *WalletClient) GetDestinationByAddress(ctx context.Context, address string) (*models.Destination, transports.ResponseError)
GetDestinationByAddress gets the destination by address
func (*WalletClient) GetDestinationByID ¶
func (b *WalletClient) GetDestinationByID(ctx context.Context, id string) (*models.Destination, transports.ResponseError)
GetDestinationByID gets the destination by id
func (*WalletClient) GetDestinationByLockingScript ¶
func (b *WalletClient) GetDestinationByLockingScript(ctx context.Context, lockingScript string, ) (*models.Destination, transports.ResponseError)
GetDestinationByLockingScript gets the destination by locking script
func (*WalletClient) GetDestinations ¶
func (b *WalletClient) GetDestinations(ctx context.Context, metadataConditions *models.Metadata, ) ([]*models.Destination, transports.ResponseError)
GetDestinations gets all destinations that match the metadata filter
func (*WalletClient) GetTransaction ¶
func (b *WalletClient) GetTransaction(ctx context.Context, txID string) (*models.Transaction, transports.ResponseError)
GetTransaction get a transaction by id
func (*WalletClient) GetTransactions ¶
func (b *WalletClient) GetTransactions(ctx context.Context, conditions map[string]interface{}, metadata *models.Metadata, queryParams *transports.QueryParams, ) ([]*models.Transaction, transports.ResponseError)
GetTransactions get all transactions matching search criteria
func (*WalletClient) GetTransactionsCount ¶
func (b *WalletClient) GetTransactionsCount(ctx context.Context, conditions map[string]interface{}, metadata *models.Metadata, ) (int64, transports.ResponseError)
GetTransactionsCount get number of user transactions
func (*WalletClient) GetTransport ¶
func (b *WalletClient) GetTransport() *transports.TransportService
GetTransport returns the current transport service
func (*WalletClient) GetXPub ¶
func (b *WalletClient) GetXPub(ctx context.Context) (*models.Xpub, transports.ResponseError)
GetXPub gets the current xpub
func (*WalletClient) IsSignRequest ¶
func (b *WalletClient) IsSignRequest() bool
IsSignRequest return whether to sign all requests
func (*WalletClient) NewDestination ¶
func (b *WalletClient) NewDestination(ctx context.Context, metadata *models.Metadata) (*models.Destination, transports.ResponseError)
NewDestination create a new destination and return it
func (*WalletClient) RecordTransaction ¶
func (b *WalletClient) RecordTransaction(ctx context.Context, hex, draftID string, metadata *models.Metadata, ) (*models.Transaction, transports.ResponseError)
RecordTransaction record a new transaction
func (*WalletClient) RejectContact ¶ added in v0.10.0
func (b *WalletClient) RejectContact(ctx context.Context, paymail string) transports.ResponseError
RejectContact will reject the contact associated with the paymail
func (*WalletClient) RevokeAccessKey ¶
func (b *WalletClient) RevokeAccessKey(ctx context.Context, id string) (*models.AccessKey, transports.ResponseError)
RevokeAccessKey revoked the access key given by id
func (*WalletClient) SendToRecipients ¶
func (b *WalletClient) SendToRecipients(ctx context.Context, recipients []*transports.Recipients, metadata *models.Metadata, ) (*models.Transaction, transports.ResponseError)
SendToRecipients send to recipients
func (*WalletClient) SetAdminKey ¶
func (b *WalletClient) SetAdminKey(adminKeyString string) error
SetAdminKey set the admin key to use to create new xpubs
func (*WalletClient) SetSignRequest ¶
func (b *WalletClient) SetSignRequest(signRequest bool)
SetSignRequest turn the signing of the http request on or off
func (*WalletClient) UpdateDestinationMetadataByAddress ¶
func (b *WalletClient) UpdateDestinationMetadataByAddress(ctx context.Context, address string, metadata *models.Metadata, ) (*models.Destination, transports.ResponseError)
UpdateDestinationMetadataByAddress updates the destination metadata by address
func (*WalletClient) UpdateDestinationMetadataByID ¶
func (b *WalletClient) UpdateDestinationMetadataByID(ctx context.Context, id string, metadata *models.Metadata, ) (*models.Destination, transports.ResponseError)
UpdateDestinationMetadataByID updates the destination metadata by id
func (*WalletClient) UpdateDestinationMetadataByLockingScript ¶
func (b *WalletClient) UpdateDestinationMetadataByLockingScript(ctx context.Context, lockingScript string, metadata *models.Metadata, ) (*models.Destination, transports.ResponseError)
UpdateDestinationMetadataByLockingScript updates the destination metadata by locking script
func (*WalletClient) UpdateTransactionMetadata ¶
func (b *WalletClient) UpdateTransactionMetadata(ctx context.Context, txID string, metadata *models.Metadata, ) (*models.Transaction, transports.ResponseError)
UpdateTransactionMetadata update the metadata of a transaction
func (*WalletClient) UpdateXPubMetadata ¶
func (b *WalletClient) UpdateXPubMetadata(ctx context.Context, metadata *models.Metadata) (*models.Xpub, transports.ResponseError)
UpdateXPubMetadata update the metadata of the logged in xpub
func (*WalletClient) UpsertContact ¶ added in v0.10.0
func (b *WalletClient) UpsertContact(ctx context.Context, paymail, fullName string, metadata *models.Metadata) (*models.Contact, transports.ResponseError)
UpsertContact add or update contact. When adding a new contact, the system utilizes Paymail's PIKE capability to dispatch an invitation request, asking the counterparty to include the current user in their contacts.
func (*WalletClient) UpsertContactForPaymail ¶ added in v0.10.0
func (b *WalletClient) UpsertContactForPaymail(ctx context.Context, paymail, fullName string, metadata *models.Metadata, requesterPaymail string) (*models.Contact, transports.ResponseError)
UpsertContactForPaymail add or update contact. When adding a new contact, the system utilizes Paymail's PIKE capability to dispatch an invitation request, asking the counterparty to include the current user specified paymail in their contacts.
func (*WalletClient) ValidateTotpForContact ¶ added in v0.10.0
func (b *WalletClient) ValidateTotpForContact(contact *models.Contact, passcode string, period, digits uint) (bool, error)
ValidateTotpForContact validates one time-based one-time password based on secret shared between the user and the contact
Source Files ¶
Directories ¶
Path | Synopsis |
---|---|
examples
module
|
|
Package transports encapsulates the different ways to communicate with SPV Wallet
|
Package transports encapsulates the different ways to communicate with SPV Wallet |
Package utils contains utility functions for the wallet like hashes and crypto functions
|
Package utils contains utility functions for the wallet like hashes and crypto functions |