Documentation ¶
Index ¶
- func NewPaymentID256() string
- func NewPaymentID64() string
- func XMRToDecimal(xmr uint64) string
- func XMRToFloat64(xmr uint64) float64
- type AddressBookEntry
- type Client
- type Config
- type Destination
- type ErrorCode
- type GetTransferType
- type GetTransfersRequest
- type GetTransfersResponse
- type H
- type ImportKeyImageResponse
- type IncTransfer
- type Payment
- type Priority
- type QueryKeyType
- type SignedKeyImage
- type SweepAllRequest
- type SweepAllResponse
- type Transfer
- type TransferRequest
- type TransferResponse
- type TransferSplitResponse
- type URIDef
- type WalletError
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func NewPaymentID256 ¶
func NewPaymentID256() string
NewPaymentID256 generates a 256 bit payment ID (hex encoded).
func NewPaymentID64 ¶
func NewPaymentID64() string
NewPaymentID64 generates a 64 bit payment ID (hex encoded). With 64 bit IDs, there is a non-negligible chance of a collision if they are randomly generated. It is up to recipients generating them to sanity check for uniqueness.
1 million IDs at 64-bit (simplified): 1,000,000^2 / (2^64 * 2) = ~1/36,893,488 so there is a 50% chance a collision happens around 5.06 billion IDs generated.
func XMRToDecimal ¶
XMRToDecimal converts a raw atomic XMR balance to a more human readable format.
func XMRToFloat64 ¶
XMRToFloat64 converts raw atomic XMR to a float64
Types ¶
type AddressBookEntry ¶
type AddressBookEntry struct { Address string `json:"address"` Description string `json:"description,omitempty"` Index uint64 `json:"index,omitempty"` PaymentID string `json:"payment_id,omitempty"` }
AddressBookEntry Address
type Client ¶
type Client interface { // Return the wallet's balance. GetBalance() (balance, unlockedBalance uint64, err error) // Return the wallet's address. // address - string; The 95-character hex address string of the monero-wallet-rpc in session. GetAddress() (address string, err error) // GetHeight - Returns the wallet's current block height. // height - unsigned int; The current monero-wallet-rpc's blockchain height. // If the wallet has been offline for a long time, it may need to catch up with the daemon. GetHeight() (height uint64, err error) // Transfer - Send monero to a number of recipients. Transfer(req TransferRequest) (resp *TransferResponse, err error) // Same as transfer, but can split into more than one tx if necessary. TransferSplit(req TransferRequest) (resp *TransferSplitResponse, err error) // Send all dust outputs back to the wallet's, to make them easier to spend (and mix). SweepDust() (txHashList []string, err error) // Send all unlocked balance to an address. SweepAll(req SweepAllRequest) (resp *SweepAllResponse, err error) // Save the blockchain. Store() error // Get a list of incoming payments using a given payment id. GetPayments(paymentid string) (payments []Payment, err error) // Get a list of incoming payments using a given payment id, or a list of // payments ids, from a given height. This method is the preferred method // over get_payments because it has the same functionality but is more extendable. // Either is fine for looking up transactions by a single payment ID. // Inputs: // // payment_ids - array of: string // min_block_height - unsigned int; The block height at which to start looking for payments. GetBulkPayments(paymentids []string, minblockheight uint) (payments []Payment, err error) // Returns a list of transfers. GetTransfers(req GetTransfersRequest) (resp *GetTransfersResponse, err error) // Show information about a transfer to/from this address. GetTransferByTxID(txid string) (transfer *Transfer, err error) // Return a list of incoming transfers to the wallet. IncomingTransfers(transfertype GetTransferType) (transfers []IncTransfer, err error) // Return the spend or view private key (or mnemonic seed). QueryKey(keytype QueryKeyType) (key string, err error) // Make an integrated address from the wallet address and a payment id. // payment_id - string; hex encoded; can be empty, in which case a random payment id is generated MakeIntegratedAddress(paymentid string) (integratedaddr string, err error) // Retrieve the standard address and payment id corresponding to an integrated address. SplitIntegratedAddress(integratedaddr string) (paymentid, address string, err error) // Stops the wallet, storing the current state. StopWallet() error // Create a payment URI using the official URI spec. MakeURI(req URIDef) (uri string, err error) // Parse a payment URI to get payment information. ParseURI(uri string) (parsed *URIDef, err error) // Rescan blockchain from scratch. RescanBlockchain() error // Set arbitrary string notes for transactions. SetTxNotes(txids, notes []string) error // Get string notes for transactions. GetTxNotes(txids []string) (notes []string, err error) // Sign a string. Sign(data string) (signature string, err error) // Verify a signature on a string. Verify(data, address, signature string) (good bool, err error) // Export a signed set of key images. ExportKeyImages() (signedkeyimages []SignedKeyImage, err error) // Import signed key images list and verify their spent status. ImportKeyImages(signedkeyimages []SignedKeyImage) (resp *ImportKeyImageResponse, err error) // Retrieves entries from the address book. // indexes - array of unsigned int; indices of the requested address book entries GetAddressBook(indexes []uint64) (entries []AddressBookEntry, err error) // Add an entry to the address book. AddAddressBook(entry AddressBookEntry) (index uint64, err error) // Delete an entry from the address book. DeleteAddressBook(index uint64) error // Rescan the blockchain for spent outputs. RescanSpent() error // Start mining in the Monero daemon. // Inputs: // // threads_count - unsigned int; Number of threads created for mining // do_background_mining - boolean; // ignore_battery - boolean; StartMining(threads uint, background, ignorebattery bool) error // Stop mining in the Monero daemon. StopMining() error // Get a list of available languages for your wallet's seed. GetLanguages() (languages []string, err error) // Create a new wallet. You need to have set the argument "–wallet-dir" when // launching monero-wallet-rpc to make this work. // Inputs: // // filename - string; // password - string; // language - string; Language for your wallets' seed. CreateWallet(filename, password, language string) error // Open a wallet. You need to have set the argument "–wallet-dir" when // launching monero-wallet-rpc to make this work. OpenWallet(filename, password string) error }
Client is a monero-wallet-rpc client.
type Config ¶
type Config struct { Address string CustomHeaders map[string]string Transport http.RoundTripper }
Config holds the configuration of a monero rpc client.
type Destination ¶
type Destination struct { // Amount - unsigned int; Amount to send to each destination, in atomic units. Amount uint64 `json:"amount"` // Address - string; Destination public address. Address string `json:"address"` }
Destination to receive XMR
type ErrorCode ¶
type ErrorCode int
ErrorCode is a monero-wallet-rpc error code. Copied from https://github.com/monero-project/monero/blob/release-v0.11.0.0/src/wallet/wallet_rpc_server_error_codes.h
const ( // ErrUnknown - E_UNKNOWN_ERROR ErrUnknown ErrorCode = -1 // ErrWrongAddress - E_WRONG_ADDRESS ErrWrongAddress ErrorCode = -2 // ErrDaemonIsBusy - E_DAEMON_IS_BUSY ErrDaemonIsBusy ErrorCode = -3 // ErrGenericTransferError - E_GENERIC_TRANSFER_ERROR ErrGenericTransferError ErrorCode = -4 // ErrWrongPaymentID - E_WRONG_PAYMENT_ID ErrWrongPaymentID ErrorCode = -5 // ErrTransferType - E_TRANSFER_TYPE ErrTransferType ErrorCode = -6 // ErrDenied - E_DENIED ErrDenied ErrorCode = -7 // ErrWrongTxID - E_WRONG_TXID ErrWrongTxID ErrorCode = -8 // ErrWrongSignature - E_WRONG_SIGNATURE ErrWrongSignature ErrorCode = -9 // ErrWrongKeyImage - E_WRONG_KEY_IMAGE ErrWrongKeyImage ErrorCode = -10 // ErrWrongURI - E_WRONG_URI ErrWrongURI ErrorCode = -11 // ErrWrongIndex - E_WRONG_INDEX ErrWrongIndex ErrorCode = -12 // ErrNotOpen - E_NOT_OPEN ErrNotOpen ErrorCode = -13 )
type GetTransferType ¶
type GetTransferType string
GetTransferType is a string that contains the possible types: "all": all the transfers; "available": only transfers which are not yet spent; "unavailable": only transfers which are already spent.
const ( // TransferAll - all the transfers TransferAll GetTransferType = "all" // TransferAvailable - only transfers which are not yet spent TransferAvailable GetTransferType = "available" TransferUnavailable GetTransferType = "unavailable" )
type GetTransfersRequest ¶
type GetTransfersRequest struct { In bool `json:"in"` Out bool `json:"out"` Pending bool `json:"pending"` Failed bool `json:"failed"` Pool bool `json:"pool"` FilterByHeight bool `json:"filter_by_height"` MinHeight uint64 `json:"min_height"` MaxHeight uint64 `json:"max_height"` }
GetTransfersRequest = GetTransfers body
type GetTransfersResponse ¶
type GetTransfersResponse struct { In []Transfer `json:"in"` Out []Transfer `json:"out"` Pending []Transfer `json:"pending"` Failed []Transfer `json:"failed"` Pool []Transfer `json:"pool"` }
GetTransfersResponse = GetTransfers output
type ImportKeyImageResponse ¶
type ImportKeyImageResponse struct { Height uint64 `json:"height"` Spent uint64 `json:"spent"` Unspent uint64 `json:"unspent"` }
ImportKeyImageResponse is the result of ImportKeyImages()
type IncTransfer ¶
type IncTransfer struct { Amount uint64 `json:"amount"` Spent bool `json:"spent"` // Mostly internal use, can be ignored by most users. GlobalIndex uint64 `json:"global_index"` // Several incoming transfers may share the same hash // if they were in the same transaction. TxHash string `json:"tx_hash"` TxSize uint64 `json:"tx_size"` }
IncTransfer is returned by IncomingTransfers
type Payment ¶
type Payment struct { PaymentID string `json:"payment_id"` TxHash string `json:"tx_hash"` Amount uint64 `json:"amount"` BlockHeight uint64 `json:"block_height"` UnlockTime uint64 `json:"unlock_time"` }
Payment ...
type QueryKeyType ¶
type QueryKeyType string
QueryKeyType is the parameter to send with client.QueryKey()
const ( // QueryKeyMnemonic is the mnemonic seed QueryKeyMnemonic QueryKeyType = "mnemonic" // QueryKeyView is the private view key QueryKeyView QueryKeyType = "view_key" // QueryKeySpend is the private spend key QueryKeySpend QueryKeyType = "spend_key" //TODO: test )
type SignedKeyImage ¶
type SignedKeyImage struct { KeyImage string `json:"key_image"` Signature string `json:"signature"` }
SignedKeyImage - The key image is an alternate public key computed on a second base point, Hp(P), instead of G. It is required in traceable ring signature construction to ensure multiple signatures with the same real key are linked.
type SweepAllRequest ¶
type SweepAllRequest struct { // address - string; Destination public address. Address string `json:"address"` // priority - unsigned int; (Optional) Priority Priority `json:"priority,omitempty"` // mixin - unsigned int; Number of outpouts from the blockchain to mix with (0 means no mixing). Mixin uint64 `json:"mixin"` // unlock_time - unsigned int; Number of blocks before the monero can be spent (0 to not add a lock). UnlockTime uint64 `json:"unlock_time"` // payment_id - string; (Optional) Random 32-byte/64-character hex string to identify a transaction. PaymentID string `json:"payment_id,omitempty"` // get_tx_keys - boolean; (Optional) Return the transaction keys after sending. GetTxKeys bool `json:"get_tx_keys,omitempty"` // below_amount - unsigned int; (Optional) BelowAmount uint64 `json:"below_amount"` // do_not_relay - boolean; (Optional) DoNotRelay bool `json:"do_not_relay,omitempty"` // get_tx_hex - boolean; (Optional) return the transactions as hex encoded string. GetTxHex bool `json:"get_tx_hex,omitempty"` }
SweepAllRequest is the struct to send all unlocked balance to an address.
type SweepAllResponse ¶
type SweepAllResponse struct { // tx_hash_list - array of: string. The tx hashes of every transaction. TxHashList []string `json:"tx_hash_list"` // tx_blob_list - array of: string. The tx as hex string for every transaction. TxBlobList []string `json:"tx_blob_list"` // tx_key_list - array of: string. The transaction keys for every transaction. TxKeyList []string `json:"tx_key_list"` }
SweepAllResponse is a tipical response of a SweepAllRequest
type Transfer ¶
type Transfer struct { TxID string `json:"txid"` PaymentID string `json:"payment_id"` Height uint64 `json:"height"` Timestamp uint64 `json:"timestamp"` Amount uint64 `json:"amount"` Fee uint64 `json:"fee"` Note string `json:"note"` Destinations []Destination `json:"destinations,omitempty"` // TODO: check if deprecated Type string `json:"type"` }
Transfer is the transfer data of
type TransferRequest ¶
type TransferRequest struct { // Destinations - array of destinations to receive XMR: Destinations []Destination `json:"destinations"` // Fee - unsigned int; Ignored, will be automatically calculated. Fee uint64 `json:"fee,omitempty"` // Mixin - unsigned int; Number of outpouts from the blockchain to mix with (0 means no mixing). Mixin uint64 `json:"mixin"` // unlock_time - unsigned int; Number of blocks before the monero can be spent (0 to not add a lock). UnlockTime uint64 `json:"unlock_time"` // payment_id - string; (Optional) Random 32-byte/64-character hex string to identify a transaction. PaymentID string `json:"payment_id,omitempty"` // get_tx_key - boolean; (Optional) Return the transaction key after sending. GetTxKey bool `json:"get_tx_key"` // priority - unsigned int; Set a priority for the transaction. // Accepted Values are: 0-3 for: default, unimportant, normal, elevated, priority. Priority Priority `json:"priority"` // do_not_relay - boolean; (Optional) If true, the newly created transaction will not be relayed to the monero network. (Defaults to false) DoNotRelay bool `json:"do_not_relay,omitempty"` // get_tx_hex - boolean; Return the transaction as hex string after sending GetTxHex bool `json:"get_tx_hex,omitempty"` }
TransferRequest is the request body of the Transfer client rpc call.
type TransferResponse ¶
type TransferResponse struct { // fee - Integer value of the fee charged for the txn. Fee uint64 `json:"fee"` // tx_hash - String for the publically searchable transaction hash TxHash string `json:"tx_hash"` // tx_key - String for the transaction key if get_tx_key is true, otherwise, blank string. TxKey string `json:"tx_key,omitempty"` // tx_blob - Transaction as hex string if get_tx_hex is true TxBlob string `json:"tx_blob,omitempty"` }
TransferResponse is the successful output of a Client.Transfer()
type TransferSplitResponse ¶
type TransferSplitResponse struct { // fee_list - array of: integer. The amount of fees paid for every transaction. FeeList []uint64 `json:"fee_list"` // tx_hash_list - array of: string. The tx hashes of every transaction. TxHashList []string `json:"tx_hash_list"` // tx_blob_list - array of: string. The tx as hex string for every transaction. TxBlobList []string `json:"tx_blob_list"` // amount_list - array of: integer. The amount transferred for every transaction.. AmountList []uint64 `json:"amount_list"` // tx_key_list - array of: string. The transaction keys for every transaction. TxKeyList []string `json:"tx_key_list"` }
TransferSplitResponse is the successful output of a Client.TransferSplit()
type URIDef ¶
type URIDef struct { // address - wallet address string Address string `json:"address"` // amount (optional) - the integer amount to receive, in atomic units Amount uint64 `json:"amount,omitempty"` // payment_id (optional) - 16 or 64 character hexadecimal payment id string PaymentID string `json:"payment_id,omitempty"` // recipient_name (optional) - string name of the payment recipient RecipientName string `json:"recipient_name,omitempty"` // tx_description (optional) - string describing the reason for the tx TxDescription string `json:"tx_description,omitempty"` }
URIDef is the skeleton of the MakeURI()
type WalletError ¶
WalletError is the error structured returned by the monero-wallet-rpc
func GetWalletError ¶
func GetWalletError(err error) (isWalletError bool, werr *WalletError)
GetWalletError checks if an erro interface is a wallet-rpc error.
func (*WalletError) Error ¶
func (we *WalletError) Error() string