types

package
v0.10.3 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Feb 28, 2025 License: MIT Imports: 21 Imported by: 109

Documentation ¶

Overview ¶

Package types defines the essential types of the Sia blockchain.

Index ¶

Constants ¶

View Source
const (
	// MaxRevisionNumber is used to finalize a FileContract. When a contract's
	// RevisionNumber is set to this value, no further revisions are possible.
	MaxRevisionNumber = math.MaxUint64

	// RenterContractIndex defines the index of the renter's output and public
	// key in a FileContract.
	RenterContractIndex = 0

	// HostContractIndex defines the index of the host's output and public key in
	// a FileContract.
	HostContractIndex = 1

	// UnassignedLeafIndex is a sentinel value used as the LeafIndex of
	// StateElements that have not been added to the accumulator yet. This is
	// necessary for constructing blocks sets where later transactions reference
	// elements created in earlier transactions.
	//
	// Most clients do not need to reference this value directly, and should
	// instead use the EphemeralSiacoinElement and EphemeralSiafundElement
	// functions to construct dependent transaction sets.
	UnassignedLeafIndex = 10101010101010101010
)

Variables ¶

View Source
var (
	// ZeroCurrency represents zero base units.
	ZeroCurrency Currency

	// MaxCurrency represents the largest possible value for the Currency type.
	MaxCurrency = NewCurrency(math.MaxUint64, math.MaxUint64)

	// HastingsPerSiacoin is the number of hastings (base units) in a siacoin.
	HastingsPerSiacoin = NewCurrency(2003764205206896640, 54210) // 10^24
)
View Source
var (
	SpecifierEd25519       = NewSpecifier("ed25519")
	SpecifierSiacoinOutput = NewSpecifier("siacoin output")
	SpecifierSiafundOutput = NewSpecifier("siafund output")
	SpecifierFileContract  = NewSpecifier("file contract")
	SpecifierStorageProof  = NewSpecifier("storage proof")
	SpecifierFoundation    = NewSpecifier("foundation")
	SpecifierEntropy       = NewSpecifier("entropy")
)

Various specifiers.

Functions ¶

func CurrentTimestamp ¶

func CurrentTimestamp() time.Time

CurrentTimestamp returns the current time, rounded to the nearest second. The time zone is set to UTC.

func DecodePtr ¶ added in v0.2.7

func DecodePtr[T any, TP interface {
	*T
	DecoderFrom
}](d *Decoder, v **T)

DecodePtr decodes a pointer to an object that implements DecoderFrom.

func DecodePtrCast ¶ added in v0.6.3

func DecodePtrCast[T interface {
	Cast() V
}, TP interface {
	*T
	DecoderFrom
}, V any](d *Decoder, p **V)

DecodePtrCast decodes a pointer to an object by casting it to V.

func DecodeSlice ¶ added in v0.2.7

func DecodeSlice[T any, DF interface {
	*T
	DecoderFrom
}](d *Decoder, s *[]T)

DecodeSlice decodes a length-prefixed slice of type T, containing values read from the decoder.

func DecodeSliceCast ¶ added in v0.2.7

func DecodeSliceCast[V any, T any, VF interface {
	*V
	Cast() T
	DecoderFrom
}](d *Decoder, s *[]T)

DecodeSliceCast decodes a length-prefixed slice of type T, casting through type V.

func DecodeSliceFn ¶ added in v0.2.7

func DecodeSliceFn[T any](d *Decoder, s *[]T, fn func(*Decoder) T)

DecodeSliceFn decodes a length-prefixed slice of type T, calling an explicit function to decode each element.

func EncodePtr ¶ added in v0.2.7

func EncodePtr[T any, P interface {
	*T
	EncoderTo
}](e *Encoder, p P)

EncodePtr encodes a pointer to an object that implements EncoderTo.

func EncodePtrCast ¶ added in v0.6.3

func EncodePtrCast[V interface {
	Cast() T
	EncoderTo
}, T any](e *Encoder, p *T)

EncodePtrCast encodes a pointer to an object by casting it to V.

func EncodeSlice ¶ added in v0.2.7

func EncodeSlice[T EncoderTo](e *Encoder, s []T)

EncodeSlice encodes a slice of objects that implement EncoderTo.

func EncodeSliceCast ¶ added in v0.2.7

func EncodeSliceCast[V interface {
	Cast() T
	EncoderTo
}, T any](e *Encoder, s []T)

EncodeSliceCast encodes a slice of objects by casting them to V.

func EncodeSliceFn ¶ added in v0.2.7

func EncodeSliceFn[T any](e *Encoder, s []T, fn func(*Encoder, T))

EncodeSliceFn encodes a slice of objects by calling an explicit function to encode each element.

Types ¶

type Address ¶

type Address Hash256

An Address is the hash of a set of UnlockConditions.

var VoidAddress Address

VoidAddress is an address whose signing key does not exist. Sending coins to this address ensures that they will never be recoverable by anyone.

func ParseAddress ¶

func ParseAddress(s string) (a Address, err error)

ParseAddress parses an address from a prefixed hex encoded string.

func StandardAddress ¶ added in v0.1.12

func StandardAddress(pk PublicKey) Address

StandardAddress returns the standard v2 Address derived from pk. It is equivalent to PolicyPublicKey(pk).Address().

func StandardUnlockHash ¶ added in v0.1.12

func StandardUnlockHash(pk PublicKey) Address

StandardUnlockHash returns the standard UnlockHash derived from pk. It is equivalent to SpendPolicy{PolicyUnlockConditions(StandardUnlockConditions(pk))}.Address().

func (*Address) DecodeFrom ¶

func (a *Address) DecodeFrom(d *Decoder)

DecodeFrom implements types.DecoderFrom.

func (Address) EncodeTo ¶

func (a Address) EncodeTo(e *Encoder)

EncodeTo implements types.EncoderTo.

func (Address) MarshalText ¶

func (a Address) MarshalText() ([]byte, error)

MarshalText implements encoding.TextMarshaler.

func (Address) String ¶

func (a Address) String() string

String implements fmt.Stringer.

func (*Address) UnmarshalText ¶

func (a *Address) UnmarshalText(b []byte) error

UnmarshalText implements encoding.TextUnmarshaler.

type Attestation ¶ added in v0.1.12

type Attestation struct {
	PublicKey PublicKey `json:"publicKey"`
	Key       string    `json:"key"`
	Value     []byte    `json:"value"`
	Signature Signature `json:"signature"`
}

An Attestation associates a key-value pair with an identity. For example, hosts attest to their network address by setting Key to "HostAnnouncement" and Value to their address, thereby allowing renters to discover them. Generally, an attestation for a particular key is considered to overwrite any previous attestations with the same key. (This allows hosts to announce a new network address, for example.)

func (*Attestation) DecodeFrom ¶ added in v0.1.12

func (a *Attestation) DecodeFrom(d *Decoder)

DecodeFrom implements types.DecoderFrom.

func (Attestation) EncodeTo ¶ added in v0.1.12

func (a Attestation) EncodeTo(e *Encoder)

EncodeTo implements types.EncoderTo.

type AttestationElement ¶ added in v0.1.12

type AttestationElement struct {
	ID           AttestationID `json:"id"`
	StateElement StateElement  `json:"stateElement"`
	Attestation  Attestation   `json:"attestation"`
}

An AttestationElement is a record of an Attestation within the state accumulator.

type AttestationID ¶ added in v0.6.0

type AttestationID Hash256

An AttestationID uniquely identifies an attestation.

func (*AttestationID) DecodeFrom ¶ added in v0.6.1

func (id *AttestationID) DecodeFrom(d *Decoder)

DecodeFrom implements types.DecoderFrom.

func (AttestationID) EncodeTo ¶ added in v0.6.1

func (id AttestationID) EncodeTo(e *Encoder)

EncodeTo implements types.EncoderTo.

func (AttestationID) MarshalText ¶ added in v0.6.1

func (aid AttestationID) MarshalText() ([]byte, error)

MarshalText implements encoding.TextMarshaler.

func (AttestationID) String ¶ added in v0.6.1

func (aid AttestationID) String() string

String implements fmt.Stringer.

func (*AttestationID) UnmarshalText ¶ added in v0.6.1

func (aid *AttestationID) UnmarshalText(b []byte) error

UnmarshalText implements encoding.TextUnmarshaler.

type Block ¶

type Block struct {
	ParentID     BlockID         `json:"parentID"`
	Nonce        uint64          `json:"nonce"`
	Timestamp    time.Time       `json:"timestamp"`
	MinerPayouts []SiacoinOutput `json:"minerPayouts"`
	Transactions []Transaction   `json:"transactions"`

	V2 *V2BlockData `json:"v2,omitempty"`
}

A Block is a timestamped set of transactions, immutably linked to a previous block, secured by proof-of-work.

func (*Block) Header ¶

func (b *Block) Header() BlockHeader

Header returns the block's header.

func (*Block) ID ¶

func (b *Block) ID() BlockID

ID returns a hash that uniquely identifies a block.

func (*Block) V2Transactions ¶ added in v0.1.12

func (b *Block) V2Transactions() []V2Transaction

V2Transactions returns the block's v2 transactions, if present.

type BlockHeader ¶

type BlockHeader struct {
	ParentID   BlockID   `json:"parentID"`
	Nonce      uint64    `json:"nonce"`
	Timestamp  time.Time `json:"timestamp"`
	Commitment Hash256   `json:"commitment"`
}

A BlockHeader is the preimage of a Block's ID.

func (*BlockHeader) DecodeFrom ¶

func (h *BlockHeader) DecodeFrom(d *Decoder)

DecodeFrom implements types.DecoderFrom.

func (BlockHeader) EncodeTo ¶

func (h BlockHeader) EncodeTo(e *Encoder)

