Documentation ¶
Index ¶
- Constants
- Variables
- func SeedToString(seed Seed, did mnemonics.DictionaryID) (string, error)
- type AddrResponse
- type BlockManager
- type BlockResponse
- type CPUMiner
- type ConsensusChange
- type ConsensusSet
- type ConsensusSetSubscriber
- type DelayedSiacoinOutputDiff
- type DiffDirection
- type DownloadInfo
- type DownloadRequest
- type EncryptionManager
- type ErasureCoder
- type Explorer
- type ExplorerBlockData
- type ExplorerStatus
- type FcResponse
- type FileContractDiff
- type FileInfo
- type FileUploadParams
- type Gateway
- type Host
- type HostAnnouncement
- type HostDB
- type HostInfo
- type HostSettings
- type KeyManager
- type Miner
- type NetAddress
- type OutputResponse
- type PeerConn
- type ProcessedInput
- type ProcessedOutput
- type ProcessedTransaction
- type RPCFunc
- type RentInfo
- type Renter
- type Seed
- type SiacoinOutputDiff
- type SiafundOutputDiff
- type SiafundPoolDiff
- type TransactionBuilder
- type TransactionPool
- type TransactionPoolSubscriber
- type TransactionResponse
- type Wallet
- type WalletAddress
- type WalletTransactionID
Constants ¶
const ( AcceptResponse = "accept" HostDir = "host" )
const ( TransactionSizeLimit = 16e3 TransactionSetSizeLimit = 100e3 )
const ( WalletDir = "wallet" SeedChecksumSize = 6 PublicKeysPerSeed = 2500 WalletSeedPreloadDepth = 25 )
const (
ExplorerDir = "explorer"
)
const (
GatewayDir = "gateway"
)
const (
HostDBDir = "hostdb"
)
const (
MinerDir = "miner"
)
Variables ¶
var ( ErrBlockKnown = errors.New("block already present in database") ErrNonExtendingBlock = errors.New("block does not extend the longest fork") )
var ( // Each identifier has a version number at the end, which will be // incremented whenever the protocol changes. RPCSettings = types.Specifier{'S', 'e', 't', 't', 'i', 'n', 'g', 's', 0} RPCUpload = types.Specifier{'U', 'p', 'l', 'o', 'a', 'd', 0} RPCRevise = types.Specifier{'R', 'e', 'v', 'i', 's', 'e', 0} RPCDownload = types.Specifier{'D', 'o', 'w', 'n', 'l', 'o', 'a', 'd', 0} )
RPC identifiers
var ( LogSettings = log.Ldate | log.Ltime | log.Lmicroseconds | log.Lshortfile SafeMutexDelay time.Duration )
var ( ErrDuplicateTransactionSet = errors.New("transaction is a duplicate") ErrLargeTransaction = errors.New("transaction is too large for this transaction pool") ErrLargeTransactionSet = errors.New("transaction set is too large for this transaction pool") ErrInvalidArbPrefix = errors.New("transaction contains non-standard arbitrary data") PrefixNonSia = types.Specifier{'N', 'o', 'n', 'S', 'i', 'a'} PrefixStrNonSia = "NonSia" // COMPATv0.3.3.3 TransactionPoolDir = "transactionpool" )
var ( ErrBadEncryptionKey = errors.New("provided encryption key is incorrect") ErrLowBalance = errors.New("insufficient balance") ErrPotentialDoubleSpend = errors.New("wallet has coins spent in unconfirmed transactions - not enough remaining coins to complete transaction") ErrLockedWallet = errors.New("wallet must be unlocked before it can be used") )
var (
BootstrapPeers = []NetAddress{
"23.239.14.98:9981",
"87.98.216.46:9981",
"45.79.132.35:9981",
"68.55.10.144:9981",
"109.206.33.225:9981",
"79.51.183.132:9981",
}
)
TODO: Move this and it's functionality into the gateway package.
var (
PrefixHostAnnouncement = types.Specifier{'H', 'o', 's', 't', 'A', 'n', 'n', 'o', 'u', 'n', 'c', 'e', 'm', 'e', 'n', 't'}
)
var (
RenterDir = "renter"
)
Functions ¶
func SeedToString ¶ added in v1.0.0
SeedToString converts a wallet seed to a human friendly string.
Types ¶
type AddrResponse ¶
type AddrResponse struct { Txns []types.TransactionID ResponseType string }
Wrapper for the address type response
type BlockManager ¶ added in v1.0.0
type BlockManager interface { // BlockForWork returns a block that is ready for nonce grinding. All // blocks returned by BlockForWork have a unique merkle root, meaning that // each can safely start from nonce 0. BlockForWork() (types.Block, crypto.Hash, types.Target, error) // HeaderForWork returns a block header that can be grinded on and // resubmitted to the miner. HeaderForWork() will remember the block that // corresponds to the header for 50 calls. HeaderForWork() (types.BlockHeader, types.Target, error) // SubmitBlock takes a block that has been worked on and has a valid // target. Typically used with external miners. SubmitBlock(types.Block) error // SubmitHeader takes a block header that has been worked on and has a // valid target. A superior choice to SubmitBlock. SubmitHeader(types.BlockHeader) error }
A BlockManager contains functions that can interface with external miners, providing and receiving blocks that have experienced nonce grinding.
type BlockResponse ¶
type BlockResponse struct { Block types.Block Height types.BlockHeight ResponseType string }
The following are used when returning information about a hash (using the GetHashInfo function)
The responseType field is used to differentiate the structs blindly, and must be set
type CPUMiner ¶ added in v1.0.0
type CPUMiner interface { // AddBlock is an extension of FindBlock - AddBlock will submit the block // after finding it. AddBlock() (types.Block, error) // CPUHashrate returns the hashrate of the cpu miner in hashes per second. CPUHashrate() int // Mining returns true if the cpu miner is enabled, and false otherwise. CPUMining() bool // FindBlock will have the miner make 1 attempt to find a solved block that // builds on the current consensus set. It will give up after a few // seconds, returning the block and a bool indicating whether the block is // sovled. FindBlock() (types.Block, error) // StartMining turns on the miner, which will endlessly work for new // blocks. StartCPUMining() // StopMining turns off the miner, but keeps the same number of threads. StopCPUMining() // SolveBlock will have the miner make 1 attempt to solve the input block, // which amounts to trying a few thousand different nonces. SolveBlock is // primarily used for testing. SolveBlock(types.Block, types.Target) (types.Block, bool) }
A CPUMiner provides access to a single-threaded cpu miner.
type ConsensusChange ¶ added in v0.3.3
type ConsensusChange struct { // RevertedBlocks is the list of blocks that were reverted by the change. // The reverted blocks were always all reverted before the applied blocks // were applied. The revered blocks are presented in the order that they // were reverted. RevertedBlocks []types.Block // AppliedBlocks is the list of blocks that were applied by the change. The // applied blocks are always all applied after all the reverted blocks were // reverted. The applied blocks are presented in the order that they were // applied. AppliedBlocks []types.Block // SiacoinOutputDiffs contains the set of siacoin diffs that were applied // to the consensus set in the recent change. The direction for the set of // diffs is 'DiffApply'. SiacoinOutputDiffs []SiacoinOutputDiff // FileContractDiffs contains the set of file contract diffs that were // applied to the consensus set in the recent change. The direction for the // set of diffs is 'DiffApply'. FileContractDiffs []FileContractDiff // SiafundOutputDiffs contains the set of siafund diffs that were applied // to the consensus set in the recent change. The direction for the set of // diffs is 'DiffApply'. SiafundOutputDiffs []SiafundOutputDiff // DelayedSiacoinOutputDiffs contains the set of delayed siacoin output // diffs that were applied to the consensus set in the recent change. DelayedSiacoinOutputDiffs []DelayedSiacoinOutputDiff // SiafundPoolDiffs are the siafund pool diffs that were applied to the // consensus set in the recent change. SiafundPoolDiffs []SiafundPoolDiff }
A ConsensusChange enumerates a set of changes that occured to the consensus set.
func (ConsensusChange) Append ¶ added in v1.0.0
func (cc ConsensusChange) Append(cc2 ConsensusChange) ConsensusChange
Append takes to ConsensusChange objects and adds all of their diffs together.
NOTE: It is possible for diffs to overlap or be inconsistent. This function should only be used with consecutive or disjoint consensus change objects.
type ConsensusSet ¶ added in v0.3.2
type ConsensusSet interface { // AcceptBlock adds a block to consensus. An error will be returned if the // block is invalid, has been seen before, is an orphan, or doesn't // contribute to the heaviest fork known to the consensus set. If the block // does not become the head of the heaviest known fork but is otherwise // valid, it will be remembered by the consensus set but an error will // still be returned. AcceptBlock(types.Block) error // ChildTarget returns the target required to extend the current heaviest // fork. This function is typically used by miners looking to extend the // heaviest fork. ChildTarget(types.BlockID) (types.Target, bool) // Close will shut down the consensus set, giving the module enough time to // run any required closing routines. Close() error // ConsensusChange returns the ith consensus change that was broadcast to // subscribers by the consensus set. An error is returned if i consensus // changes have not been broadcast. The primary purpose of this function is // to rescan the blockchain. ConsensusChange(i int) (ConsensusChange, error) // ConsensusSetSubscribe will subscribe another module to the consensus // set. Every time that there is a change to the consensus set, an update // will be sent to the module via the 'ReceiveConsensusSetUpdate' function. // This is a thread-safe way of managing updates. ConsensusSetSubscribe(ConsensusSetSubscriber) // EarliestChildTimestamp returns the earliest timestamp that is acceptable // on the current longest fork according to the consensus set. This is a // required piece of information for the miner, who could otherwise be at // risk of mining invalid blocks. EarliestChildTimestamp(types.BlockID) (types.Timestamp, bool) // GenesisBlock returns the genesis block. GenesisBlock() types.Block // InCurrentPath returns true if the block id presented is found in the // current path, false otherwise. InCurrentPath(types.BlockID) bool // TryTransactionSet checks whether the transaction set would be valid if // it were added in the next block. A consensus change is returned // detailing the diffs that would result from the application of the // transaction. TryTransactionSet([]types.Transaction) (ConsensusChange, error) }
A ConsensusSet accepts blocks and builds an understanding of network consensus.
type ConsensusSetSubscriber ¶ added in v0.3.2
type ConsensusSetSubscriber interface { // ProcessConsensusChange sends a consensus update to a module through // a function call. Updates will always be sent in the correct order. ProcessConsensusChange(ConsensusChange) }
A ConsensusSetSubscriber is an object that receives updates to the consensus set every time there is a change in consensus.
type DelayedSiacoinOutputDiff ¶ added in v0.3.3
type DelayedSiacoinOutputDiff struct { Direction DiffDirection ID types.SiacoinOutputID SiacoinOutput types.SiacoinOutput MaturityHeight types.BlockHeight }
A DelayedSiacoinOutputDiff indicates the introduction of a siacoin output that cannot be spent until after maturing for 144 blocks. When the output has matured, a SiacoinOutputDiff will be provided.
type DiffDirection ¶ added in v0.3.1
type DiffDirection bool
A DiffDirection indicates the "direction" of a diff, either applied or reverted. A bool is used to restrict the value to these two possibilities.
const ( ConsensusDir = "consensus" // DiffApply and DiffRevert are the names given to the variables // corresponding to applying and reverting diffs. DiffApply DiffDirection = true DiffRevert DiffDirection = false )
type DownloadInfo ¶
type DownloadInfo interface { // StartTime is when the download was initiated. StartTime() time.Time // Filesize is the size of the file being downloaded. Filesize() uint64 // Received is the number of bytes downloaded so far. Received() uint64 // Destination is the filepath that the file was downloaded into. Destination() string // Nickname is the identifier assigned to the file when it was uploaded. Nickname() string }
DownloadInfo is an interface providing information about a file that has been requested for download.
type DownloadRequest ¶
A DownloadRequest is used to retrieve a particular segment of a file from a host.
type EncryptionManager ¶ added in v1.0.0
type EncryptionManager interface { // Encrypt will encrypt the wallet using the input key. Upon // encryption, a primary seed will be created for the wallet (no seed // exists prior to this point). If the key is blank, then the hash of // the seed that is generated will be used as the key. // // Encrypt can only be called once throughout the life of the wallet, // and will return an error on subsequent calls (even after restarting // the wallet). To reset the wallet, the wallet files must be moved to // a different directory or deleted. Encrypt(masterKey crypto.TwofishKey) (Seed, error) // Encrypted returns whether or not the wallet has been encrypted yet. // After being encrypted for the first time, the wallet can only be // unlocked using the encryption password. Encrypted() bool // Lock deletes all keys in memory and prevents the wallet from being // used to spend coins or extract keys until 'Unlock' is called. Lock() error // Unlock must be called before the wallet is usable. All wallets and // wallet seeds are encrypted by default, and the wallet will not know // which addresses to watch for on the blockchain until unlock has been // called. // // All items in the wallet are encrypted using different keys which are // derived from the master key. Unlock(masterKey crypto.TwofishKey) error // Unlocked returns true if the wallet is currently unlocked, false // otherwise. Unlocked() bool }
EncryptionManager can encrypt, lock, unlock, and indicate the current status of the EncryptionManager.
type ErasureCoder ¶ added in v1.0.0
type ErasureCoder interface { // NumPieces is the number of pieces returned by Encode. NumPieces() int // MinPieces is the minimum number of pieces that must be present to // recover the original data. MinPieces() int // Encode splits data into equal-length pieces, with some pieces // containing parity data. Encode(data []byte) ([][]byte, error) // Recover recovers the original data from pieces (including parity) and // writes it to w. pieces should be identical to the slice returned by // Encode (length and order must be preserved), but with missing elements // set to nil. n is the number of bytes to be written to w; this is // necessary because pieces may have been padded with zeros during // encoding. Recover(pieces [][]byte, n uint64, w io.Writer) error }
An ErasureCoder is an error-correcting encoder and decoder.
type Explorer ¶ added in v1.0.0
type Explorer interface { // Returns a slice of data points about blocks. Called // primarly by the blockdata api call BlockInfo(types.BlockHeight, types.BlockHeight) ([]ExplorerBlockData, error) // Function to return status of a bunch of static variables, // in the form of an ExplorerStatus struct ExplorerStatus() ExplorerStatus // Function to safely shut down the block explorer. Closes the database Close() error // Returns information pertaining to a given hash. The // type of the returned value depends on what the hash // was, so an interface is returned instead (i.e. an // address will return a list of transactions while a // block ID will return a block GetHashInfo([]byte) (interface{}, error) }
The BlockExplorer interface provides access to the block explorer
type ExplorerBlockData ¶
type ExplorerBlockData struct { ID types.BlockID // The id hash of the block Timestamp types.Timestamp // The timestamp on the block Target types.Target // The target the block was mined for Size uint64 // The size in bytes of the marshalled block }
Used for the BlockInfo call
type ExplorerStatus ¶
type ExplorerStatus struct { Height types.BlockHeight Block types.Block Target types.Target MatureTime types.Timestamp TotalCurrency types.Currency ActiveContractCount uint64 ActiveContractCosts types.Currency ActiveContractSize uint64 TotalContractCount uint64 TotalContractCosts types.Currency TotalContractSize uint64 }
Used for the BlockInfo call
type FcResponse ¶
type FcResponse struct { Contract types.TransactionID Revisions []types.TransactionID Proof types.TransactionID ResponseType string }
Wrapper for fcInfo struct, defined in database.go
type FileContractDiff ¶ added in v0.3.1
type FileContractDiff struct { Direction DiffDirection ID types.FileContractID FileContract types.FileContract }
A FileContractDiff indicates the addition or removal of a FileContract in the consensus set.
type FileInfo ¶
type FileInfo interface { // Available indicates whether the file is available for downloading or // not. Available() bool // UploadProgress is a percentage indicating the progress of the file as // it is being uploaded. This percentage is calculated internally (unlike // DownloadInfo) because redundancy schemes complicate the definition of // "progress." Since UploadProgress includes redundancy, files will almost // certainly be Available before UploadProgress == 100. UploadProgress() float32 // Nickname is the nickname of the file. Nickname() string // Filesize is the size of the file. Filesize() uint64 // Expiration is the block height at which the file will expire. Expiration() types.BlockHeight }
FileInfo is an interface providing information about a file.
type FileUploadParams ¶ added in v0.3.1
type FileUploadParams struct { Filename string Duration types.BlockHeight Nickname string ErasureCode ErasureCoder PieceSize uint64 }
FileUploadParams contains the information used by the Renter to upload a file.
type Gateway ¶
type Gateway interface { // Connect establishes a persistent connection to a peer. Connect(NetAddress) error // Disconnect terminates a connection to a peer. Disconnect(NetAddress) error // Address returns the Gateway's address. Address() NetAddress // Peers returns the addresses that the Gateway is currently connected to. Peers() []NetAddress // RegisterRPC registers a function to handle incoming connections that // supply the given RPC ID. RegisterRPC(string, RPCFunc) // RegisterConnectCall registers an RPC name and function to be called // upon connecting to a peer. RegisterConnectCall(string, RPCFunc) // RPC calls an RPC on the given address. RPC cannot be called on an // address that the Gateway is not connected to. RPC(NetAddress, string, RPCFunc) error // Broadcast transmits obj, prefaced by the RPC name, to all of the // Gateway's connected peers in parallel. Broadcast(name string, obj interface{}) // Close safely stops the Gateway's listener process. Close() error }
A Gateway facilitates the interactions between the local node and remote nodes (peers). It relays incoming blocks and transactions to local modules, and broadcasts outgoing blocks and transactions to peers. In a broad sense, it is responsible for ensuring that the local consensus set is consistent with the "network" consensus set.
type Host ¶
type Host interface { // Address returns the host's network address Address() NetAddress // Announce announces the host on the blockchain, returning an error if the // host cannot reach itself or if the external ip address is unknown. Announce() error // ForceAnnounce announces the specified address on the blockchain, // regardless of connectivity. ForceAnnounce(NetAddress) error // SetConfig sets the hosting parameters of the host. SetSettings(HostSettings) // Settings returns the host's settings. Settings() HostSettings // Info returns info about the host, including its hosting parameters, the // amount of storage remaining, and the number of active contracts. Info() HostInfo // Close saves the state of the host and stops its listener process. Close() error }
type HostAnnouncement ¶
type HostAnnouncement struct {
IPAddress NetAddress
}
HostAnnouncements are stored in the Arbitrary Data section of transactions on the blockchain. They announce the willingness of a node to host files. Renters can contact the host privately to obtain more detailed hosting parameters (see HostSettings). To mitigate Sybil attacks, HostAnnouncements are paired with a volume of 'frozen' coins. The FreezeIndex indicates which output in the transaction contains the frozen coins, and the SpendConditions indicate the number of blocks the coins are frozen for.
type HostDB ¶
type HostDB interface { // ActiveHosts returns the list of hosts that are actively being selected // from. ActiveHosts() []HostSettings // AllHosts returns the full list of hosts known to the hostdb. AllHosts() []HostSettings // InsertHost adds a host to the database. InsertHost(HostSettings) error // RandomHosts will pull up to 'num' random hosts from the hostdb. There // will be no repeats, but the length of the slice returned may be less // than 'num', and may even be 0. The hosts returned first have the higher // priority. RandomHosts(num int) []HostSettings // Remove deletes the host with the input address from the database. RemoveHost(NetAddress) error }
A HostDB is a database of hosts that the renter can use for figuring out who to upload to, and download from.
type HostInfo ¶
type HostInfo struct { HostSettings StorageRemaining int64 NumContracts int Profit types.Currency PotentialProfit types.Currency Competition types.Currency }
HostInfo contains HostSettings and details pertinent to the host's understanding of their offered services
type HostSettings ¶
type HostSettings struct { IPAddress NetAddress TotalStorage int64 // Can go negative. MinFilesize uint64 MaxFilesize uint64 MinDuration types.BlockHeight MaxDuration types.BlockHeight WindowSize types.BlockHeight Price types.Currency Collateral types.Currency UnlockHash types.UnlockHash }
HostSettings are the parameters advertised by the host. These are the values that the HostDB will request from the host in order to build its database.
type KeyManager ¶ added in v1.0.0
type KeyManager interface { // AllAddresses returns all addresses that the wallet is able to spend // from, including unseeded addresses. Addresses are returned sorted in // byte-order. AllAddresses() []types.UnlockHash // AllSeeds returns all of the seeds that are being tracked by the // wallet, including the primary seed. Only the primary seed is used to // generate new addresses, but the wallet can spend funds sent to // public keys generated by any of the seeds returned. AllSeeds() ([]Seed, error) // PrimarySeed returns the current primary seed of the wallet, // unencrypted, with an int indicating how many addresses have been // consumed. PrimarySeed() (Seed, uint64, error) // NextAddress returns a new coin addresses generated from the // primary seed. NextAddress() (types.UnlockConditions, error) // CreateBackup will create a backup of the wallet at the provided // filepath. The backup will have all seeds and keys. CreateBackup(string) error // Load033xWallet will load a version 0.3.3.x wallet from disk and add all of // the keys in the wallet as unseeded keys. Load033xWallet(crypto.TwofishKey, string) error // LoadSeed will recreate a wallet file using the recovery phrase. // LoadSeed only needs to be called if the original seed file or // encryption password was lost. The master key is used encrypt the // recovery seed before saving it to disk. LoadSeed(crypto.TwofishKey, Seed) error // LoadSiagKeys will take a set of filepaths that point to a siag key // and will have the siag keys loaded into the wallet so that they will // become spendable. LoadSiagKeys(crypto.TwofishKey, []string) error }
KeyManager manages wallet keys, including the use of seeds, creating and loading backups, and providing a layer of compatibility for older wallet files.
type Miner ¶ added in v0.3.1
type Miner interface { BlockManager CPUMiner // BlocksMined returns the number of blocks and stale blocks that have been // mined using this miner. BlocksMined() (goodBlocks, staleBlocks int) }
The Miner interface provides access to mining features.
type NetAddress ¶
type NetAddress string
A NetAddress contains the information needed to contact a peer.
func (NetAddress) Host ¶
func (na NetAddress) Host() string
Host removes the port from a NetAddress, returning just the host. If the address is invalid, the empty string is returned.
func (NetAddress) IsLocal ¶ added in v1.0.3
func (na NetAddress) IsLocal() bool
IsLocal returns true for ip addresses that are on the same machine.
func (NetAddress) IsValid ¶ added in v1.0.0
func (na NetAddress) IsValid() bool
IsValid does nothing. Please ignore it.
func (NetAddress) Port ¶
func (na NetAddress) Port() string
Port returns the NetAddress object's port number. The empty string is returned if the NetAddress is invalid.
type OutputResponse ¶
type OutputResponse struct { OutputTx types.TransactionID InputTx types.TransactionID ResponseType string }
Used for the BlockInfo call
type PeerConn ¶ added in v0.3.1
A PeerConn is the connection type used when communicating with peers during an RPC. For now it is identical to a net.Conn.
type ProcessedInput ¶ added in v1.0.0
type ProcessedInput struct { FundType types.Specifier `json:"fundtype"` WalletAddress bool `json:"walletaddress"` RelatedAddress types.UnlockHash `json:"relatedaddress"` Value types.Currency `json:"value"` }
A ProcessedInput represents funding to a transaction. The input is coming from an address and going to the outputs. The fund types are 'SiacoinInput', 'SiafundInput'.
type ProcessedOutput ¶ added in v1.0.0
type ProcessedOutput struct { FundType types.Specifier `json:"fundtype"` MaturityHeight types.BlockHeight `json:"maturityheight"` WalletAddress bool `json:"walletaddress"` RelatedAddress types.UnlockHash `json:"relatedaddress"` Value types.Currency `json:"value"` }
A ProcessedOutput is a siacoin output that appears in a transaction. Some outputs mature immediately, some are delayed, and some may never mature at all (in the event of storage proofs).
Fund type can either be 'SiacoinOutput', 'SiafundOutput', 'ClaimOutput', 'MinerPayout', or 'MinerFee'. All outputs except the miner fee create outputs accessible to an address. Miner fees are not spendable, and instead contribute to the block subsidy.
MaturityHeight indicates at what block height the output becomes available. SiacoinInputs and SiafundInputs become available immediately. ClaimInputs and MinerPayouts become available after 144 confirmations.
type ProcessedTransaction ¶ added in v1.0.0
type ProcessedTransaction struct { Transaction types.Transaction `json:"transaction"` TransactionID types.TransactionID `json:"transactionid"` ConfirmationHeight types.BlockHeight `json:"confirmationheight"` ConfirmationTimestamp types.Timestamp `json:"confirmationtimestamp"` Inputs []ProcessedInput `json:"inputs"` Outputs []ProcessedOutput `json:"outputs"` }
A processed transaction is a transaction that has been processed into explicit inputs and outputs and tagged with some header data such as confirmation height + timestamp.
Because of the block subsidy, a block is considered as a transaction. Since there is technically no transaction id for the block subsidy, the block id is used instead.
type RPCFunc ¶
RPCFunc is the type signature of functions that handle RPCs. It is used for both the caller and the callee. RPCFuncs may perform locking. RPCFuncs may close the connection early, and it is recommended that they do so to avoid keeping the connection open after all necessary I/O has been performed.
type Renter ¶
type Renter interface { // DeleteFile deletes a file entry from the renter. DeleteFile(nickname string) error // Download downloads a file to the given filepath. Download(nickname, filepath string) error // DownloadQueue lists all the files that have been scheduled for download. DownloadQueue() []DownloadInfo // FileList returns information on all of the files stored by the renter. FileList() []FileInfo // Info returns the list of all files by nickname. (deprecated) Info() RentInfo // contain multiple files. The nicknames of the added files are returned. LoadSharedFiles(filename string) ([]string, error) // renter. LoadSharedFilesAscii(asciiSia string) ([]string, error) // Rename changes the nickname of a file. RenameFile(currentName, newName string) error ShareFiles(nicknames []string, sharedest string) error ShareFilesAscii(nicknames []string) (asciiSia string, err error) // Upload uploads a file using the input parameters. Upload(FileUploadParams) error }
A Renter uploads, tracks, repairs, and downloads a set of files for the user.
type Seed ¶ added in v1.0.0
type Seed [crypto.EntropySize]byte
AddressSeed is cryptographic entropy that is used to derive spendable wallet addresses.
func StringToSeed ¶ added in v1.0.0
StringToSeed converts a string to a wallet seed.
type SiacoinOutputDiff ¶ added in v0.3.1
type SiacoinOutputDiff struct { Direction DiffDirection ID types.SiacoinOutputID SiacoinOutput types.SiacoinOutput }
A SiacoinOutputDiff indicates the addition or removal of a SiacoinOutput in the consensus set.
type SiafundOutputDiff ¶ added in v0.3.1
type SiafundOutputDiff struct { Direction DiffDirection ID types.SiafundOutputID SiafundOutput types.SiafundOutput }
A SiafundOutputDiff indicates the addition or removal of a SiafundOutput in the consensus set.
type SiafundPoolDiff ¶ added in v0.3.1
type SiafundPoolDiff struct { Direction DiffDirection Previous types.Currency Adjusted types.Currency }
A SiafundPoolDiff contains the value of the siafundPool before the block was applied, and after the block was applied. When applying the diff, set siafundPool to 'Adjusted'. When reverting the diff, set siafundPool to 'Previous'.
type TransactionBuilder ¶ added in v1.0.0
type TransactionBuilder interface { // FundSiacoins will add a siacoin input of exaclty 'amount' to the // transaction. A parent transaction may be needed to achieve an input // with the correct value. The siacoin input will not be signed until // 'Sign' is called on the transaction builder. The expectation is that // the transaction will be completed and broadcast within a few hours. // Longer risks double-spends, as the wallet will assume that the // transaction failed. FundSiacoins(amount types.Currency) error // FundSiafunds will add a siafund input of exaclty 'amount' to the // transaction. A parent transaction may be needed to achieve an input // with the correct value. The siafund input will not be signed until // 'Sign' is called on the transaction builder. Any siacoins that are // released by spending the siafund outputs will be sent to another // address owned by the wallet. The expectation is that the transaction // will be completed and broadcast within a few hours. Longer risks // double-spends, because the wallet will assume the transcation // failed. FundSiafunds(amount types.Currency) error // AddMinerFee adds a miner fee to the transaction, returning the index // of the miner fee within the transaction. AddMinerFee(fee types.Currency) uint64 // AddSiacoinInput adds a siacoin input to the transaction, returning // the index of the siacoin input within the transaction. When 'Sign' // gets called, this input will be left unsigned. AddSiacoinInput(types.SiacoinInput) uint64 // AddSiacoinOutput adds a siacoin output to the transaction, returning // the index of the siacoin output within the transaction. AddSiacoinOutput(types.SiacoinOutput) uint64 // AddFileContract adds a file contract to the transaction, returning // the index of the file contract within the transaction. AddFileContract(types.FileContract) uint64 // AddFileContractRevision adds a file contract revision to the // transaction, returning the index of the file contract revision // within the transaction. When 'Sign' gets called, this revision will // be left unsigned. AddFileContractRevision(types.FileContractRevision) uint64 // AddStorageProof adds a storage proof to the transaction, returning // the index of the storage proof within the transaction. AddStorageProof(types.StorageProof) uint64 // AddSiafundInput adds a siafund input to the transaction, returning // the index of the siafund input within the transaction. When 'Sign' // is called, this input will be left unsigned. AddSiafundInput(types.SiafundInput) uint64 // AddSiafundOutput adds a siafund output to the transaction, returning // the index of the siafund output within the transaction. AddSiafundOutput(types.SiafundOutput) uint64 // AddArbitraryData adds arbitrary data to the transaction, returning // the index of the data within the transaction. AddArbitraryData(arb []byte) uint64 // AddTransactionSignature adds a transaction signature to the // transaction, returning the index of the signature within the // transaction. The signature should already be valid, and shouldn't // sign any of the inputs that were added by calling 'FundSiacoins' or // 'FundSiafunds'. AddTransactionSignature(types.TransactionSignature) uint64 // Sign will sign any inputs added by 'FundSiacoins' or 'FundSiafunds' // and return a transaction set that contains all parents prepended to // the transaction. If more fields need to be added, a new transaction // builder will need to be created. // // If the whole transaction flag is set to true, then the whole // transaction flag will be set in the covered fields object. If the // whole transaction flag is set to false, then the covered fields // object will cover all fields that have already been added to the // transaction, but will also leave room for more fields to be added. Sign(wholeTransaction bool) ([]types.Transaction, error) // View returns the incomplete transaction along with all of its // parents. View() (txn types.Transaction, parents []types.Transaction) // Drop indicates that a transaction is no longer useful, will not be // broadcast, and that all of the outputs can be reclaimed. 'Drop' // should only be used before signatures are added. Drop() }
TransactionBuilder is used to construct custom transactions. A transaction builder is intialized via 'RegisterTransaction' and then can be modified by adding funds or other fields. The transaction is completed by calling 'Sign', which will sign all inputs added via the 'FundSiacoins' or 'FundSiafunds' call. All modifications are additive.
Parents of the transaction are kept in the transaction builder. A parent is any unconfirmed transaction that is required for the child to be valid.
Transaction builders are not thread safe.
type TransactionPool ¶
type TransactionPool interface { // AcceptTransactionSet accepts a set of potentially interdependent // transactions. AcceptTransactionSet([]types.Transaction) error // COMPAT v0.3.3.3 // // RelayTransaction is an RPC that accepts a transaction set from a // peer. RelayTransaction(PeerConn) error // RelayTransactionSet is an RPC that accepts a transaction set from a // peer. RelayTransactionSet(PeerConn) error // IsStandardTransaction returns `err = nil` if the transaction is // standard, otherwise it returns an error explaining what is not standard. IsStandardTransaction(types.Transaction) error // PurgeTransactionPool is a temporary function available to the miner. In // the event that a miner mines an unacceptable block, the transaction pool // will be purged to clear out the transaction pool and get rid of the // illegal transaction. This should never happen, however there are bugs // that make this condition necessary. PurgeTransactionPool() // TransactionList returns a list of all transactions in the transaction // pool. The transactions are provided in an order that can acceptably be // put into a block. TransactionList() []types.Transaction // TransactionPoolSubscribe adds a subscriber to the transaction pool. // Subscribers will receive all consensus set changes as well as // transaction pool changes, and should not subscribe to both. TransactionPoolSubscribe(TransactionPoolSubscriber) }
A TransactionPool manages unconfirmed transactions.
type TransactionPoolSubscriber ¶ added in v0.3.1
type TransactionPoolSubscriber interface { // All transaction pool subscribers must also be able to receive consensus // set updates. ConsensusSetSubscriber // ReceiveTransactionPoolUpdate notifies subscribers of a change to the // consensus set and/or unconfirmed set, and includes the consensus change // that would result if all of the transactions made it into a block. ReceiveUpdatedUnconfirmedTransactions([]types.Transaction, ConsensusChange) }
A TransactionPoolSubscriber receives updates about the confirmed and unconfirmed set from the transaction pool. Generally, there is no need to subscribe to both the consensus set and the transaction pool.
type TransactionResponse ¶
type TransactionResponse struct { Tx types.Transaction ParentID types.BlockID TxNum int ResponseType string }
Wrapper for a transaction, with a little extra info
type Wallet ¶
type Wallet interface { EncryptionManager KeyManager // ConfirmedBalance returns the confirmed balance of the wallet, minus // any outgoing transactions. ConfirmedBalance will include unconfirmed // refund transacitons. ConfirmedBalance() (siacoinBalance types.Currency, siafundBalance types.Currency, siacoinClaimBalance types.Currency) // UnconfirmedBalance returns the unconfirmed balance of the wallet. // Outgoing funds and incoming funds are reported separately. Refund // outputs are included, meaning that a sending a single coin to // someone could result in 'outgoing: 12, incoming: 11'. Siafunds are // not considered in the unconfirmed balance. UnconfirmedBalance() (outgoingSiacoins types.Currency, incomingSiacoins types.Currency) // AddressTransactions returns all of the transactions that are related // to a given address. AddressTransactions(types.UnlockHash) []ProcessedTransaction // AddressUnconfirmedHistory returns all of the unconfirmed // transactions related to a given address. AddressUnconfirmedTransactions(types.UnlockHash) []ProcessedTransaction // Transaction returns the transaction with the given id. The bool // indicates whether the transaction is in the wallet database. The // wallet only stores transactions that are related to the wallet. Transaction(types.TransactionID) (ProcessedTransaction, bool) // Transactions returns all of the transactions that were confirmed at // heights [startHeight, endHeight]. Unconfirmed transactions are not // included. Transactions(startHeight types.BlockHeight, endHeight types.BlockHeight) ([]ProcessedTransaction, error) // UnconfirmedTransactions returns all unconfirmed transactions // relative to the wallet. UnconfirmedTransactions() []ProcessedTransaction // RegisterTransaction takes a transaction and its parents and returns // a TransactionBuilder which can be used to expand the transaction. // The most typical call is 'RegisterTransaction(types.Transaction{}, // nil)', which registers a new transaction without parents. RegisterTransaction(t types.Transaction, parents []types.Transaction) TransactionBuilder // StartTransaction is a convenience method that calls // RegisterTransaction(types.Transaction{}, nil) StartTransaction() TransactionBuilder // SendSiacoins is a tool for sending siacoins from the wallet to an // address. Sending money usually results in multiple transactions. The // transactions are automatically given to the transaction pool, and // are also returned to the caller. SendSiacoins(amount types.Currency, dest types.UnlockHash) ([]types.Transaction, error) // SendSiafunds is a tool for sending siafunds from the wallet to an // address. Sending money usually results in multiple transactions. The // transactions are automatically given to the transaction pool, and // are also returned to the caller. SendSiafunds(amount types.Currency, dest types.UnlockHash) ([]types.Transaction, error) }
Wallet stores and manages siacoins and siafunds. The wallet file is encrypted using a user-specified password. Common addresses are all dervied from a single address seed.
type WalletAddress ¶
type WalletAddress struct {
Address types.UnlockHash `json:"address"`
}
A WalletAddress is an address. A struct is used so that it can be expanded in the future to include items such as balances.
type WalletTransactionID ¶ added in v1.0.0
WalletTransactionID is a unique identifier for a wallet transaction.
func CalculateWalletTransactionID ¶ added in v1.0.0
func CalculateWalletTransactionID(tid types.TransactionID, oid types.OutputID) WalletTransactionID
CalculateWalletTransactionID is a helper function for determining the id of a wallet transaction.