Documentation
¶
Index ¶
- Constants
- func CSRFCheck(store *CSRFStore, handler http.Handler) http.Handler
- func OriginRefererCheck(host string, handler http.Handler) http.Handler
- type APIError
- type BlockchainMetadata
- type CSRFStore
- type CSRFToken
- type Client
- func (c *Client) AddressCount() (uint64, error)
- func (c *Client) AddressTransactions(addr string) ([]ReadableTransaction, error)
- func (c *Client) AddressUxOuts(addr string) ([]*historydb.UxOutJSON, error)
- func (c *Client) Balance(addrs []string) (*wallet.BalancePair, error)
- func (c *Client) BlockByHash(hash string) (*visor.ReadableBlock, error)
- func (c *Client) BlockBySeq(seq uint64) (*visor.ReadableBlock, error)
- func (c *Client) BlockchainMetadata() (*visor.BlockchainMetadata, error)
- func (c *Client) BlockchainProgress() (*daemon.BlockchainProgress, error)
- func (c *Client) Blocks(start, end int) (*visor.ReadableBlocks, error)
- func (c *Client) CSRF() (string, error)
- func (c *Client) CoinSupply() (*CoinSupply, error)
- func (c *Client) ConfirmedTransactions(addrs []string) (*[]visor.TransactionResult, error)
- func (c *Client) CreateEncryptedWallet(seed, label, password string, scanN int) (*WalletResponse, error)
- func (c *Client) CreateTransaction(req CreateTransactionRequest) (*CreateTransactionResponse, error)
- func (c *Client) CreateUnencryptedWallet(seed, label string, scanN int) (*WalletResponse, error)
- func (c *Client) DecryptWallet(id string, password string) (*WalletResponse, error)
- func (c *Client) EncryptWallet(id string, password string) (*WalletResponse, error)
- func (c *Client) Get(endpoint string, obj interface{}) error
- func (c *Client) GetWalletSeed(id string, password string) (string, error)
- func (c *Client) Health() (*HealthResponse, error)
- func (c *Client) InjectTransaction(rawTx string) (string, error)
- func (c *Client) LastBlocks(n int) (*visor.ReadableBlocks, error)
- func (c *Client) NetworkConnection(addr string) (*daemon.Connection, error)
- func (c *Client) NetworkConnections() (*daemon.Connections, error)
- func (c *Client) NetworkDefaultConnections() ([]string, error)
- func (c *Client) NetworkExchangeableConnections() ([]string, error)
- func (c *Client) NetworkTrustedConnections() ([]string, error)
- func (c *Client) NewSeed(entropy int) (string, error)
- func (c *Client) NewWalletAddress(id string, n int, password string) ([]string, error)
- func (c *Client) Outputs() (*visor.ReadableOutputSet, error)
- func (c *Client) OutputsForAddresses(addrs []string) (*visor.ReadableOutputSet, error)
- func (c *Client) OutputsForHashes(hashes []string) (*visor.ReadableOutputSet, error)
- func (c *Client) PendingTransactions() ([]*visor.ReadableUnconfirmedTxn, error)
- func (c *Client) PostForm(endpoints string, body io.Reader, obj interface{}) error
- func (c *Client) PostJSON(endpoints string, reqObj, respObj interface{}) error
- func (c *Client) RawTransaction(txid string) (string, error)
- func (c *Client) ResendUnconfirmedTransactions() (*daemon.ResendResult, error)
- func (c *Client) Richlist(params *RichlistParams) (*Richlist, error)
- func (c *Client) Spend(id, dst string, coins uint64, password string) (*SpendResult, error)
- func (c *Client) Transaction(txid string) (*visor.TransactionResult, error)
- func (c *Client) Transactions(addrs []string) (*[]visor.TransactionResult, error)
- func (c *Client) UnconfirmedTransactions(addrs []string) (*[]visor.TransactionResult, error)
- func (c *Client) UnloadWallet(id string) error
- func (c *Client) UpdateWallet(id, label string) error
- func (c *Client) UxOut(uxID string) (*historydb.UxOutJSON, error)
- func (c *Client) Version() (*visor.BuildInfo, error)
- func (c *Client) Wallet(id string) (*WalletResponse, error)
- func (c *Client) WalletBalance(id string) (*wallet.BalancePair, error)
- func (c *Client) WalletFolderName() (*WalletFolder, error)
- func (c *Client) WalletTransactions(id string) (*UnconfirmedTxnsResponse, error)
- func (c *Client) Wallets() ([]*WalletResponse, error)
- type CoinSupply
- type Config
- type CreateTransactionRequest
- type CreateTransactionRequestWallet
- type CreateTransactionResponse
- type CreatedTransaction
- type CreatedTransactionInput
- type CreatedTransactionOutput
- type Gatewayer
- type HealthResponse
- type HoursSelection
- type ReadableTransaction
- type Receiver
- type Richlist
- type RichlistParams
- type Server
- type SpendResult
- type UnconfirmedTxnsResponse
- type WalletEntry
- type WalletFolder
- type WalletMeta
- type WalletResponse
Constants ¶
const ( // CSRFHeaderName is the name of the CSRF header CSRFHeaderName = "X-CSRF-Token" // CSRFMaxAge is the lifetime of a CSRF token in seconds CSRFMaxAge = time.Second * 30 )
const HTTP401AuthHeader = "SkycoinWallet"
HTTP401AuthHeader WWW-Authenticate value
Variables ¶
This section is empty.
Functions ¶
func OriginRefererCheck ¶
OriginRefererCheck checks the Origin header if present, falling back on Referer. The Origin or Referer hostname must match the configured host. If neither are present, the request is allowed. All major browsers will set at least one of these values. If neither are set, assume it is a request from curl/wget.
Types ¶
type BlockchainMetadata ¶
type BlockchainMetadata struct {
*visor.BlockchainMetadata
TimeSinceLastBlock wh.Duration `json:"time_since_last_block"`
}
BlockchainMetadata extends visor.BlockchainMetadata to include the time since the last block
type Client ¶
Client provides an interface to a remote node's HTTP API
func (*Client) AddressCount ¶
AddressCount makes a request to /addresscount
func (*Client) AddressTransactions ¶
func (c *Client) AddressTransactions(addr string) ([]ReadableTransaction, error)
AddressTransactions makes a request to /explorer/address
func (*Client) AddressUxOuts ¶
AddressUxOuts makes a request to /address_uxouts
func (*Client) Balance ¶
func (c *Client) Balance(addrs []string) (*wallet.BalancePair, error)
Balance makes a request to /balance?addrs=xxx
func (*Client) BlockByHash ¶
func (c *Client) BlockByHash(hash string) (*visor.ReadableBlock, error)
BlockByHash makes a request to /block?hash=xxx
func (*Client) BlockBySeq ¶
func (c *Client) BlockBySeq(seq uint64) (*visor.ReadableBlock, error)
BlockBySeq makes a request to /block?seq=xxx
func (*Client) BlockchainMetadata ¶
func (c *Client) BlockchainMetadata() (*visor.BlockchainMetadata, error)
BlockchainMetadata makes a request to /blockchain/metadata
func (*Client) BlockchainProgress ¶
func (c *Client) BlockchainProgress() (*daemon.BlockchainProgress, error)
BlockchainProgress makes a request to /blockchain/progress
func (*Client) Blocks ¶
func (c *Client) Blocks(start, end int) (*visor.ReadableBlocks, error)
Blocks makes a request to /blocks
func (*Client) CSRF ¶
CSRF returns a CSRF token. If CSRF is disabled on the node, returns an empty string and nil error.
func (*Client) CoinSupply ¶
func (c *Client) CoinSupply() (*CoinSupply, error)
CoinSupply makes a request to /coinSupply
func (*Client) ConfirmedTransactions ¶
func (c *Client) ConfirmedTransactions(addrs []string) (*[]visor.TransactionResult, error)
ConfirmedTransactions makes a request to /transactions?confirmed=true
func (*Client) CreateEncryptedWallet ¶
func (c *Client) CreateEncryptedWallet(seed, label, password string, scanN int) (*WalletResponse, error)
CreateEncryptedWallet makes a request to /wallet/create and try to create a wallet with encryption. If scanN is <= 0, the scan number defaults to 1
func (*Client) CreateTransaction ¶
func (c *Client) CreateTransaction(req CreateTransactionRequest) (*CreateTransactionResponse, error)
CreateTransaction makes a request to POST /wallet/transaction
func (*Client) CreateUnencryptedWallet ¶
func (c *Client) CreateUnencryptedWallet(seed, label string, scanN int) (*WalletResponse, error)
CreateUnencryptedWallet makes a request to /wallet/create and create a wallet without no encryption If scanN is <= 0, the scan number defaults to 1
func (*Client) DecryptWallet ¶
func (c *Client) DecryptWallet(id string, password string) (*WalletResponse, error)
DecryptWallet decrypts wallet by making a request to /wallet/decrypt
func (*Client) EncryptWallet ¶
func (c *Client) EncryptWallet(id string, password string) (*WalletResponse, error)
EncryptWallet encrypts specific wallet with given password
func (*Client) Get ¶
Get makes a GET request to an endpoint and unmarshals the response to obj. If the response is not 200 OK, returns an error
func (*Client) GetWalletSeed ¶
GetWalletSeed makes a request to /wallet/seed
func (*Client) Health ¶
func (c *Client) Health() (*HealthResponse, error)
Health makes a request to /health
func (*Client) InjectTransaction ¶
InjectTransaction makes a request to /injectTransaction
func (*Client) LastBlocks ¶
func (c *Client) LastBlocks(n int) (*visor.ReadableBlocks, error)
LastBlocks makes a request to /last_blocks
func (*Client) NetworkConnection ¶
func (c *Client) NetworkConnection(addr string) (*daemon.Connection, error)
NetworkConnection makes a request to /network/connection
func (*Client) NetworkConnections ¶
func (c *Client) NetworkConnections() (*daemon.Connections, error)
NetworkConnections makes a request to /network/connections
func (*Client) NetworkDefaultConnections ¶
NetworkDefaultConnections makes a request to /network/defaultConnections
func (*Client) NetworkExchangeableConnections ¶
NetworkExchangeableConnections makes a request to /network/connections/exchange
func (*Client) NetworkTrustedConnections ¶
NetworkTrustedConnections makes a request to /network/connections/trust
func (*Client) NewWalletAddress ¶
NewWalletAddress makes a request to /wallet/newAddress if n is <= 0, defaults to 1
func (*Client) Outputs ¶
func (c *Client) Outputs() (*visor.ReadableOutputSet, error)
Outputs makes a request to /outputs
func (*Client) OutputsForAddresses ¶
func (c *Client) OutputsForAddresses(addrs []string) (*visor.ReadableOutputSet, error)
OutputsForAddresses makes a request to /outputs?addrs=xxx
func (*Client) OutputsForHashes ¶
func (c *Client) OutputsForHashes(hashes []string) (*visor.ReadableOutputSet, error)
OutputsForHashes makes a request to /outputs?hashes=zzz
func (*Client) PendingTransactions ¶
func (c *Client) PendingTransactions() ([]*visor.ReadableUnconfirmedTxn, error)
PendingTransactions makes a request to /pendingTxs
func (*Client) PostForm ¶
PostForm makes a POST request to an endpoint with body of "application/x-www-form-urlencoded" formated data.
func (*Client) RawTransaction ¶
RawTransaction makes a request to /rawtx
func (*Client) ResendUnconfirmedTransactions ¶
func (c *Client) ResendUnconfirmedTransactions() (*daemon.ResendResult, error)
ResendUnconfirmedTransactions makes a request to /resendUnconfirmedTxns
func (*Client) Richlist ¶
func (c *Client) Richlist(params *RichlistParams) (*Richlist, error)
Richlist makes a request to /richlist
func (*Client) Transaction ¶
func (c *Client) Transaction(txid string) (*visor.TransactionResult, error)
Transaction makes a request to /transaction
func (*Client) Transactions ¶
func (c *Client) Transactions(addrs []string) (*[]visor.TransactionResult, error)
Transactions makes a request to /transactions
func (*Client) UnconfirmedTransactions ¶
func (c *Client) UnconfirmedTransactions(addrs []string) (*[]visor.TransactionResult, error)
UnconfirmedTransactions makes a request to /transactions?confirmed=false
func (*Client) UnloadWallet ¶
UnloadWallet makes a request to /wallet/unload
func (*Client) UpdateWallet ¶
UpdateWallet makes a request to /wallet/update
func (*Client) Wallet ¶
func (c *Client) Wallet(id string) (*WalletResponse, error)
Wallet makes a request to /wallet
func (*Client) WalletBalance ¶
func (c *Client) WalletBalance(id string) (*wallet.BalancePair, error)
WalletBalance makes a request to /wallet/balance
func (*Client) WalletFolderName ¶
func (c *Client) WalletFolderName() (*WalletFolder, error)
WalletFolderName makes a request to /wallets/folderName
func (*Client) WalletTransactions ¶
func (c *Client) WalletTransactions(id string) (*UnconfirmedTxnsResponse, error)
WalletTransactions makes a request to /wallet/transactions
func (*Client) Wallets ¶
func (c *Client) Wallets() ([]*WalletResponse, error)
Wallets makes a request to /wallets
type CoinSupply ¶
type CoinSupply struct {
// Coins distributed beyond the project:
CurrentSupply string `json:"current_supply"`
// TotalSupply is CurrentSupply plus coins held by the distribution addresses that are spendable
TotalSupply string `json:"total_supply"`
// MaxSupply is the maximum number of coins to be distributed ever
MaxSupply string `json:"max_supply"`
// CurrentCoinHourSupply is coins hours in non distribution addresses
CurrentCoinHourSupply string `json:"current_coinhour_supply"`
// TotalCoinHourSupply is coin hours in all addresses including unlocked distribution addresses
TotalCoinHourSupply string `json:"total_coinhour_supply"`
// Distribution addresses which count towards total supply
UnlockedAddresses []string `json:"unlocked_distribution_addresses"`
// Distribution addresses which are locked and do not count towards total supply
LockedAddresses []string `json:"locked_distribution_addresses"`
}
CoinSupply records the coin supply info
type Config ¶
type Config struct {
StaticDir string
DisableCSRF bool
EnableWalletAPI bool
ReadTimeout time.Duration
WriteTimeout time.Duration
IdleTimeout time.Duration
}
Config configures Server
type CreateTransactionRequest ¶
type CreateTransactionRequest struct {
HoursSelection HoursSelection `json:"hours_selection"`
Wallet CreateTransactionRequestWallet `json:"wallet"`
ChangeAddress string `json:"change_address"`
To []Receiver `json:"to"`
}
CreateTransactionRequest is sent to /wallet/transaction
type CreateTransactionRequestWallet ¶
type CreateTransactionRequestWallet struct {
ID string `json:"id"`
Addresses []string `json:"addresses,omitempty"`
Password string `json:"password"`
}
CreateTransactionRequestWallet defines a wallet to spend from and optionally which addresses in the wallet
type CreateTransactionResponse ¶
type CreateTransactionResponse struct {
Transaction CreatedTransaction `json:"transaction"`
EncodedTransaction string `json:"encoded_transaction"`
}
CreateTransactionResponse is returned by /wallet/transaction
func NewCreateTransactionResponse ¶
func NewCreateTransactionResponse(txn *coin.Transaction, inputs []wallet.UxBalance) (*CreateTransactionResponse, error)
NewCreateTransactionResponse creates a CreateTransactionResponse
type CreatedTransaction ¶
type CreatedTransaction struct {
Length uint32 `json:"length"`
Type uint8 `json:"type"`
TxID string `json:"txid"`
InnerHash string `json:"inner_hash"`
Fee string `json:"fee"`
Sigs []string `json:"sigs"`
In []CreatedTransactionInput `json:"inputs"`
Out []CreatedTransactionOutput `json:"outputs"`
}
CreatedTransaction represents a transaction created by /wallet/transaction
func NewCreatedTransaction ¶
func NewCreatedTransaction(txn *coin.Transaction, inputs []wallet.UxBalance) (*CreatedTransaction, error)
NewCreatedTransaction returns a CreatedTransaction
func (*CreatedTransaction) ToTransaction ¶
func (r *CreatedTransaction) ToTransaction() (*coin.Transaction, error)
ToTransaction converts a CreatedTransaction back to a coin.Transaction
type CreatedTransactionInput ¶
type CreatedTransactionInput struct {
UxID string `json:"uxid"`
Address string `json:"address"`
Coins string `json:"coins"`
Hours string `json:"hours"`
CalculatedHours string `json:"calculated_hours"`
Time uint64 `json:"timestamp"`
Block uint64 `json:"block"`
TxID string `json:"txid"`
}
CreatedTransactionInput is a verbose transaction input
func NewCreatedTransactionInput ¶
func NewCreatedTransactionInput(out wallet.UxBalance) (*CreatedTransactionInput, error)
NewCreatedTransactionInput creates CreatedTransactionInput
type CreatedTransactionOutput ¶
type CreatedTransactionOutput struct {
UxID string `json:"uxid"`
Address string `json:"address"`
Coins string `json:"coins"`
Hours string `json:"hours"`
}
CreatedTransactionOutput is a transaction output
func NewCreatedTransactionOutput ¶
func NewCreatedTransactionOutput(out coin.TransactionOutput, txid cipher.SHA256) (*CreatedTransactionOutput, error)
NewCreatedTransactionOutput creates CreatedTransactionOutput
type Gatewayer ¶
type Gatewayer interface {
Spend(wltID string, password []byte, coins uint64, dest cipher.Address) (*coin.Transaction, error)
CreateTransaction(w wallet.CreateTransactionParams) (*coin.Transaction, []wallet.UxBalance, error)
GetWalletBalance(wltID string) (wallet.BalancePair, error)
GetWallet(wltID string) (*wallet.Wallet, error)
GetWallets() (wallet.Wallets, error)
UpdateWalletLabel(wltID, label string) error
GetWalletUnconfirmedTxns(wltID string) ([]visor.UnconfirmedTxn, error)
CreateWallet(wltName string, options wallet.Options) (*wallet.Wallet, error)
NewAddresses(wltID string, password []byte, n uint64) ([]cipher.Address, error)
GetWalletDir() (string, error)
IsWalletAPIEnabled() bool
EncryptWallet(wltID string, password []byte) (*wallet.Wallet, error)
DecryptWallet(wltID string, password []byte) (*wallet.Wallet, error)
GetWalletSeed(wltID string, password []byte) (string, error)
GetBlockByHash(hash cipher.SHA256) (block coin.SignedBlock, ok bool)
GetBlockBySeq(seq uint64) (block coin.SignedBlock, ok bool)
GetBlocks(start, end uint64) (*visor.ReadableBlocks, error)
GetLastBlocks(num uint64) (*visor.ReadableBlocks, error)
GetBuildInfo() visor.BuildInfo
GetUnspentOutputs(filters ...daemon.OutputsFilter) (*visor.ReadableOutputSet, error)
GetBalanceOfAddrs(addrs []cipher.Address) ([]wallet.BalancePair, error)
GetBlockchainMetadata() (*visor.BlockchainMetadata, error)
GetBlockchainProgress() *daemon.BlockchainProgress
GetConnection(addr string) *daemon.Connection
GetConnections() *daemon.Connections
GetDefaultConnections() []string
GetTrustConnections() []string
GetExchgConnection() []string
GetAllUnconfirmedTxns() []visor.UnconfirmedTxn
GetTransaction(txid cipher.SHA256) (*visor.Transaction, error)
GetTransactions(flts ...visor.TxFilter) ([]visor.Transaction, error)
InjectBroadcastTransaction(txn coin.Transaction) error
ResendUnconfirmedTxns() *daemon.ResendResult
GetUxOutByID(id cipher.SHA256) (*historydb.UxOut, error)
GetAddrUxOuts(addr []cipher.Address) ([]*historydb.UxOut, error)
GetAddressTxns(a cipher.Address) (*visor.TransactionResults, error)
GetRichlist(includeDistribution bool) (visor.Richlist, error)
GetAddressCount() (uint64, error)
GetHealth() (*daemon.Health, error)
UnloadWallet(id string) error
}
Gatewayer interface for Gateway methods
type HealthResponse ¶
type HealthResponse struct {
BlockchainMetadata BlockchainMetadata `json:"blockchain"`
Version visor.BuildInfo `json:"version"`
OpenConnections int `json:"open_connections"`
Uptime wh.Duration `json:"uptime"`
}
HealthResponse is returned by the /health endpoint
type HoursSelection ¶
HoursSelection defines options for hours distribution
type ReadableTransaction ¶
type ReadableTransaction struct {
Status visor.TransactionStatus `json:"status"`
Length uint32 `json:"length"`
Type uint8 `json:"type"`
Hash string `json:"txid"`
InnerHash string `json:"inner_hash"`
Timestamp uint64 `json:"timestamp,omitempty"`
Sigs []string `json:"sigs"`
In []visor.ReadableTransactionInput `json:"inputs"`
Out []visor.ReadableTransactionOutput `json:"outputs"`
}
ReadableTransaction represents readable address transaction
func NewReadableTransaction ¶
func NewReadableTransaction(t visor.TransactionResult, inputs []visor.ReadableTransactionInput) ReadableTransaction
NewReadableTransaction creates readable address transaction
type Receiver ¶
type Receiver struct {
Address string `json:"address"`
Coins string `json:"coins"`
Hours string `json:"hours,omitempty"`
}
Receiver specifies a spend destination
type RichlistParams ¶
RichlistParams are arguments to the /richlist endpoint
type Server ¶
type Server struct {
// contains filtered or unexported fields
}
Server exposes an HTTP API
func CreateHTTPS ¶
func CreateHTTPS(host string, c Config, daemon *daemon.Daemon, certFile, keyFile string) (*Server, error)
CreateHTTPS creates a new Server instance that listens on HTTPS
type SpendResult ¶
type SpendResult struct {
Balance *wallet.BalancePair `json:"balance,omitempty"`
Transaction *visor.ReadableTransaction `json:"txn,omitempty"`
Error string `json:"error,omitempty"`
}
SpendResult represents the result of spending
type UnconfirmedTxnsResponse ¶
type UnconfirmedTxnsResponse struct {
Transactions []visor.ReadableUnconfirmedTxn `json:"transactions"`
}
UnconfirmedTxnsResponse contains unconfirmed transaction data
type WalletEntry ¶
WalletEntry the wallet entry struct
type WalletFolder ¶
type WalletFolder struct {
Address string `json:"address"`
}
WalletFolder struct
type WalletMeta ¶
type WalletMeta struct {
Coin string `json:"coin"`
Filename string `json:"filename"`
Label string `json:"label"`
Type string `json:"type"`
Version string `json:"version"`
CryptoType string `json:"crypto_type"`
Timestamp int64 `json:"timestamp"`
Encrypted bool `json:"encrypted"`
}
WalletMeta the wallet meta struct
type WalletResponse ¶
type WalletResponse struct {
Meta WalletMeta `json:"meta"`
Entries []WalletEntry `json:"entries"`
}
WalletResponse wallet response struct for http apis
func NewWalletResponse ¶
func NewWalletResponse(w *wallet.Wallet) (*WalletResponse, error)
NewWalletResponse creates WalletResponse struct from *wallet.Wallet