EncodeTo implements types.EncoderTo.

func (BlockHeader) ID ¶

func (bh BlockHeader) ID() BlockID

ID returns the hash of the header data.

type BlockID ¶

type BlockID Hash256

A BlockID uniquely identifies a block.

func (BlockID) CmpWork ¶ added in v0.1.8

func (bid BlockID) CmpWork(t BlockID) int

CmpWork compares the work implied by two BlockIDs.

func (*BlockID) DecodeFrom ¶

func (id *BlockID) DecodeFrom(d *Decoder)

DecodeFrom implements types.DecoderFrom.

func (BlockID) EncodeTo ¶

func (id BlockID) EncodeTo(e *Encoder)

EncodeTo implements types.EncoderTo.

func (BlockID) FoundationOutputID ¶

func (bid BlockID) FoundationOutputID() SiacoinOutputID

FoundationOutputID returns the ID of the block's Foundation subsidy.

func (BlockID) MarshalText ¶

func (bid BlockID) MarshalText() ([]byte, error)

MarshalText implements encoding.TextMarshaler.

func (BlockID) MinerOutputID ¶

func (bid BlockID) MinerOutputID(i int) SiacoinOutputID

MinerOutputID returns the ID of the block's i'th miner payout.

func (BlockID) String ¶

func (bid BlockID) String() string

String implements fmt.Stringer.

func (*BlockID) UnmarshalText ¶

func (bid *BlockID) UnmarshalText(b []byte) error

UnmarshalText implements encoding.TextUnmarshaler.

type ChainIndex ¶

type ChainIndex struct {
	Height uint64  `json:"height"`
	ID     BlockID `json:"id"`
}

A ChainIndex pairs a block's height with its ID.

func ParseChainIndex ¶

func ParseChainIndex(s string) (ci ChainIndex, err error)

ParseChainIndex parses a chain index from a string.

func (*ChainIndex) DecodeFrom ¶

func (index *ChainIndex) DecodeFrom(d *Decoder)

DecodeFrom implements types.DecoderFrom.

func (ChainIndex) EncodeTo ¶

func (index ChainIndex) EncodeTo(e *Encoder)

EncodeTo implements types.EncoderTo.

func (ChainIndex) MarshalJSON ¶ added in v0.1.11

func (ci ChainIndex) MarshalJSON() ([]byte, error)

MarshalJSON implements json.Marshaler.

func (ChainIndex) MarshalText ¶

func (ci ChainIndex) MarshalText() ([]byte, error)

MarshalText implements encoding.TextMarshaler.

func (ChainIndex) String ¶

func (ci ChainIndex) String() string

String implements fmt.Stringer.

func (*ChainIndex) UnmarshalJSON ¶ added in v0.1.11

func (ci *ChainIndex) UnmarshalJSON(b []byte) error

UnmarshalJSON implements json.Unmarshaler.

func (*ChainIndex) UnmarshalText ¶

func (ci *ChainIndex) UnmarshalText(b []byte) (err error)

UnmarshalText implements encoding.TextUnmarshaler.

type ChainIndexElement ¶ added in v0.1.12

type ChainIndexElement struct {
	ID           BlockID      `json:"id"`
	StateElement StateElement `json:"stateElement"`
	ChainIndex   ChainIndex   `json:"chainIndex"`
}

A ChainIndexElement is a record of a ChainIndex within the state accumulator.

func (*ChainIndexElement) DecodeFrom ¶ added in v0.1.12

func (cie *ChainIndexElement) DecodeFrom(d *Decoder)

DecodeFrom implements types.DecoderFrom.

func (ChainIndexElement) EncodeTo ¶ added in v0.1.12

func (cie ChainIndexElement) EncodeTo(e *Encoder)

EncodeTo implements types.EncoderTo.

type CoveredFields ¶

type CoveredFields struct {
	WholeTransaction      bool     `json:"wholeTransaction,omitempty"`
	SiacoinInputs         []uint64 `json:"siacoinInputs,omitempty"`
	SiacoinOutputs        []uint64 `json:"siacoinOutputs,omitempty"`
	FileContracts         []uint64 `json:"fileContracts,omitempty"`
	FileContractRevisions []uint64 `json:"fileContractRevisions,omitempty"`
	StorageProofs         []uint64 `json:"storageProofs,omitempty"`
	SiafundInputs         []uint64 `json:"siafundInputs,omitempty"`
	SiafundOutputs        []uint64 `json:"siafundOutputs,omitempty"`
	MinerFees             []uint64 `json:"minerFees,omitempty"`
	ArbitraryData         []uint64 `json:"arbitraryData,omitempty"`
	Signatures            []uint64 `json:"signatures,omitempty"`
}

CoveredFields indicates which fields of a transaction are covered by a signature.

func (*CoveredFields) DecodeFrom ¶

func (cf *CoveredFields) DecodeFrom(d *Decoder)

DecodeFrom implements types.DecoderFrom.

func (CoveredFields) EncodeTo ¶

func (cf CoveredFields) EncodeTo(e *Encoder)

EncodeTo implements types.EncoderTo.

type Currency ¶

type Currency struct {
	Lo, Hi uint64
}

Currency represents a quantity of hastings as an unsigned 128-bit number.

func NewCurrency ¶

func NewCurrency(lo, hi uint64) Currency

NewCurrency returns the Currency value (lo,hi).

func NewCurrency64 ¶

func NewCurrency64(c uint64) Currency

NewCurrency64 converts c to a Currency value.

func ParseCurrency ¶

func ParseCurrency(s string) (Currency, error)

ParseCurrency parses s as a Currency value. The format of s should match one of the representations provided by (Currency).Format.

func Siacoins ¶

func Siacoins(n uint32) Currency

Siacoins returns a Currency value representing n siacoins.

func (Currency) Add ¶

func (c Currency) Add(v Currency) Currency

Add returns c+v. If the result would overflow, Add panics.

It is safe to use Add in any context where the sum cannot exceed the total supply of Currency (such as when calculating the balance of a wallet). In less-trusted contexts (such as when validating a transaction), AddWithOverflow should be used instead.

func (Currency) AddWithOverflow ¶

func (c Currency) AddWithOverflow(v Currency) (Currency, bool)

AddWithOverflow returns c+v, along with a boolean indicating whether the result overflowed.

func (Currency) Big ¶

func (c Currency) Big() *big.Int

Big returns c as a *big.Int.

func (Currency) Cmp ¶

func (c Currency) Cmp(v Currency) int

Cmp compares c and v and returns:

-1 if c <  v
 0 if c == v
+1 if c >  v

func (Currency) Div ¶

func (c Currency) Div(v Currency) Currency

Div returns c/v. If v == 0, Div panics.

func (Currency) Div64 ¶

func (c Currency) Div64(v uint64) Currency

Div64 returns c/v. If v == 0, Div panics.

func (Currency) Equals ¶

func (c Currency) Equals(v Currency) bool

Equals returns true if c == v.

Currency values can be compared directly with ==, but use of the Equals method is preferred for consistency.

func (Currency) ExactString ¶

func (c Currency) ExactString() string

ExactString returns the base-10 representation of c as a string.

func (Currency) Format ¶

func (c Currency) Format(f fmt.State, v rune)

Format implements fmt.Formatter. It accepts the following formats:

s, v: decimal with unit suffix (equivalent to String())
b, d, o, O, x, X: raw integer, formatted via c.Big().Format

func (Currency) IsZero ¶

func (c Currency) IsZero() bool

IsZero returns true if c == 0.

func (Currency) MarshalText ¶ added in v0.2.2

func (c Currency) MarshalText() ([]byte, error)

MarshalText implements encoding.TextMarshaler.

func (Currency) Mul ¶

func (c Currency) Mul(v Currency) Currency

Mul returns c*v. If the result would overflow, Mul panics.

Note that it is safe to multiply any two Currency values that are below 2^64.

func (Currency) Mul64 ¶

func (c Currency) Mul64(v uint64) Currency

Mul64 returns c*v. If the result would overflow, Mul64 panics.

Note that it is safe to multiply any two Currency values that are below 2^64.

func (Currency) Mul64WithOverflow ¶ added in v0.1.8

func (c Currency) Mul64WithOverflow(v uint64) (Currency, bool)

Mul64WithOverflow returns c*v along with a boolean indicating whether the result overflowed.

Note that it is safe to multiply any two Currency values that are below 2^64.

func (Currency) MulWithOverflow ¶ added in v0.1.8

func (c Currency) MulWithOverflow(v Currency) (Currency, bool)

MulWithOverflow returns c*v, along with a boolean indicating whether the result overflowed.

Note that it is safe to multiply any two Currency values that are below 2^64.

func (Currency) Siacoins ¶ added in v0.2.0

func (c Currency) Siacoins() float64

Siacoins converts c to a floating-point number of siacoins. This may result in a loss of precision.

func (Currency) String ¶

func (c Currency) String() string

String returns the base-10 representation of c with a unit suffix.

func (Currency) Sub ¶

func (c Currency) Sub(v Currency) Currency

Sub returns c-v. If the result would underflow, Sub panics.

func (Currency) SubWithUnderflow ¶

func (c Currency) SubWithUnderflow(v Currency) (Currency, bool)

SubWithUnderflow returns c-v, along with a boolean indicating whether the result underflowed.

func (*Currency) UnmarshalText ¶ added in v0.2.2

func (c *Currency) UnmarshalText(b []byte) (err error)

UnmarshalText implements encoding.TextUnmarshaler.

type Decoder ¶

type Decoder struct {
	// contains filtered or unexported fields
}

A Decoder reads values from an underlying stream. Callers MUST check (*Decoder).Err before using any decoded values.

func NewBufDecoder ¶

func NewBufDecoder(buf []byte) *Decoder

NewBufDecoder returns a Decoder for the provided byte slice.

func NewDecoder ¶

func NewDecoder(lr io.LimitedReader) *Decoder

NewDecoder returns a Decoder that wraps the provided stream.

func (*Decoder) Err ¶

func (d *Decoder) Err() error

Err returns the first error encountered during decoding.

func (*Decoder) Read ¶

func (d *Decoder) Read(p []byte) (int, error)

Read implements the io.Reader interface. It always returns an error if fewer than len(p) bytes were read.

func (*Decoder) ReadBool ¶

func (d *Decoder) ReadBool() bool

ReadBool reads a bool value from the underlying stream.

func (*Decoder) ReadBytes ¶

func (d *Decoder) ReadBytes() []byte

ReadBytes reads a length-prefixed []byte from the underlying stream.

func (*Decoder) ReadString ¶

func (d *Decoder) ReadString() string

ReadString reads a length-prefixed string from the underlying stream.

func (*Decoder) ReadTime ¶

func (d *Decoder) ReadTime() time.Time

ReadTime reads a time.Time from the underlying stream.

func (*Decoder) ReadUint64 ¶

func (d *Decoder) ReadUint64() uint64

ReadUint64 reads a uint64 value from the underlying stream.

func (*Decoder) ReadUint8 ¶

func (d *Decoder) ReadUint8() uint8

ReadUint8 reads a uint8 value from the underlying stream.

func (*Decoder) SetErr ¶

func (d *Decoder) SetErr(err error)

SetErr sets the Decoder's error if it has not already been set. SetErr should only be called from DecodeFrom methods.

type DecoderFrom ¶

type DecoderFrom interface {
	DecodeFrom(d *Decoder)
}

A DecoderFrom can decode itself from a stream via a Decoder.

type DecoderFunc ¶ added in v0.1.12

type DecoderFunc func(*Decoder)

DecoderFunc implements types.DecoderTo with a function.

func (DecoderFunc) DecodeFrom ¶ added in v0.1.12

func (fn DecoderFunc) DecodeFrom(d *Decoder)

DecodeFrom implements types.DecoderTo.

type ElementID ¶ added in v0.6.0

type ElementID = [32]byte

An ElementID identifies a generic element within the state accumulator. In practice, it may be a BlockID, SiacoinOutputID, SiafundOutputID, FileContractID, or AttestationID.

type Encoder ¶

type Encoder struct {
	// contains filtered or unexported fields
}

An Encoder writes Sia objects to an underlying stream.

func NewEncoder ¶

func NewEncoder(w io.Writer) *Encoder

NewEncoder returns an Encoder that wraps the provided stream.

func (*Encoder) Flush ¶

func (e *Encoder) Flush() error

Flush writes any pending data to the underlying stream. It returns the first error encountered by the Encoder.

func (*Encoder) Reset ¶ added in v0.1.12

func (e *Encoder) Reset(w io.Writer)

Reset resets the Encoder to write to w. Any unflushed data, along with any error previously encountered, is discarded.

func (*Encoder) Write ¶

func (e *Encoder) Write(p []byte) (int, error)

Write implements io.Writer.

func (*Encoder) WriteBool ¶

func (e *Encoder) WriteBool(b bool)

WriteBool writes a bool value to the underlying stream.

func (*Encoder) WriteBytes ¶

func (e *Encoder) WriteBytes(b []byte)

WriteBytes writes a length-prefixed []byte to the underlying stream.

func (*Encoder) WriteString ¶

func (e *Encoder) WriteString(s string)

WriteString writes a length-prefixed string to the underlying stream.

func (*Encoder) WriteTime ¶

func (e *Encoder) WriteTime(t time.Time)

WriteTime writes a time.Time value to the underlying stream.

func (*Encoder) WriteUint64 ¶

func (e *Encoder) WriteUint64(u uint64)

WriteUint64 writes a uint64 value to the underlying stream.

func (*Encoder) WriteUint8 ¶

func (e *Encoder) WriteUint8(u uint8)

WriteUint8 writes a uint8 value to the underlying stream.

type EncoderFunc ¶ added in v0.1.12

type EncoderFunc func(*Encoder)

EncoderFunc implements types.EncoderTo with a function.

func (EncoderFunc) EncodeTo ¶ added in v0.1.12

func (fn EncoderFunc) EncodeTo(e *Encoder)

EncodeTo implements types.EncoderTo.

type EncoderTo ¶

type EncoderTo interface {
	EncodeTo(e *Encoder)
}

An EncoderTo can encode itself to a stream via an Encoder.

type FileContract ¶

type FileContract struct {
	Filesize           uint64          `json:"filesize"`
	FileMerkleRoot     Hash256         `json:"fileMerkleRoot"`
	WindowStart        uint64          `json:"windowStart"`
	WindowEnd          uint64          `json:"windowEnd"`
	Payout             Currency        `json:"payout"`
	ValidProofOutputs  []SiacoinOutput `json:"validProofOutputs"`
	MissedProofOutputs []SiacoinOutput `json:"missedProofOutputs"`
	UnlockHash         Address         `json:"unlockHash"`
	RevisionNumber     uint64          `json:"revisionNumber"`
}

A FileContract is a storage agreement between a renter and a host. It contains a bidirectional payment channel that resolves as either "valid" or "missed" depending on whether a valid StorageProof is submitted for the contract.

func (*FileContract) DecodeFrom ¶

func (fc *FileContract) DecodeFrom(d *Decoder)

DecodeFrom implements types.DecoderFrom.

func (FileContract) EncodeTo ¶

func (fc FileContract) EncodeTo(e *Encoder)

EncodeTo implements types.EncoderTo.

func (*FileContract) EndHeight ¶

func (fc *FileContract) EndHeight() uint64

EndHeight returns the height at which the contract's host is no longer obligated to store the contract data.

func (*FileContract) MissedHostOutput ¶

func (fc *FileContract) MissedHostOutput() SiacoinOutput

MissedHostOutput returns the output that will be created for the host if the contract resolves missed.

func (*FileContract) MissedHostPayout ¶

func (fc *FileContract) MissedHostPayout() Currency

MissedHostPayout returns the amount of siacoins that the host will receive if the contract resolves missed.

func (*FileContract) MissedRenterOutput ¶

func (fc *FileContract) MissedRenterOutput() SiacoinOutput

MissedRenterOutput returns the output that will be created for the renter if the contract resolves missed.

func (*FileContract) MissedRenterPayout ¶

func (fc *FileContract) MissedRenterPayout() Currency

MissedRenterPayout returns the amount of siacoins that the renter will receive if the contract resolves missed.

func (*FileContract) ValidHostOutput ¶

func (fc *FileContract) ValidHostOutput() SiacoinOutput

ValidHostOutput returns the output that will be created for the host if the contract resolves valid.

func (*FileContract) ValidHostPayout ¶

func (fc *FileContract) ValidHostPayout() Currency

ValidHostPayout returns the amount of siacoins that the host will receive if the contract resolves valid.

func (*FileContract) ValidRenterOutput ¶

func (fc *FileContract) ValidRenterOutput() SiacoinOutput

ValidRenterOutput returns the output that will be created for the renter if the contract resolves valid.

func (*FileContract) ValidRenterPayout ¶

func (fc *FileContract) ValidRenterPayout() Currency

ValidRenterPayout returns the amount of siacoins that the renter will receive if the contract resolves valid.

type FileContractElement ¶ added in v0.1.12

type FileContractElement struct {
	ID           FileContractID `json:"id"`
	StateElement StateElement   `json:"stateElement"`
	FileContract FileContract   `json:"fileContract"`
}

A FileContractElement is a record of a FileContract within the state accumulator.

func (*FileContractElement) DecodeFrom ¶ added in v0.1.12

func (fce *FileContractElement) DecodeFrom(d *Decoder)

DecodeFrom implements types.DecoderFrom.

func (FileContractElement) EncodeTo ¶ added in v0.1.12

func (fce FileContractElement) EncodeTo(e *Encoder)

EncodeTo implements types.EncoderTo.

type FileContractID ¶

type FileContractID Hash256

A FileContractID uniquely identifies a file contract.

func (*FileContractID) DecodeFrom ¶

func (id *FileContractID) DecodeFrom(d *Decoder)

DecodeFrom implements types.DecoderFrom.

func (FileContractID) EncodeTo ¶

func (id FileContractID) EncodeTo(e *Encoder)

EncodeTo implements types.EncoderTo.

func (FileContractID) MarshalText ¶

func (fcid FileContractID) MarshalText() ([]byte, error)

MarshalText implements encoding.TextMarshaler.

func (FileContractID) MissedOutputID ¶

func (fcid FileContractID) MissedOutputID(i int) SiacoinOutputID

MissedOutputID returns the ID of the missed proof output at index i.

func (FileContractID) String ¶

func (fcid FileContractID) String() string

String implements fmt.Stringer.

func (*FileContractID) UnmarshalText ¶

func (fcid *FileContractID) UnmarshalText(b []byte) error

UnmarshalText implements encoding.TextUnmarshaler.

func (FileContractID) V2HostOutputID ¶ added in v0.1.12

func (fcid FileContractID) V2HostOutputID() SiacoinOutputID

V2HostOutputID returns the ID of the host output for a v2 contract.

func (FileContractID) V2RenewalID ¶ added in v0.1.12

func (fcid FileContractID) V2RenewalID() FileContractID

V2RenewalID returns the ID of the renewal of a v2 contract.

func (FileContractID) V2RenterOutputID ¶ added in v0.1.12

func (fcid FileContractID) V2RenterOutputID() SiacoinOutputID

V2RenterOutputID returns the ID of the renter output for a v2 contract.

func (FileContractID) ValidOutputID ¶

func (fcid FileContractID) ValidOutputID(i int) SiacoinOutputID

ValidOutputID returns the ID of the valid proof output at index i.

type FileContractRevision ¶

type FileContractRevision struct {
	ParentID         FileContractID   `json:"parentID"`
	UnlockConditions UnlockConditions `json:"unlockConditions"`
	// NOTE: the Payout field of the contract is not "really" part of a
	// revision. A revision cannot change the total payout, so the original siad
	// code defines FileContractRevision as an entirely separate struct without
	// a Payout field. Here, we instead reuse the FileContract type, which means
	// we must treat its Payout field as invalid. To guard against developer
	// error, we set it to a sentinel value when decoding it.
	FileContract
}

A FileContractRevision updates the state of an existing file contract.

func (*FileContractRevision) DecodeFrom ¶

func (rev *FileContractRevision) DecodeFrom(d *Decoder)

DecodeFrom implements types.DecoderFrom.

func (FileContractRevision) EncodeTo ¶

func (rev FileContractRevision) EncodeTo(e *Encoder)

EncodeTo implements types.EncoderTo.

func (FileContractRevision) MarshalJSON ¶ added in v0.4.1

func (fcr FileContractRevision) MarshalJSON() ([]byte, error)

MarshalJSON implements json.Marshaler.

func (*FileContractRevision) UnmarshalJSON ¶ added in v0.4.1

func (fcr *FileContractRevision) UnmarshalJSON(b []byte) error

UnmarshalJSON implements json.Unmarshaler.

type FoundationAddressUpdate ¶

type FoundationAddressUpdate struct {
	NewPrimary  Address `json:"newPrimary"`
	NewFailsafe Address `json:"newFailsafe"`
}

A FoundationAddressUpdate updates the primary and failsafe Foundation subsidy addresses.

func (*FoundationAddressUpdate) DecodeFrom ¶

func (fau *FoundationAddressUpdate) DecodeFrom(d *Decoder)

DecodeFrom implements types.DecoderFrom.

func (FoundationAddressUpdate) EncodeTo ¶

func (fau FoundationAddressUpdate) EncodeTo(e *Encoder)

EncodeTo implements types.EncoderTo.

type Hash256 ¶

type Hash256 [32]byte

A Hash256 is a generic 256-bit cryptographic hash.

func HashBytes ¶

func HashBytes(b []byte) Hash256

HashBytes computes the hash of b using Sia's hash function.

func (*Hash256) DecodeFrom ¶

func (h *Hash256) DecodeFrom(d *Decoder)

DecodeFrom implements types.DecoderFrom.

func (Hash256) EncodeTo ¶

func (h Hash256) EncodeTo(e *Encoder)

EncodeTo implements types.EncoderTo.

func (Hash256) MarshalText ¶

func (h Hash256) MarshalText() ([]byte, error)

MarshalText implements encoding.TextMarshaler.

func (Hash256) String ¶

func (h Hash256) String() string

String implements fmt.Stringer.

func (*Hash256) UnmarshalText ¶

func (h *Hash256) UnmarshalText(b []byte) error

UnmarshalText implements encoding.TextUnmarshaler.

type Hasher ¶

type Hasher struct {
	E *Encoder
	// contains filtered or unexported fields
}

A Hasher streams objects into an instance of Sia's hash function.

func NewHasher ¶

func NewHasher() *Hasher

NewHasher returns a new Hasher instance.

func (*Hasher) Reset ¶

func (h *Hasher) Reset()

Reset resets the underlying hash and encoder state.

func (*Hasher) Sum ¶

func (h *Hasher) Sum() (sum Hash256)

Sum returns the digest of the objects written to the Hasher.

func (*Hasher) WriteDistinguisher ¶ added in v0.1.12

func (h *Hasher) WriteDistinguisher(p string)

WriteDistinguisher writes a distinguisher prefix to the encoder.

type PolicyTypeAbove ¶ added in v0.1.12

type PolicyTypeAbove uint64

PolicyTypeAbove requires the input to be spent above a given block height.

type PolicyTypeAfter ¶ added in v0.1.12

type PolicyTypeAfter time.Time

PolicyTypeAfter requires the input to be spent after a given timestamp.

type PolicyTypeHash ¶ added in v0.1.12

type PolicyTypeHash Hash256

PolicyTypeHash requires the input to reveal a SHA256 hash preimage.

type PolicyTypeOpaque ¶ added in v0.1.12

type PolicyTypeOpaque Address

PolicyTypeOpaque is the opaque hash of a policy. It is not satisfiable.

type PolicyTypePublicKey ¶ added in v0.1.12

type PolicyTypePublicKey PublicKey

PolicyTypePublicKey requires the input to be signed by a given key.

type PolicyTypeThreshold ¶ added in v0.1.12

type PolicyTypeThreshold struct {
	N  uint8         `json:"n"`
	Of []SpendPolicy `json:"of"`
}

PolicyTypeThreshold requires at least N sub-policies to be satisfied.

type PolicyTypeUnlockConditions ¶ added in v0.1.12

type PolicyTypeUnlockConditions UnlockConditions

PolicyTypeUnlockConditions reproduces the requirements imposed by Sia's original "UnlockConditions" type. It exists for compatibility purposes and should not be used to construct new policies.

type PrivateKey ¶

type PrivateKey []byte

A PrivateKey is an Ed25519 private key.

func GeneratePrivateKey ¶

func GeneratePrivateKey() PrivateKey

GeneratePrivateKey creates a new private key from a secure entropy source.

func NewPrivateKeyFromSeed ¶

func NewPrivateKeyFromSeed(seed []byte) PrivateKey

NewPrivateKeyFromSeed calculates a private key from a seed.

func (PrivateKey) PublicKey ¶

func (priv PrivateKey) PublicKey() (pk PublicKey)

PublicKey returns the PublicKey corresponding to priv.

func (PrivateKey) SignHash ¶

func (priv PrivateKey) SignHash(h Hash256) (s Signature)

SignHash signs h with priv, producing a Signature.

type PublicKey ¶

type PublicKey [32]byte

A PublicKey is an Ed25519 public key.

func (*PublicKey) DecodeFrom ¶

func (pk *PublicKey) DecodeFrom(d *Decoder)

DecodeFrom implements types.DecoderFrom.

func (PublicKey) EncodeTo ¶

func (pk PublicKey) EncodeTo(e *Encoder)

EncodeTo implements types.EncoderTo.

func (PublicKey) MarshalText ¶

func (pk PublicKey) MarshalText() ([]byte, error)

MarshalText implements encoding.TextMarshaler.

func (PublicKey) String ¶

func (pk PublicKey) String() string

String implements fmt.Stringer.

func (PublicKey) UnlockKey ¶ added in v0.1.2

func (pk PublicKey) UnlockKey() UnlockKey

UnlockKey returns pk as an UnlockKey.

func (*PublicKey) UnmarshalText ¶

func (pk *PublicKey) UnmarshalText(b []byte) error

UnmarshalText implements encoding.TextUnmarshaler.

func (PublicKey) VerifyHash ¶

func (pk PublicKey) VerifyHash(h Hash256, s Signature) bool

VerifyHash verifies that s is a valid signature of h by pk.

type SatisfiedPolicy ¶ added in v0.1.12

type SatisfiedPolicy struct {
	Policy     SpendPolicy
	Signatures []Signature
	Preimages  [][32]byte
}

A SatisfiedPolicy pairs a policy with the signatures and preimages that satisfy it.

func (*SatisfiedPolicy) DecodeFrom ¶ added in v0.1.12

func (sp *SatisfiedPolicy) DecodeFrom(d *Decoder)

DecodeFrom implements types.DecoderFrom.

func (SatisfiedPolicy) EncodeTo ¶ added in v0.1.12

func (sp SatisfiedPolicy) EncodeTo(e *Encoder)

EncodeTo implements types.EncoderTo.

func (SatisfiedPolicy) MarshalJSON ¶ added in v0.1.12

func (sp SatisfiedPolicy) MarshalJSON() ([]byte, error)

MarshalJSON implements json.Marshaler.

func (*SatisfiedPolicy) UnmarshalJSON ¶ added in v0.1.12

func (sp *SatisfiedPolicy) UnmarshalJSON(b []byte) error

UnmarshalJSON implements json.Unmarshaler.

type SiacoinElement ¶ added in v0.1.12

type SiacoinElement struct {
	ID             SiacoinOutputID `json:"id"`
	StateElement   StateElement    `json:"stateElement"`
	SiacoinOutput  SiacoinOutput   `json:"siacoinOutput"`
	MaturityHeight uint64          `json:"maturityHeight"`
}

A SiacoinElement is a record of a SiacoinOutput within the state accumulator.

func (*SiacoinElement) DecodeFrom ¶ added in v0.1.12

func (sce *SiacoinElement) DecodeFrom(d *Decoder)

DecodeFrom implements types.DecoderFrom.

func (SiacoinElement) EncodeTo ¶ added in v0.1.12

func (sce SiacoinElement) EncodeTo(e *Encoder)

EncodeTo implements types.EncoderTo.

type SiacoinInput ¶

type SiacoinInput struct {
	ParentID         SiacoinOutputID  `json:"parentID"`
	UnlockConditions UnlockConditions `json:"unlockConditions"`
}

A SiacoinInput spends an unspent SiacoinOutput in the UTXO set by revealing and satisfying its unlock conditions.

func (*SiacoinInput) DecodeFrom ¶

func (in *SiacoinInput) DecodeFrom(d *Decoder)

DecodeFrom implements types.DecoderFrom.

func (SiacoinInput) EncodeTo ¶

func (in SiacoinInput) EncodeTo(e *Encoder)

EncodeTo implements types.EncoderTo.

type SiacoinOutput ¶

type SiacoinOutput struct {
	Value   Currency `json:"value"`
	Address Address  `json:"address"`
}

A SiacoinOutput is the recipient of some of the siacoins spent in a transaction.

type SiacoinOutputID ¶

type SiacoinOutputID Hash256

A SiacoinOutputID uniquely identifies a siacoin output.

func (*SiacoinOutputID) DecodeFrom ¶

func (id *SiacoinOutputID) DecodeFrom(d *Decoder)

DecodeFrom implements types.DecoderFrom.

func (SiacoinOutputID) EncodeTo ¶

func (id SiacoinOutputID) EncodeTo(e *Encoder)

EncodeTo implements types.EncoderTo.

func (SiacoinOutputID) MarshalText ¶

func (scoid SiacoinOutputID) MarshalText() ([]byte, error)

MarshalText implements encoding.TextMarshaler.

func (SiacoinOutputID) String ¶

func (scoid SiacoinOutputID) String() string

String implements fmt.Stringer.

func (*SiacoinOutputID) UnmarshalText ¶

func (scoid *SiacoinOutputID) UnmarshalText(b []byte) error

UnmarshalText implements encoding.TextUnmarshaler.

type SiafundElement ¶ added in v0.1.12

type SiafundElement struct {
	ID            SiafundOutputID `json:"id"`
	StateElement  StateElement    `json:"stateElement"`
	SiafundOutput SiafundOutput   `json:"siafundOutput"`
	ClaimStart    Currency        `json:"claimStart"` // value of SiafundTaxRevenue when element was created
}

A SiafundElement is a record of a SiafundOutput within the state accumulator.

func (*SiafundElement) DecodeFrom ¶ added in v0.1.12

func (sfe *SiafundElement) DecodeFrom(d *Decoder)

DecodeFrom implements types.DecoderFrom.

func (SiafundElement) EncodeTo ¶ added in v0.1.12

func (sfe SiafundElement) EncodeTo(e *Encoder)

EncodeTo implements types.EncoderTo.

type SiafundInput ¶

type SiafundInput struct {
	ParentID         SiafundOutputID  `json:"parentID"`
	UnlockConditions UnlockConditions `json:"unlockConditions"`
	ClaimAddress     Address          `json:"claimAddress"`
}

A SiafundInput spends an unspent SiafundOutput in the UTXO set by revealing and satisfying its unlock conditions. SiafundInputs also include a ClaimAddress, specifying the recipient of the siacoins that were earned by the output.

func (*SiafundInput) DecodeFrom ¶

func (in *SiafundInput) DecodeFrom(d *Decoder)

DecodeFrom implements types.DecoderFrom.

func (SiafundInput) EncodeTo ¶

func (in SiafundInput) EncodeTo(e *Encoder)

EncodeTo implements types.EncoderTo.

type SiafundOutput ¶

type SiafundOutput struct {
	Value   uint64  `json:"value"`
	Address Address `json:"address"`
}

A SiafundOutput is the recipient of some of the siafunds spent in a transaction.

type SiafundOutputID ¶

type SiafundOutputID Hash256

A SiafundOutputID uniquely identifies a siafund output.

func (SiafundOutputID) ClaimOutputID ¶

func (sfoid SiafundOutputID) ClaimOutputID() SiacoinOutputID

ClaimOutputID returns the ID of the SiacoinOutput that is created when the siafund output is spent.

func (*SiafundOutputID) DecodeFrom ¶

func (id *SiafundOutputID) DecodeFrom(d *Decoder)

DecodeFrom implements types.DecoderFrom.

func (SiafundOutputID) EncodeTo ¶

func (id SiafundOutputID) EncodeTo(e *Encoder)

EncodeTo implements types.EncoderTo.

func (SiafundOutputID) MarshalText ¶

func (sfoid SiafundOutputID) MarshalText() ([]byte, error)

MarshalText implements encoding.TextMarshaler.

func (SiafundOutputID) String ¶

func (sfoid SiafundOutputID) String() string

String implements fmt.Stringer.

func (*SiafundOutputID) UnmarshalText ¶

func (sfoid *SiafundOutputID) UnmarshalText(b []byte) error

UnmarshalText implements encoding.TextUnmarshaler.

func (SiafundOutputID) V2ClaimOutputID ¶ added in v0.1.12

func (sfoid SiafundOutputID) V2ClaimOutputID() SiacoinOutputID

V2ClaimOutputID returns the ID of the SiacoinOutput that is created when the siafund output is spent.

type Signature ¶

type Signature [64]byte

A Signature is an Ed25519 signature.

func (*Signature) DecodeFrom ¶

func (s *Signature) DecodeFrom(d *Decoder)

DecodeFrom implements types.DecoderFrom.

func (Signature) EncodeTo ¶

func (s Signature) EncodeTo(e *Encoder)

EncodeTo implements types.EncoderTo.

func (Signature) MarshalText ¶

func (sig Signature) MarshalText() ([]byte, error)

MarshalText implements encoding.TextMarshaler.

func (Signature) String ¶

func (sig Signature) String() string

String implements fmt.Stringer.

func (*Signature) UnmarshalText ¶

func (sig *Signature) UnmarshalText(b []byte) error

UnmarshalText implements encoding.TextUnmarshaler.

type Specifier ¶

type Specifier [16]byte

A Specifier is a fixed-size, 0-padded identifier.

func NewSpecifier ¶

func NewSpecifier(name string) (s Specifier)

NewSpecifier returns a specifier containing the provided name.

func (*Specifier) DecodeFrom ¶

func (s *Specifier) DecodeFrom(d *Decoder)

DecodeFrom implements types.DecoderFrom.

func (Specifier) EncodeTo ¶

func (s Specifier) EncodeTo(e *Encoder)

EncodeTo implements types.EncoderTo.

func (Specifier) MarshalText ¶

func (s Specifier) MarshalText() ([]byte, error)

MarshalText implements encoding.TextMarshaler.

func (Specifier) String ¶

func (s Specifier) String() string

String implements fmt.Stringer.

func (*Specifier) UnmarshalText ¶

func (s *Specifier) UnmarshalText(b []byte) error

UnmarshalText implements encoding.TextUnmarshaler.

type SpendPolicy ¶ added in v0.1.12

type SpendPolicy struct {
	Type interface {
		// contains filtered or unexported methods
	}
}

A SpendPolicy describes the conditions under which an input may be spent.

func AnyoneCanSpend ¶ added in v0.1.12

func AnyoneCanSpend() SpendPolicy

AnyoneCanSpend returns a policy that has no requirements.

func ParseSpendPolicy ¶ added in v0.1.12

func ParseSpendPolicy(s string) (SpendPolicy, error)

ParseSpendPolicy parses a spend policy from a string.

func PolicyAbove ¶ added in v0.1.12

func PolicyAbove(height uint64) SpendPolicy

PolicyAbove returns a policy that requires the input to be spent above a given block height.

func PolicyAfter ¶ added in v0.1.12

func PolicyAfter(t time.Time) SpendPolicy

PolicyAfter returns a policy that requires the input to be spent after a given timestamp.

func PolicyHash ¶ added in v0.1.12

func PolicyHash(h Hash256) SpendPolicy

PolicyHash returns a policy that requires the input to reveal a SHA256 hash preimage.

func PolicyOpaque ¶ added in v0.1.12

func PolicyOpaque(p SpendPolicy) SpendPolicy

PolicyOpaque returns a policy with the same address as p, but without its semantics.

func PolicyPublicKey ¶ added in v0.1.12

func PolicyPublicKey(pk PublicKey) SpendPolicy

PolicyPublicKey returns a policy that requires the input to be signed by a given key.

func PolicyThreshold ¶ added in v0.1.12

func PolicyThreshold(n uint8, of []SpendPolicy) SpendPolicy

PolicyThreshold returns a policy that requires at least N sub-policies to be satisfied. When satisfying a threshold policy, all unsatisfied sub-policies must be replaced with PolicyOpaque.

func (SpendPolicy) Address ¶ added in v0.1.12

func (p SpendPolicy) Address() Address

Address computes the opaque address for a given policy.

func (*SpendPolicy) DecodeFrom ¶ added in v0.1.12

func (p *SpendPolicy) DecodeFrom(d *Decoder)

DecodeFrom implements types.DecoderFrom.

func (SpendPolicy) EncodeTo ¶ added in v0.1.12

func (p SpendPolicy) EncodeTo(e *Encoder)

EncodeTo implements types.EncoderTo.

func (SpendPolicy) MarshalJSON ¶ added in v0.1.12

func (p SpendPolicy) MarshalJSON() ([]byte, error)

MarshalJSON implements json.Marshaler.

func (SpendPolicy) String ¶ added in v0.1.12

func (p SpendPolicy) String() string

String implements fmt.Stringer.

func (*SpendPolicy) UnmarshalJSON ¶ added in v0.1.12

func (p *SpendPolicy) UnmarshalJSON(b []byte) (err error)

UnmarshalJSON implements json.Unmarshaler.

func (SpendPolicy) Verify ¶ added in v0.1.12

func (p SpendPolicy) Verify(height uint64, medianTimestamp time.Time, sigHash Hash256, sigs []Signature, preimages [][32]byte) error

Verify verifies that p is satisfied by the supplied inputs.

type StateElement ¶ added in v0.1.12

type StateElement struct {
	LeafIndex   uint64    `json:"leafIndex"`
	MerkleProof []Hash256 `json:"merkleProof,omitempty"`
}

A StateElement is a generic element within the state accumulator.

func (*StateElement) DecodeFrom ¶ added in v0.1.12

func (se *StateElement) DecodeFrom(d *Decoder)

DecodeFrom implements types.DecoderFrom.

func (StateElement) EncodeTo ¶ added in v0.1.12

func (se StateElement) EncodeTo(e *Encoder)

EncodeTo implements types.EncoderTo.

type StorageProof ¶

type StorageProof struct {
	ParentID FileContractID
	Leaf     [64]byte
	Proof    []Hash256
}

A StorageProof asserts the presence of a randomly-selected leaf within the Merkle tree of a FileContract's data.

func (*StorageProof) DecodeFrom ¶

func (sp *StorageProof) DecodeFrom(d *Decoder)

DecodeFrom implements types.DecoderFrom.

func (StorageProof) EncodeTo ¶

func (sp StorageProof) EncodeTo(e *Encoder)

EncodeTo implements types.EncoderTo.

func (StorageProof) MarshalJSON ¶ added in v0.1.11

func (sp StorageProof) MarshalJSON() ([]byte, error)

MarshalJSON implements json.Marshaler.

func (*StorageProof) UnmarshalJSON ¶ added in v0.1.11

func (sp *StorageProof) UnmarshalJSON(b []byte) error

UnmarshalJSON implements json.Unmarshaler.

type Transaction ¶

type Transaction struct {
	SiacoinInputs         []SiacoinInput         `json:"siacoinInputs,omitempty"`
	SiacoinOutputs        []SiacoinOutput        `json:"siacoinOutputs,omitempty"`
	FileContracts         []FileContract         `json:"fileContracts,omitempty"`
	FileContractRevisions []FileContractRevision `json:"fileContractRevisions,omitempty"`
	StorageProofs         []StorageProof         `json:"storageProofs,omitempty"`
	SiafundInputs         []SiafundInput         `json:"siafundInputs,omitempty"`
	SiafundOutputs        []SiafundOutput        `json:"siafundOutputs,omitempty"`
	MinerFees             []Currency             `json:"minerFees,omitempty"`
	ArbitraryData         [][]byte               `json:"arbitraryData,omitempty"`
	Signatures            []TransactionSignature `json:"signatures,omitempty"`
}

A Transaction effects a change of blockchain state.

func (*Transaction) DecodeFrom ¶

func (txn *Transaction) DecodeFrom(d *Decoder)

DecodeFrom implements types.DecoderFrom.

func (Transaction) EncodeTo ¶

func (txn Transaction) EncodeTo(e *Encoder)

EncodeTo implements types.EncoderTo.

func (*Transaction) FileContractID ¶

func (txn *Transaction) FileContractID(i int) FileContractID

FileContractID returns the ID of the file contract at index i.

func (*Transaction) FullHash ¶ added in v0.1.12

func (txn *Transaction) FullHash() Hash256

FullHash returns the hash of the transaction's binary encoding. This hash is only used in specific circumstances; generally, ID should be used instead.

func (*Transaction) ID ¶

func (txn *Transaction) ID() TransactionID

ID returns the "semantic hash" of the transaction, covering all of the transaction's effects, but not incidental data such as signatures. This ensures that the ID will remain stable (i.e. non-malleable).

To hash all of the data in a transaction, use the FullHash method.

func (Transaction) MarshalJSON ¶ added in v0.6.2

func (txn Transaction) MarshalJSON() ([]byte, error)

MarshalJSON implements json.Marshaller.

For convenience, the transaction's ID is also calculated and included. This field is ignored during unmarshalling.

func (*Transaction) SiacoinOutputID ¶

func (txn *Transaction) SiacoinOutputID(i int) SiacoinOutputID

SiacoinOutputID returns the ID of the siacoin output at index i.

func (*Transaction) SiafundClaimOutputID ¶

func (txn *Transaction) SiafundClaimOutputID(i int) SiacoinOutputID

SiafundClaimOutputID returns the ID of the siacoin claim output for the siafund input at index i.

func (*Transaction) SiafundOutputID ¶

func (txn *Transaction) SiafundOutputID(i int) SiafundOutputID

SiafundOutputID returns the ID of the siafund output at index i.

func (*Transaction) TotalFees ¶ added in v0.1.12

func (txn *Transaction) TotalFees() Currency

TotalFees returns the sum of the transaction's miner fees. If the sum would overflow, TotalFees returns ZeroCurrency.

type TransactionID ¶

type TransactionID Hash256

A TransactionID uniquely identifies a transaction.

func (*TransactionID) DecodeFrom ¶

func (id *TransactionID) DecodeFrom(d *Decoder)

DecodeFrom implements types.DecoderFrom.

func (TransactionID) EncodeTo ¶

func (id TransactionID) EncodeTo(e *Encoder)

EncodeTo implements types.EncoderTo.

func (TransactionID) MarshalText ¶

func (tid TransactionID) MarshalText() ([]byte, error)

MarshalText implements encoding.TextMarshaler.

func (TransactionID) String ¶

func (tid TransactionID) String() string

String implements fmt.Stringer.

func (*TransactionID) UnmarshalText ¶

func (tid *TransactionID) UnmarshalText(b []byte) error

UnmarshalText implements encoding.TextUnmarshaler.

type TransactionSignature ¶

type TransactionSignature struct {
	ParentID       Hash256       `json:"parentID"`
	PublicKeyIndex uint64        `json:"publicKeyIndex"`
	Timelock       uint64        `json:"timelock,omitempty"`
	CoveredFields  CoveredFields `json:"coveredFields"`
	Signature      []byte        `json:"signature"`
}

A TransactionSignature signs transaction data.

func (*TransactionSignature) DecodeFrom ¶

func (ts *TransactionSignature) DecodeFrom(d *Decoder)

DecodeFrom implements types.DecoderFrom.

func (TransactionSignature) EncodeTo ¶

func (ts TransactionSignature) EncodeTo(e *Encoder)

EncodeTo implements types.EncoderTo.

type UnlockConditions ¶

type UnlockConditions struct {
	Timelock           uint64      `json:"timelock"`
	PublicKeys         []UnlockKey `json:"publicKeys"`
	SignaturesRequired uint64      `json:"signaturesRequired"`
}

UnlockConditions specify the conditions for spending an output or revising a file contract.

func StandardUnlockConditions ¶ added in v0.1.12

func StandardUnlockConditions(pk PublicKey) UnlockConditions

StandardUnlockConditions returns the standard unlock conditions for pk.

func (*UnlockConditions) DecodeFrom ¶

func (uc *UnlockConditions) DecodeFrom(d *Decoder)

DecodeFrom implements types.DecoderFrom.

func (UnlockConditions) EncodeTo ¶

func (uc UnlockConditions) EncodeTo(e *Encoder)

EncodeTo implements types.EncoderTo.

func (UnlockConditions) UnlockHash ¶

func (uc UnlockConditions) UnlockHash() Address

UnlockHash computes the hash of a set of UnlockConditions. Such hashes are most commonly used as addresses, but are also used in file contracts.

type UnlockKey ¶

type UnlockKey struct {
	Algorithm Specifier
	Key       []byte
}

An UnlockKey can provide one of the signatures required by a set of UnlockConditions.

func (*UnlockKey) DecodeFrom ¶

func (uk *UnlockKey) DecodeFrom(d *Decoder)

DecodeFrom implements types.DecoderFrom.

func (UnlockKey) EncodeTo ¶

func (uk UnlockKey) EncodeTo(e *Encoder)

EncodeTo implements types.EncoderTo.

func (UnlockKey) MarshalText ¶ added in v0.1.11

func (uk UnlockKey) MarshalText() ([]byte, error)

MarshalText implements encoding.TextMarshaler.

func (*UnlockKey) UnmarshalText ¶ added in v0.1.11

func (uk *UnlockKey) UnmarshalText(b []byte) error

UnmarshalText implements encoding.TextUnmarshaler.

type V1Block ¶ added in v0.1.12

type V1Block Block

V1Block provides v1 encoding for Block.

func (V1Block) Cast ¶ added in v0.2.7

func (b V1Block) Cast() Block

Cast provides type safety for DecodeSliceCast.

func (*V1Block) DecodeFrom ¶ added in v0.1.12

func (b *V1Block) DecodeFrom(d *Decoder)

DecodeFrom implements types.DecoderFrom.

func (V1Block) EncodeTo ¶ added in v0.1.12

func (b V1Block) EncodeTo(e *Encoder)

EncodeTo implements types.EncoderTo.

type V1Currency ¶ added in v0.2.1

type V1Currency Currency

V1Currency provides v1 encoding for Currency.

func (V1Currency) Cast ¶ added in v0.2.7

func (c V1Currency) Cast() Currency

Cast provides type safety for DecodeSliceCast.

func (*V1Currency) DecodeFrom ¶ added in v0.2.1

func (c *V1Currency) DecodeFrom(d *Decoder)

DecodeFrom implements types.DecoderFrom.

func (V1Currency) EncodeTo ¶ added in v0.2.1

func (c V1Currency) EncodeTo(e *Encoder)

EncodeTo implements types.EncoderTo.

type V1SiacoinOutput ¶ added in v0.2.1

type V1SiacoinOutput SiacoinOutput

V1SiacoinOutput provides v1 encoding for SiacoinOutput.

func (V1SiacoinOutput) Cast ¶ added in v0.2.7

func (sco V1SiacoinOutput) Cast() SiacoinOutput

Cast provides type safety for DecodeSliceCast.

func (*V1SiacoinOutput) DecodeFrom ¶ added in v0.2.1

func (sco *V1SiacoinOutput) DecodeFrom(d *Decoder)

DecodeFrom implements types.DecoderFrom.

func (V1SiacoinOutput) EncodeTo ¶ added in v0.2.1

func (sco V1SiacoinOutput) EncodeTo(e *Encoder)

EncodeTo implements types.EncoderTo.

type V1SiafundOutput ¶ added in v0.2.1

type V1SiafundOutput SiafundOutput

V1SiafundOutput provides v1 encoding for SiafundOutput.

func (V1SiafundOutput) Cast ¶ added in v0.2.7

func (sfo V1SiafundOutput) Cast() SiafundOutput

Cast provides type safety for DecodeSliceCast.

func (*V1SiafundOutput) DecodeFrom ¶ added in v0.2.1

func (sfo *V1SiafundOutput) DecodeFrom(d *Decoder)

DecodeFrom implements types.DecoderFrom.

func (V1SiafundOutput) EncodeTo ¶ added in v0.2.1

func (sfo V1SiafundOutput) EncodeTo(e *Encoder)

EncodeTo implements types.EncoderTo.

type V2Block ¶ added in v0.1.12

type V2Block Block

V2Block provides v2 encoding for Block.

func (V2Block) Cast ¶ added in v0.2.7

func (b V2Block) Cast() Block

Cast provides type safety for DecodeSliceCast.

func (*V2Block) DecodeFrom ¶ added in v0.1.12

func (b *V2Block) DecodeFrom(d *Decoder)

DecodeFrom implements types.DecoderFrom.

func (V2Block) EncodeTo ¶ added in v0.1.12

func (b V2Block) EncodeTo(e *Encoder)

EncodeTo implements types.EncoderTo.

type V2BlockData ¶ added in v0.1.12

type V2BlockData struct {
	Height       uint64          `json:"height"`
	Commitment   Hash256         `json:"commitment"`
	Transactions []V2Transaction `json:"transactions"`
}

V2BlockData contains additional fields not present in v1 blocks.

func (*V2BlockData) DecodeFrom ¶ added in v0.1.12

func (b *V2BlockData) DecodeFrom(d *Decoder)

DecodeFrom implements types.DecoderFrom.

func (V2BlockData) EncodeTo ¶ added in v0.1.12

func (b V2BlockData) EncodeTo(e *Encoder)

EncodeTo implements types.EncoderTo.

type V2Currency ¶ added in v0.2.1

type V2Currency Currency

V2Currency provides v2 encoding for Currency.

func (V2Currency) Cast ¶ added in v0.2.7

func (c V2Currency) Cast() Currency

Cast provides type safety for DecodeSliceCast.

func (*V2Currency) DecodeFrom ¶ added in v0.2.1

func (c *V2Currency) DecodeFrom(d *Decoder)

DecodeFrom implements types.DecoderFrom.

func (V2Currency) EncodeTo ¶ added in v0.2.1

func (c V2Currency) EncodeTo(e *Encoder)

EncodeTo implements types.EncoderTo.

type V2FileContract ¶ added in v0.1.12

type V2FileContract struct {
	Capacity         uint64        `json:"capacity"`
	Filesize         uint64        `json:"filesize"`
	FileMerkleRoot   Hash256       `json:"fileMerkleRoot"`
	ProofHeight      uint64        `json:"proofHeight"`
	ExpirationHeight uint64        `json:"expirationHeight"`
	RenterOutput     SiacoinOutput `json:"renterOutput"`
	HostOutput       SiacoinOutput `json:"hostOutput"`
	MissedHostValue  Currency      `json:"missedHostValue"`
	TotalCollateral  Currency      `json:"totalCollateral"`
	RenterPublicKey  PublicKey     `json:"renterPublicKey"`
	HostPublicKey    PublicKey     `json:"hostPublicKey"`
	RevisionNumber   uint64        `json:"revisionNumber"`

	// signatures cover above fields
	RenterSignature Signature `json:"renterSignature"`
	HostSignature   Signature `json:"hostSignature"`
}

A V2FileContract is a storage agreement between a renter and a host. It consists of a bidirectional payment channel that resolves as either "valid" or "missed" depending on whether a valid StorageProof is submitted for the contract.

func (*V2FileContract) DecodeFrom ¶ added in v0.1.12

func (fc *V2FileContract) DecodeFrom(d *Decoder)

DecodeFrom implements types.DecoderFrom.

func (V2FileContract) EncodeTo ¶ added in v0.1.12

func (fc V2FileContract) EncodeTo(e *Encoder)

EncodeTo implements types.EncoderTo.

func (V2FileContract) MissedHostOutput ¶ added in v0.1.12

func (fc V2FileContract) MissedHostOutput() SiacoinOutput

MissedHostOutput returns the host output that will be created if the contract resolves missed.

type V2FileContractElement ¶ added in v0.1.12

type V2FileContractElement struct {
	ID             FileContractID `json:"id"`
	StateElement   StateElement   `json:"stateElement"`
	V2FileContract V2FileContract `json:"v2FileContract"`
}

A V2FileContractElement is a record of a V2FileContract within the state accumulator.

func (*V2FileContractElement) DecodeFrom ¶ added in v0.1.12

func (fce *V2FileContractElement) DecodeFrom(d *Decoder)

DecodeFrom implements types.DecoderFrom.

func (V2FileContractElement) EncodeTo ¶ added in v0.1.12

func (fce V2FileContractElement) EncodeTo(e *Encoder)

EncodeTo implements types.EncoderTo.

type V2FileContractExpiration ¶ added in v0.1.12

type V2FileContractExpiration struct{}

A V2FileContractExpiration resolves an expired contract. A contract is considered expired when its proof window has elapsed. If the contract is not storing any data, it will resolve as valid; otherwise, it resolves as missed.

func (*V2FileContractExpiration) DecodeFrom ¶ added in v0.1.12

func (*V2FileContractExpiration) DecodeFrom(d *Decoder)

DecodeFrom implements types.DecoderFrom.

func (V2FileContractExpiration) EncodeTo ¶ added in v0.1.12

func (V2FileContractExpiration) EncodeTo(e *Encoder)

EncodeTo implements types.EncoderTo.

type V2FileContractRenewal ¶ added in v0.1.12

type V2FileContractRenewal struct {
	FinalRenterOutput SiacoinOutput  `json:"finalRenterOutput"`
	FinalHostOutput   SiacoinOutput  `json:"finalHostOutput"`
	RenterRollover    Currency       `json:"renterRollover"`
	HostRollover      Currency       `json:"hostRollover"`
	NewContract       V2FileContract `json:"newContract"`

	// signatures cover above fields
	RenterSignature Signature `json:"renterSignature"`
	HostSignature   Signature `json:"hostSignature"`
}

A V2FileContractRenewal renews a file contract.

func (*V2FileContractRenewal) DecodeFrom ¶ added in v0.1.12

func (ren *V2FileContractRenewal) DecodeFrom(d *Decoder)

DecodeFrom implements types.DecoderFrom.

func (V2FileContractRenewal) EncodeTo ¶ added in v0.1.12

func (ren V2FileContractRenewal) EncodeTo(e *Encoder)

EncodeTo implements types.EncoderTo.

type V2FileContractResolution ¶ added in v0.1.12

type V2FileContractResolution struct {
	Parent     V2FileContractElement        `json:"parent"`
	Resolution V2FileContractResolutionType `json:"resolution"`
}

A V2FileContractResolution closes a v2 file contract's payment channel. There are three ways a contract can be resolved:

1) The renter and host can jointly renew the contract. The old contract is finalized, and a portion of its funds are "rolled over" into a new contract. Renewals must be submitted prior to the contract's ProofHeight.

2) If the renter is unwilling or unable to sign a renewal, the host can submit a storage proof, asserting that it has faithfully stored the contract data for the agreed-upon duration. Storage proofs must be submitted after the contract's ProofHeight and prior to its ExpirationHeight.

3) Lastly, anyone can submit a contract expiration. An expiration can only be submitted after the contract's ExpirationHeight.

Once a contract has been resolved, it cannot be altered or resolved again. When a contract is resolved, its RenterOutput and HostOutput are created immediately (though they will not be spendable until their timelock expires). However, if the contract is resolved via an expiration, the HostOutput will have value equal to MissedHostValue; in other words, the host forfeits its collateral. This is considered a "missed" resolution; all other resolution types are "valid." As a special case, the expiration of an empty contract is considered valid, reflecting the fact that the host has not failed to perform any duty.

func (*V2FileContractResolution) DecodeFrom ¶ added in v0.1.12

func (res *V2FileContractResolution) DecodeFrom(d *Decoder)

DecodeFrom implements types.DecoderFrom.

func (V2FileContractResolution) EncodeTo ¶ added in v0.1.12

func (res V2FileContractResolution) EncodeTo(e *Encoder)

EncodeTo implements types.EncoderTo.

func (V2FileContractResolution) MarshalJSON ¶ added in v0.1.12

func (res V2FileContractResolution) MarshalJSON() ([]byte, error)

MarshalJSON implements json.Marshaler.

func (*V2FileContractResolution) UnmarshalJSON ¶ added in v0.1.12

func (res *V2FileContractResolution) UnmarshalJSON(b []byte) error

UnmarshalJSON implements json.Marshaler.

type V2FileContractResolutionType ¶ added in v0.1.12

type V2FileContractResolutionType interface {
	// contains filtered or unexported methods
}

V2FileContractResolutionType enumerates the types of file contract resolution.

type V2FileContractRevision ¶ added in v0.1.12

type V2FileContractRevision struct {
	Parent   V2FileContractElement `json:"parent"`
	Revision V2FileContract        `json:"revision"`
}

A V2FileContractRevision updates the state of an existing file contract.

func (*V2FileContractRevision) DecodeFrom ¶ added in v0.1.12

func (rev *V2FileContractRevision) DecodeFrom(d *Decoder)

DecodeFrom implements types.DecoderFrom.

func (V2FileContractRevision) EncodeTo ¶ added in v0.1.12

func (rev V2FileContractRevision) EncodeTo(e *Encoder)

EncodeTo implements types.EncoderTo.

type V2SiacoinInput ¶ added in v0.1.12

type V2SiacoinInput struct {
	Parent          SiacoinElement  `json:"parent"`
	SatisfiedPolicy SatisfiedPolicy `json:"satisfiedPolicy"`
}

A V2SiacoinInput spends an unspent SiacoinElement in the state accumulator by revealing its public key and signing the transaction.

func (*V2SiacoinInput) DecodeFrom ¶ added in v0.1.12

func (in *V2SiacoinInput) DecodeFrom(d *Decoder)

DecodeFrom implements types.DecoderFrom.

func (V2SiacoinInput) EncodeTo ¶ added in v0.1.12

func (in V2SiacoinInput) EncodeTo(e *Encoder)

EncodeTo implements types.EncoderTo.

type V2SiacoinOutput ¶ added in v0.2.1

type V2SiacoinOutput SiacoinOutput

V2SiacoinOutput provides v2 encoding for SiacoinOutput.

func (V2SiacoinOutput) Cast ¶ added in v0.2.7

func (sco V2SiacoinOutput) Cast() SiacoinOutput

Cast provides type safety for DecodeSliceCast.

func (*V2SiacoinOutput) DecodeFrom ¶ added in v0.2.1

func (sco *V2SiacoinOutput) DecodeFrom(d *Decoder)

DecodeFrom implements types.DecoderFrom.

func (V2SiacoinOutput) EncodeTo ¶ added in v0.2.1

func (sco V2SiacoinOutput) EncodeTo(e *Encoder)

EncodeTo implements types.EncoderTo.

type V2SiafundInput ¶ added in v0.1.12

type V2SiafundInput struct {
	Parent          SiafundElement  `json:"parent"`
	ClaimAddress    Address         `json:"claimAddress"`
	SatisfiedPolicy SatisfiedPolicy `json:"satisfiedPolicy"`
}

A V2SiafundInput spends an unspent SiafundElement in the state accumulator by revealing its public key and signing the transaction. Inputs also include a ClaimAddress, specifying the recipient of the siacoins that were earned by the SiafundElement.

func (*V2SiafundInput) DecodeFrom ¶ added in v0.1.12

func (in *V2SiafundInput) DecodeFrom(d *Decoder)

DecodeFrom implements types.DecoderFrom.

func (V2SiafundInput) EncodeTo ¶ added in v0.1.12

func (in V2SiafundInput) EncodeTo(e *Encoder)

EncodeTo implements types.EncoderTo.

type V2SiafundOutput ¶ added in v0.2.1

type V2SiafundOutput SiafundOutput

V2SiafundOutput provides v2 encoding for SiafundOutput.

func (V2SiafundOutput) Cast ¶ added in v0.2.7

func (sfo V2SiafundOutput) Cast() SiafundOutput

Cast provides type safety for DecodeSliceCast.

func (*V2SiafundOutput) DecodeFrom ¶ added in v0.2.1

func (sfo *V2SiafundOutput) DecodeFrom(d *Decoder)

DecodeFrom implements types.DecoderFrom.

func (V2SiafundOutput) EncodeTo ¶ added in v0.2.1

func (sfo V2SiafundOutput) EncodeTo(e *Encoder)

EncodeTo implements types.EncoderTo.

type V2StorageProof ¶ added in v0.1.12

type V2StorageProof struct {
	// Selecting the leaf requires a source of unpredictable entropy; we use the
	// ID of the block at the contract's ProofHeight. The storage proof thus
	// includes a proof that this ID is the correct ancestor.
	//
	// During validation, it is imperative to check that ProofIndex.Height
	// matches the ProofHeight field of the contract's final revision;
	// otherwise, the prover could use any ProofIndex, giving them control over
	// the leaf index.
	ProofIndex ChainIndexElement

	// The leaf is always 64 bytes, extended with zeros if necessary.
	Leaf  [64]byte
	Proof []Hash256
}

A V2StorageProof asserts the presence of a randomly-selected leaf within the Merkle tree of a V2FileContract's data.

func (*V2StorageProof) DecodeFrom ¶ added in v0.1.12

func (sp *V2StorageProof) DecodeFrom(d *Decoder)

DecodeFrom implements types.DecoderFrom.

func (V2StorageProof) EncodeTo ¶ added in v0.1.12

func (sp V2StorageProof) EncodeTo(e *Encoder)

EncodeTo implements types.EncoderTo.

func (V2StorageProof) MarshalJSON ¶ added in v0.1.12

func (sp V2StorageProof) MarshalJSON() ([]byte, error)

MarshalJSON implements json.Marshaler.

func (*V2StorageProof) UnmarshalJSON ¶ added in v0.1.12

func (sp *V2StorageProof) UnmarshalJSON(b []byte) error

UnmarshalJSON implements json.Unmarshaler.

type V2Transaction ¶ added in v0.1.12

type V2Transaction struct {
	SiacoinInputs           []V2SiacoinInput           `json:"siacoinInputs,omitempty"`
	SiacoinOutputs          []SiacoinOutput            `json:"siacoinOutputs,omitempty"`
	SiafundInputs           []V2SiafundInput           `json:"siafundInputs,omitempty"`
	SiafundOutputs          []SiafundOutput            `json:"siafundOutputs,omitempty"`
	FileContracts           []V2FileContract           `json:"fileContracts,omitempty"`
	FileContractRevisions   []V2FileContractRevision   `json:"fileContractRevisions,omitempty"`
	FileContractResolutions []V2FileContractResolution `json:"fileContractResolutions,omitempty"`
	Attestations            []Attestation              `json:"attestations,omitempty"`
	ArbitraryData           []byte                     `json:"arbitraryData,omitempty"`
	NewFoundationAddress    *Address                   `json:"newFoundationAddress,omitempty"`
	MinerFee                Currency                   `json:"minerFee"`
}

A V2Transaction effects a change of blockchain state.

func (*V2Transaction) AttestationID ¶ added in v0.1.12

func (*V2Transaction) AttestationID(txid TransactionID, i int) AttestationID

AttestationID returns the ID for the attestation at index i.

func (*V2Transaction) DecodeFrom ¶ added in v0.1.12

func (txn *V2Transaction) DecodeFrom(d *Decoder)

DecodeFrom implements types.DecoderFrom.

func (*V2Transaction) DeepCopy ¶ added in v0.1.12

func (txn *V2Transaction) DeepCopy() V2Transaction

DeepCopy returns a copy of txn that does not alias any of its memory.

func (V2Transaction) EncodeTo ¶ added in v0.1.12

func (txn V2Transaction) EncodeTo(e *Encoder)

EncodeTo implements types.EncoderTo.

func (*V2Transaction) EphemeralSiacoinOutput ¶ added in v0.1.12

func (txn *V2Transaction) EphemeralSiacoinOutput(i int) SiacoinElement

EphemeralSiacoinOutput returns a SiacoinElement for the siacoin output at index i.

func (*V2Transaction) EphemeralSiafundOutput ¶ added in v0.1.12

func (txn *V2Transaction) EphemeralSiafundOutput(i int) SiafundElement

EphemeralSiafundOutput returns a SiafundElement for the siafund output at index i.

func (*V2Transaction) FullHash ¶ added in v0.1.12

func (txn *V2Transaction) FullHash() Hash256

FullHash returns the hash of the transaction's binary encoding. This hash is only used in specific circumstances; generally, ID should be used instead.

func (*V2Transaction) ID ¶ added in v0.1.12

func (txn *V2Transaction) ID() TransactionID

ID returns the "semantic hash" of the transaction, covering all of the transaction's effects, but not incidental data such as signatures or Merkle proofs. This ensures that the ID will remain stable (i.e. non-malleable).

To hash all of the data in a transaction, use the FullHash method.

func (V2Transaction) MarshalJSON ¶ added in v0.6.2

func (txn V2Transaction) MarshalJSON() ([]byte, error)

MarshalJSON implements json.Marshaller.

For convenience, the transaction's ID is also calculated and included. This field is ignored during unmarshalling.

func (*V2Transaction) SiacoinOutputID ¶ added in v0.1.12

func (*V2Transaction) SiacoinOutputID(txid TransactionID, i int) SiacoinOutputID

SiacoinOutputID returns the ID for the siacoin output at index i.

func (*V2Transaction) SiafundOutputID ¶ added in v0.1.12

func (*V2Transaction) SiafundOutputID(txid TransactionID, i int) SiafundOutputID

SiafundOutputID returns the ID for the siafund output at index i.

func (*V2Transaction) V2FileContractID ¶ added in v0.1.12

func (*V2Transaction) V2FileContractID(txid TransactionID, i int) FileContractID

V2FileContractID returns the ID for the v2 file contract at index i.

type V2TransactionSemantics ¶ added in v0.1.12

type V2TransactionSemantics V2Transaction

V2TransactionSemantics is a helper type that provides a "semantic encoding" of a v2 transaction, for use in computing IDs and signature hashes.

func (V2TransactionSemantics) EncodeTo ¶ added in v0.1.12

func (txn V2TransactionSemantics) EncodeTo(e *Encoder)

EncodeTo implements types.EncoderTo.

type V2TransactionsMultiproof ¶ added in v0.1.12

type V2TransactionsMultiproof []V2Transaction

V2TransactionsMultiproof is a slice of V2Transactions whose Merkle proofs are encoded as a single multiproof. This can significantly reduce the size of the encoded transactions. However, multiproofs may only be used for transaction sets whose Merkle proofs are all valid for the same consensus state.

func (*V2TransactionsMultiproof) DecodeFrom ¶ added in v0.1.12

func (txns *V2TransactionsMultiproof) DecodeFrom(d *Decoder)

DecodeFrom implements types.DecoderFrom.

func (V2TransactionsMultiproof) EncodeTo ¶ added in v0.1.12

func (txns V2TransactionsMultiproof) EncodeTo(e *Encoder)

EncodeTo implements types.EncoderTo.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL
JackTT - Gopher 🇻🇳