Documentation
¶
Overview ¶
Package types defines the essential types of the Bigfile blockchain.
Index ¶
- Constants
- Variables
- func CurrentTimestamp() time.Time
- func DecodePtr[T any, TP interface{ ... }](d *Decoder, v **T)
- func DecodePtrCast[T interface{ ... }, TP interface{ ... }, V any](d *Decoder, p **V)
- func DecodeSlice[T any, DF interface{ ... }](d *Decoder, s *[]T)
- func DecodeSliceCast[V any, T any, VF interface{ ... }](d *Decoder, s *[]T)
- func DecodeSliceFn[T any](d *Decoder, s *[]T, fn func(*Decoder) T)
- func EncodePtr[T any, P interface{ ... }](e *Encoder, p P)
- func EncodePtrCast[V interface{ ... }, T any](e *Encoder, p *T)
- func EncodeSlice[T EncoderTo](e *Encoder, s []T)
- func EncodeSliceCast[V interface{ ... }, T any](e *Encoder, s []T)
- func EncodeSliceFn[T any](e *Encoder, s []T, fn func(*Encoder, T))
- type Address
- type Attestation
- type AttestationElement
- type AttestationID
- type BigfileElement
- type BigfileInput
- type BigfileOutput
- type BigfileOutputID
- type BigfundElement
- type BigfundInput
- type BigfundOutput
- type BigfundOutputID
- func (bfoid BigfundOutputID) ClaimOutputID() BigfileOutputID
- func (id *BigfundOutputID) DecodeFrom(d *Decoder)
- func (id BigfundOutputID) EncodeTo(e *Encoder)
- func (bfoid BigfundOutputID) MarshalText() ([]byte, error)
- func (bfoid BigfundOutputID) String() string
- func (bfoid *BigfundOutputID) UnmarshalText(b []byte) error
- func (bfoid BigfundOutputID) V2ClaimOutputID() BigfileOutputID
- type Block
- type BlockHeader
- type BlockID
- func (bid BlockID) CmpWork(t BlockID) int
- func (id *BlockID) DecodeFrom(d *Decoder)
- func (id BlockID) EncodeTo(e *Encoder)
- func (bid BlockID) FoundationOutputID() BigfileOutputID
- func (bid BlockID) MarshalText() ([]byte, error)
- func (bid BlockID) MinerOutputID(i int) BigfileOutputID
- func (bid BlockID) String() string
- func (bid *BlockID) UnmarshalText(b []byte) error
- type ChainIndex
- func (index *ChainIndex) DecodeFrom(d *Decoder)
- func (index ChainIndex) EncodeTo(e *Encoder)
- func (ci ChainIndex) MarshalJSON() ([]byte, error)
- func (ci ChainIndex) MarshalText() ([]byte, error)
- func (ci ChainIndex) String() string
- func (ci *ChainIndex) UnmarshalJSON(b []byte) error
- func (ci *ChainIndex) UnmarshalText(b []byte) (err error)
- type ChainIndexElement
- type CoveredFields
- type Currency
- func (c Currency) Add(v Currency) Currency
- func (c Currency) AddWithOverflow(v Currency) (Currency, bool)
- func (c Currency) Big() *big.Int
- func (c Currency) Bigfiles() float64
- func (c Currency) Cmp(v Currency) int
- func (c Currency) Div(v Currency) Currency
- func (c Currency) Div64(v uint64) Currency
- func (c Currency) Equals(v Currency) bool
- func (c Currency) ExactString() string
- func (c Currency) Format(f fmt.State, v rune)
- func (c Currency) IsZero() bool
- func (c Currency) MarshalText() ([]byte, error)
- func (c Currency) Mul(v Currency) Currency
- func (c Currency) Mul64(v uint64) Currency
- func (c Currency) Mul64WithOverflow(v uint64) (Currency, bool)
- func (c Currency) MulWithOverflow(v Currency) (Currency, bool)
- func (c Currency) String() string
- func (c Currency) Sub(v Currency) Currency
- func (c Currency) SubWithUnderflow(v Currency) (Currency, bool)
- func (c *Currency) UnmarshalText(b []byte) (err error)
- type Decoder
- func (d *Decoder) Err() error
- func (d *Decoder) Read(p []byte) (int, error)
- func (d *Decoder) ReadBool() bool
- func (d *Decoder) ReadBytes() []byte
- func (d *Decoder) ReadString() string
- func (d *Decoder) ReadTime() time.Time
- func (d *Decoder) ReadUint8() uint8
- func (d *Decoder) ReadUint64() uint64
- func (d *Decoder) SetErr(err error)
- type DecoderFrom
- type DecoderFunc
- type ElementID
- type Encoder
- func (e *Encoder) Flush() error
- func (e *Encoder) Reset(w io.Writer)
- func (e *Encoder) Write(p []byte) (int, error)
- func (e *Encoder) WriteBool(b bool)
- func (e *Encoder) WriteBytes(b []byte)
- func (e *Encoder) WriteString(s string)
- func (e *Encoder) WriteTime(t time.Time)
- func (e *Encoder) WriteUint8(u uint8)
- func (e *Encoder) WriteUint64(u uint64)
- type EncoderFunc
- type EncoderTo
- type FileContract
- func (fc *FileContract) DecodeFrom(d *Decoder)
- func (fc FileContract) EncodeTo(e *Encoder)
- func (fc *FileContract) EndHeight() uint64
- func (fc *FileContract) MissedHostOutput() BigfileOutput
- func (fc *FileContract) MissedHostPayout() Currency
- func (fc *FileContract) MissedRenterOutput() BigfileOutput
- func (fc *FileContract) MissedRenterPayout() Currency
- func (fc *FileContract) ValidHostOutput() BigfileOutput
- func (fc *FileContract) ValidHostPayout() Currency
- func (fc *FileContract) ValidRenterOutput() BigfileOutput
- func (fc *FileContract) ValidRenterPayout() Currency
- type FileContractElement
- type FileContractID
- func (id *FileContractID) DecodeFrom(d *Decoder)
- func (id FileContractID) EncodeTo(e *Encoder)
- func (fcid FileContractID) MarshalText() ([]byte, error)
- func (fcid FileContractID) MissedOutputID(i int) BigfileOutputID
- func (fcid FileContractID) String() string
- func (fcid *FileContractID) UnmarshalText(b []byte) error
- func (fcid FileContractID) V2HostOutputID() BigfileOutputID
- func (fcid FileContractID) V2RenewalID() FileContractID
- func (fcid FileContractID) V2RenterOutputID() BigfileOutputID
- func (fcid FileContractID) ValidOutputID(i int) BigfileOutputID
- type FileContractRevision
- type FoundationAddressUpdate
- type Hash256
- type Hasher
- type PolicyTypeAbove
- type PolicyTypeAfter
- type PolicyTypeHash
- type PolicyTypeOpaque
- type PolicyTypePublicKey
- type PolicyTypeThreshold
- type PolicyTypeUnlockConditions
- type PrivateKey
- type PublicKey
- func (pk *PublicKey) DecodeFrom(d *Decoder)
- func (pk PublicKey) EncodeTo(e *Encoder)
- func (pk PublicKey) MarshalText() ([]byte, error)
- func (pk PublicKey) String() string
- func (pk PublicKey) UnlockKey() UnlockKey
- func (pk *PublicKey) UnmarshalText(b []byte) error
- func (pk PublicKey) VerifyHash(h Hash256, s Signature) bool
- type SatisfiedPolicy
- type Signature
- type Specifier
- type SpendPolicy
- func AnyoneCanSpend() SpendPolicy
- func ParseSpendPolicy(s string) (SpendPolicy, error)
- func PolicyAbove(height uint64) SpendPolicy
- func PolicyAfter(t time.Time) SpendPolicy
- func PolicyHash(h Hash256) SpendPolicy
- func PolicyOpaque(p SpendPolicy) SpendPolicy
- func PolicyPublicKey(pk PublicKey) SpendPolicy
- func PolicyThreshold(n uint8, of []SpendPolicy) SpendPolicy
- func (p SpendPolicy) Address() Address
- func (p *SpendPolicy) DecodeFrom(d *Decoder)
- func (p SpendPolicy) EncodeTo(e *Encoder)
- func (p SpendPolicy) MarshalJSON() ([]byte, error)
- func (p SpendPolicy) String() string
- func (p *SpendPolicy) UnmarshalJSON(b []byte) (err error)
- func (p SpendPolicy) Verify(height uint64, medianTimestamp time.Time, sigHash Hash256, sigs []Signature, ...) error
- type StateElement
- type StorageProof
- type Transaction
- func (txn *Transaction) BigfileOutputID(i int) BigfileOutputID
- func (txn *Transaction) BigfundClaimOutputID(i int) BigfileOutputID
- func (txn *Transaction) BigfundOutputID(i int) BigfundOutputID
- func (txn *Transaction) DecodeFrom(d *Decoder)
- func (txn Transaction) EncodeTo(e *Encoder)
- func (txn *Transaction) FileContractID(i int) FileContractID
- func (txn *Transaction) FullHash() Hash256
- func (txn *Transaction) ID() TransactionID
- func (txn Transaction) MarshalJSON() ([]byte, error)
- func (txn *Transaction) MerkleLeafHash() Hash256
- func (txn *Transaction) TotalFees() Currency
- type TransactionID
- type TransactionSignature
- type UnlockConditions
- type UnlockKey
- type V1BigfileOutput
- type V1BigfundOutput
- type V1Block
- type V1Currency
- type V2BigfileInput
- type V2BigfileOutput
- type V2BigfundInput
- type V2BigfundOutput
- type V2Block
- type V2BlockData
- type V2Currency
- type V2FileContract
- type V2FileContractElement
- func (v2fce V2FileContractElement) Copy() V2FileContractElement
- func (fce *V2FileContractElement) DecodeFrom(d *Decoder)
- func (fce V2FileContractElement) EncodeTo(e *Encoder)
- func (v2fce V2FileContractElement) Move() V2FileContractElement
- func (v2fce V2FileContractElement) Share() V2FileContractElement
- type V2FileContractExpiration
- type V2FileContractRenewal
- type V2FileContractResolution
- type V2FileContractResolutionType
- type V2FileContractRevision
- type V2StorageProof
- type V2Transaction
- func (*V2Transaction) AttestationID(txid TransactionID, i int) AttestationID
- func (*V2Transaction) BigfileOutputID(txid TransactionID, i int) BigfileOutputID
- func (*V2Transaction) BigfundOutputID(txid TransactionID, i int) BigfundOutputID
- func (txn *V2Transaction) DecodeFrom(d *Decoder)
- func (txn *V2Transaction) DeepCopy() V2Transaction
- func (txn V2Transaction) EncodeTo(e *Encoder)
- func (txn *V2Transaction) EphemeralBigfileOutput(i int) BigfileElement
- func (txn *V2Transaction) EphemeralBigfundOutput(i int) BigfundElement
- func (txn *V2Transaction) FullHash() Hash256
- func (txn *V2Transaction) ID() TransactionID
- func (txn V2Transaction) MarshalJSON() ([]byte, error)
- func (txn *V2Transaction) MerkleLeafHash() Hash256
- func (*V2Transaction) V2FileContractID(txid TransactionID, i int) FileContractID
- type V2TransactionSemantics
- type V2TransactionsMultiproof
Constants ¶
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 EphemeralBigfileElement and EphemeralBigfundElement // functions to construct dependent transaction sets. UnassignedLeafIndex = 10101010101010101010 )
Variables ¶
var ( // ZeroCurrency represents zero base units. ZeroCurrency Currency // MaxCurrency represents the largest possible value for the Currency type. MaxCurrency = NewCurrency(math.MaxUint64, math.MaxUint64) // HastingsPerBigfile is the number of hastings (base units) in a bigfile. HastingsPerBigfile = NewCurrency(2003764205206896640, 54210) // 10^24 )
var ( SpecifierEd25519 = NewSpecifier("ed25519") SpecifierBigfileOutput = NewSpecifier("bigfile output") SpecifierBigfundOutput = NewSpecifier("bigfund output") SpecifierFileContract = NewSpecifier("file contract") SpecifierStorageProof = NewSpecifier("storage proof") SpecifierFoundation = NewSpecifier("foundation") SpecifierEntropy = NewSpecifier("entropy") )
Various specifiers.
Functions ¶
func CurrentTimestamp ¶
CurrentTimestamp returns the current time, rounded to the nearest second. The time zone is set to UTC.
func DecodePtr ¶
func DecodePtr[T any, TP interface { *T DecoderFrom }](d *Decoder, v **T)
DecodePtr decodes a pointer to an object that implements DecoderFrom.
func DecodePtrCast ¶
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 ¶
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 ¶
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 ¶
DecodeSliceFn decodes a length-prefixed slice of type T, calling an explicit function to decode each element.
func EncodePtrCast ¶
EncodePtrCast encodes a pointer to an object by casting it to V.
func EncodeSlice ¶
EncodeSlice encodes a slice of objects that implement EncoderTo.
func EncodeSliceCast ¶
EncodeSliceCast encodes a slice of objects by casting them to V.
func EncodeSliceFn ¶
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 ¶
ParseAddress parses an address from a prefixed hex encoded string.
func StandardAddress ¶
StandardAddress returns the standard v2 Address derived from pk. It is equivalent to PolicyPublicKey(pk).Address().
func StandardUnlockHash ¶
StandardUnlockHash returns the standard UnlockHash derived from pk. It is equivalent to SpendPolicy{PolicyUnlockConditions(StandardUnlockConditions(pk))}.Address().
func (*Address) DecodeFrom ¶
DecodeFrom implements types.DecoderFrom.
func (Address) MarshalText ¶
MarshalText implements encoding.TextMarshaler.
func (*Address) UnmarshalText ¶
UnmarshalText implements encoding.TextUnmarshaler.
type Attestation ¶
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 ¶
func (a *Attestation) DecodeFrom(d *Decoder)
DecodeFrom implements types.DecoderFrom.
func (Attestation) EncodeTo ¶
func (a Attestation) EncodeTo(e *Encoder)
EncodeTo implements types.EncoderTo.
type AttestationElement ¶
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.
func (AttestationElement) Copy ¶ added in v0.0.2
func (ae AttestationElement) Copy() AttestationElement
Copy returns a deep copy of the element. It must be used whenever the element's memory is copied.
func (AttestationElement) Move ¶ added in v0.0.2
func (ae AttestationElement) Move() AttestationElement
Move returns a shallow copy of the element. It must only be used when the element's memory is not shared.
func (AttestationElement) Share ¶ added in v0.0.2
func (ae AttestationElement) Share() AttestationElement
Share returns a shallow copy of the element. It must be used whenever the element's memory is intentionally aliased.
type AttestationID ¶
type AttestationID Hash256
An AttestationID uniquely identifies an attestation.
func (*AttestationID) DecodeFrom ¶
func (id *AttestationID) DecodeFrom(d *Decoder)
DecodeFrom implements types.DecoderFrom.
func (AttestationID) EncodeTo ¶
func (id AttestationID) EncodeTo(e *Encoder)
EncodeTo implements types.EncoderTo.
func (AttestationID) MarshalText ¶
func (aid AttestationID) MarshalText() ([]byte, error)
MarshalText implements encoding.TextMarshaler.
func (AttestationID) String ¶
func (aid AttestationID) String() string
String implements fmt.Stringer.
func (*AttestationID) UnmarshalText ¶
func (aid *AttestationID) UnmarshalText(b []byte) error
UnmarshalText implements encoding.TextUnmarshaler.
type BigfileElement ¶ added in v1.0.9
type BigfileElement struct {
ID BigfileOutputID `json:"id"`
StateElement StateElement `json:"stateElement"`
BigfileOutput BigfileOutput `json:"bigfileOutput"`
MaturityHeight uint64 `json:"maturityHeight"`
}
A BigfileElement is a record of a BigfileOutput within the state accumulator.
func (BigfileElement) Copy ¶ added in v1.0.9
func (bige BigfileElement) Copy() BigfileElement
Copy returns a deep copy of the element. It must be used whenever the element's memory is copied.
func (*BigfileElement) DecodeFrom ¶ added in v1.0.9
func (bige *BigfileElement) DecodeFrom(d *Decoder)
DecodeFrom implements types.DecoderFrom.
func (BigfileElement) EncodeTo ¶ added in v1.0.9
func (bige BigfileElement) EncodeTo(e *Encoder)
EncodeTo implements types.EncoderTo.
func (BigfileElement) Move ¶ added in v1.0.9
func (bige BigfileElement) Move() BigfileElement
Move returns a shallow copy of the element. It must only be used when the element's memory is not shared.
func (BigfileElement) Share ¶ added in v1.0.9
func (bige BigfileElement) Share() BigfileElement
Share returns a shallow copy of the element. It must be used whenever the element's memory is intentionally aliased.
type BigfileInput ¶ added in v1.0.9
type BigfileInput struct {
ParentID BigfileOutputID `json:"parentID"`
UnlockConditions UnlockConditions `json:"unlockConditions"`
}
A BigfileInput spends an unspent BigfileOutput in the UTXO set by revealing and satisfying its unlock conditions.
func (*BigfileInput) DecodeFrom ¶ added in v1.0.9
func (in *BigfileInput) DecodeFrom(d *Decoder)
DecodeFrom implements types.DecoderFrom.
func (BigfileInput) EncodeTo ¶ added in v1.0.9
func (in BigfileInput) EncodeTo(e *Encoder)
EncodeTo implements types.EncoderTo.
func (BigfileInput) MarshalJSON ¶ added in v1.0.9
func (si BigfileInput) MarshalJSON() ([]byte, error)
MarshalJSON implements json.Marshaler.
For convenience, the input's address is also calculated and included. This field is ignored during unmarshalling.
type BigfileOutput ¶ added in v1.0.9
A BigfileOutput is the recipient of some of the bigfiles spent in a transaction.
type BigfileOutputID ¶ added in v1.0.9
type BigfileOutputID Hash256
A BigfileOutputID uniquely identifies a bigfile output.
func (*BigfileOutputID) DecodeFrom ¶ added in v1.0.9
func (id *BigfileOutputID) DecodeFrom(d *Decoder)
DecodeFrom implements types.DecoderFrom.
func (BigfileOutputID) EncodeTo ¶ added in v1.0.9
func (id BigfileOutputID) EncodeTo(e *Encoder)
EncodeTo implements types.EncoderTo.
func (BigfileOutputID) MarshalText ¶ added in v1.0.9
func (bigoid BigfileOutputID) MarshalText() ([]byte, error)
MarshalText implements encoding.TextMarshaler.
func (BigfileOutputID) String ¶ added in v1.0.9
func (bigoid BigfileOutputID) String() string
String implements fmt.Stringer.
func (*BigfileOutputID) UnmarshalText ¶ added in v1.0.9
func (bigoid *BigfileOutputID) UnmarshalText(b []byte) error
UnmarshalText implements encoding.TextUnmarshaler.
type BigfundElement ¶ added in v1.0.4
type BigfundElement struct {
ID BigfundOutputID `json:"id"`
StateElement StateElement `json:"stateElement"`
BigfundOutput BigfundOutput `json:"bigfundOutput"`
ClaimStart Currency `json:"claimStart"` // value of BigfundTaxRevenue when element was created
}
A BigfundElement is a record of a BigfundOutput within the state accumulator.
func (BigfundElement) Copy ¶ added in v1.0.4
func (bfe BigfundElement) Copy() BigfundElement
Copy returns a deep copy of the element. It must be used whenever the element's memory is copied.
func (*BigfundElement) DecodeFrom ¶ added in v1.0.4
func (bfe *BigfundElement) DecodeFrom(d *Decoder)
DecodeFrom implements types.DecoderFrom.
func (BigfundElement) EncodeTo ¶ added in v1.0.4
func (bfe BigfundElement) EncodeTo(e *Encoder)
EncodeTo implements types.EncoderTo.
func (BigfundElement) Move ¶ added in v1.0.4
func (bfe BigfundElement) Move() BigfundElement
Move returns a shallow copy of the element. It must only be used when the element's memory is not shared.
func (BigfundElement) Share ¶ added in v1.0.4
func (bfe BigfundElement) Share() BigfundElement
Share returns a shallow copy of the element. It must be used whenever the element's memory is intentionally aliased.
type BigfundInput ¶ added in v1.0.4
type BigfundInput struct {
ParentID BigfundOutputID `json:"parentID"`
UnlockConditions UnlockConditions `json:"unlockConditions"`
ClaimAddress Address `json:"claimAddress"`
}
A BigfundInput spends an unspent BigfundOutput in the UTXO set by revealing and satisfying its unlock conditions. BigfundInputs also include a ClaimAddress, specifying the recipient of the bigfiles that were earned by the output.
func (*BigfundInput) DecodeFrom ¶ added in v1.0.4
func (in *BigfundInput) DecodeFrom(d *Decoder)
DecodeFrom implements types.DecoderFrom.
func (BigfundInput) EncodeTo ¶ added in v1.0.4
func (in BigfundInput) EncodeTo(e *Encoder)
EncodeTo implements types.EncoderTo.
func (BigfundInput) MarshalJSON ¶ added in v1.0.9
func (si BigfundInput) MarshalJSON() ([]byte, error)
MarshalJSON implements json.Marshaler.
For convenience, the input's address is also calculated and included. This field is ignored during unmarshalling.
type BigfundOutput ¶ added in v1.0.4
A BigfundOutput is the recipient of some of the bigfilefunds spent in a transaction.
type BigfundOutputID ¶ added in v1.0.4
type BigfundOutputID Hash256
A BigfundOutputID uniquely identifies a bigfund output.
func (BigfundOutputID) ClaimOutputID ¶ added in v1.0.4
func (bfoid BigfundOutputID) ClaimOutputID() BigfileOutputID
ClaimOutputID returns the ID of the BigfileOutput that is created when the bigfund output is spent.
func (*BigfundOutputID) DecodeFrom ¶ added in v1.0.4
func (id *BigfundOutputID) DecodeFrom(d *Decoder)
DecodeFrom implements types.DecoderFrom.
func (BigfundOutputID) EncodeTo ¶ added in v1.0.4
func (id BigfundOutputID) EncodeTo(e *Encoder)
EncodeTo implements types.EncoderTo.
func (BigfundOutputID) MarshalText ¶ added in v1.0.4
func (bfoid BigfundOutputID) MarshalText() ([]byte, error)
MarshalText implements encoding.TextMarshaler.
func (BigfundOutputID) String ¶ added in v1.0.4
func (bfoid BigfundOutputID) String() string
String implements fmt.Stringer.
func (*BigfundOutputID) UnmarshalText ¶ added in v1.0.4
func (bfoid *BigfundOutputID) UnmarshalText(b []byte) error
UnmarshalText implements encoding.TextUnmarshaler.
func (BigfundOutputID) V2ClaimOutputID ¶ added in v1.0.4
func (bfoid BigfundOutputID) V2ClaimOutputID() BigfileOutputID
V2ClaimOutputID returns the ID of the BigfileOutput that is created when the bigfund output is spent.
type Block ¶
type Block struct {
ParentID BlockID `json:"parentID"`
Nonce uint64 `json:"nonce"`
Timestamp time.Time `json:"timestamp"`
MinerPayouts []BigfileOutput `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) V2Transactions ¶
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.
type BlockID ¶
type BlockID Hash256
A BlockID uniquely identifies a block.
func (*BlockID) DecodeFrom ¶
DecodeFrom implements types.DecoderFrom.
func (BlockID) FoundationOutputID ¶
func (bid BlockID) FoundationOutputID() BigfileOutputID
FoundationOutputID returns the ID of the block's Foundation subsidy.
func (BlockID) MarshalText ¶
MarshalText implements encoding.TextMarshaler.
func (BlockID) MinerOutputID ¶
func (bid BlockID) MinerOutputID(i int) BigfileOutputID
MinerOutputID returns the ID of the block's i'th miner payout.
func (*BlockID) UnmarshalText ¶
UnmarshalText implements encoding.TextUnmarshaler.
type ChainIndex ¶
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 ¶
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) UnmarshalJSON ¶
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 ¶
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) Copy ¶ added in v0.0.2
func (cie ChainIndexElement) Copy() ChainIndexElement
Copy returns a deep copy of the element. It must be used whenever the element's memory is copied.
func (*ChainIndexElement) DecodeFrom ¶
func (cie *ChainIndexElement) DecodeFrom(d *Decoder)
DecodeFrom implements types.DecoderFrom.
func (ChainIndexElement) EncodeTo ¶
func (cie ChainIndexElement) EncodeTo(e *Encoder)
EncodeTo implements types.EncoderTo.
func (ChainIndexElement) Move ¶ added in v0.0.2
func (cie ChainIndexElement) Move() ChainIndexElement
Move returns a shallow copy of the element. It must only be used when the element's memory is not shared.
func (ChainIndexElement) Share ¶ added in v0.0.2
func (cie ChainIndexElement) Share() ChainIndexElement
Share returns a shallow copy of the element. It must be used whenever the element's memory is intentionally aliased.
type CoveredFields ¶
type CoveredFields struct {
WholeTransaction bool `json:"wholeTransaction,omitempty"`
BigfileInputs []uint64 `json:"bigfileInputs,omitempty"`
BigfileOutputs []uint64 `json:"bigfileOutputs,omitempty"`
FileContracts []uint64 `json:"fileContracts,omitempty"`
FileContractRevisions []uint64 `json:"fileContractRevisions,omitempty"`
StorageProofs []uint64 `json:"storageProofs,omitempty"`
BigfundInputs []uint64 `json:"bigfundInputs,omitempty"`
BigfundOutputs []uint64 `json:"bigfundOutputs,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 ¶
NewCurrency returns the Currency value (lo,hi).
func NewCurrency64 ¶
NewCurrency64 converts c to a Currency value.
func ParseCurrency ¶
ParseCurrency parses s as a Currency value. The format of s should match one of the representations provided by (Currency).Format.
func (Currency) Add ¶
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 ¶
AddWithOverflow returns c+v, along with a boolean indicating whether the result overflowed.
func (Currency) Bigfiles ¶ added in v1.0.9
Bigfiles converts c to a floating-point number of bigfiles. This may result in a loss of precision.
func (Currency) Equals ¶
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 ¶
ExactString returns the base-10 representation of c as a string.
func (Currency) Format ¶
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) MarshalText ¶
MarshalText implements encoding.TextMarshaler.
func (Currency) Mul ¶
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 ¶
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 ¶
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 ¶
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) SubWithUnderflow ¶
SubWithUnderflow returns c-v, along with a boolean indicating whether the result underflowed.
func (*Currency) UnmarshalText ¶
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 ¶
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) Read ¶
Read implements the io.Reader interface. It always returns an error if fewer than len(p) bytes were read.
func (*Decoder) ReadString ¶
ReadString reads a length-prefixed string from the underlying stream.
func (*Decoder) ReadUint64 ¶
ReadUint64 reads a uint64 value from the underlying stream.
type DecoderFrom ¶
type DecoderFrom interface {
DecodeFrom(d *Decoder)
}
A DecoderFrom can decode itself from a stream via a Decoder.
type DecoderFunc ¶
type DecoderFunc func(*Decoder)
DecoderFunc implements types.DecoderTo with a function.
func (DecoderFunc) DecodeFrom ¶
func (fn DecoderFunc) DecodeFrom(d *Decoder)
DecodeFrom implements types.DecoderTo.
type ElementID ¶
type ElementID = [32]byte
An ElementID identifies a generic element within the state accumulator. In practice, it may be a BlockID, BigfileOutputID, BigfundOutputID, FileContractID, or AttestationID.
type Encoder ¶
type Encoder struct {
// contains filtered or unexported fields
}
An Encoder writes Bigfile objects to an underlying stream.
func NewEncoder ¶
NewEncoder returns an Encoder that wraps the provided stream.
func (*Encoder) Flush ¶
Flush writes any pending data to the underlying stream. It returns the first error encountered by the Encoder.
func (*Encoder) Reset ¶
Reset resets the Encoder to write to w. Any unflushed data, along with any error previously encountered, is discarded.
func (*Encoder) WriteBytes ¶
WriteBytes writes a length-prefixed []byte to the underlying stream.
func (*Encoder) WriteString ¶
WriteString writes a length-prefixed string to the underlying stream.
func (*Encoder) WriteUint8 ¶
WriteUint8 writes a uint8 value to the underlying stream.
func (*Encoder) WriteUint64 ¶
WriteUint64 writes a uint64 value to the underlying stream.
type EncoderFunc ¶
type EncoderFunc func(*Encoder)
EncoderFunc implements types.EncoderTo with a function.
func (EncoderFunc) EncodeTo ¶
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 []BigfileOutput `json:"validProofOutputs"`
MissedProofOutputs []BigfileOutput `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() BigfileOutput
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 bigfiles that the host will receive if the contract resolves missed.
func (*FileContract) MissedRenterOutput ¶
func (fc *FileContract) MissedRenterOutput() BigfileOutput
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 bigfiles that the renter will receive if the contract resolves missed.
func (*FileContract) ValidHostOutput ¶
func (fc *FileContract) ValidHostOutput() BigfileOutput
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 bigfiles that the host will receive if the contract resolves valid.
func (*FileContract) ValidRenterOutput ¶
func (fc *FileContract) ValidRenterOutput() BigfileOutput
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 bigfiles that the renter will receive if the contract resolves valid.
type FileContractElement ¶
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) Copy ¶ added in v0.0.2
func (fce FileContractElement) Copy() FileContractElement
Copy returns a deep copy of the element. It must be used whenever the element's memory is copied.
func (*FileContractElement) DecodeFrom ¶
func (fce *FileContractElement) DecodeFrom(d *Decoder)
DecodeFrom implements types.DecoderFrom.
func (FileContractElement) EncodeTo ¶
func (fce FileContractElement) EncodeTo(e *Encoder)
EncodeTo implements types.EncoderTo.
func (FileContractElement) Move ¶ added in v0.0.2
func (fce FileContractElement) Move() FileContractElement
Move returns a shallow copy of the element. It must only be used when the element's memory is not shared.
func (FileContractElement) Share ¶ added in v0.0.2
func (fce FileContractElement) Share() FileContractElement
Share returns a shallow copy of the element. It must be used whenever the element's memory is intentionally aliased.
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) BigfileOutputID
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 ¶
func (fcid FileContractID) V2HostOutputID() BigfileOutputID
V2HostOutputID returns the ID of the host output for a v2 contract.
func (FileContractID) V2RenewalID ¶
func (fcid FileContractID) V2RenewalID() FileContractID
V2RenewalID returns the ID of the renewal of a v2 contract.
func (FileContractID) V2RenterOutputID ¶
func (fcid FileContractID) V2RenterOutputID() BigfileOutputID
V2RenterOutputID returns the ID of the renter output for a v2 contract.
func (FileContractID) ValidOutputID ¶
func (fcid FileContractID) ValidOutputID(i int) BigfileOutputID
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 ¶
func (fcr FileContractRevision) MarshalJSON() ([]byte, error)
MarshalJSON implements json.Marshaler.
func (*FileContractRevision) UnmarshalJSON ¶
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 (*Hash256) DecodeFrom ¶
DecodeFrom implements types.DecoderFrom.
func (Hash256) MarshalText ¶
MarshalText implements encoding.TextMarshaler.
func (*Hash256) UnmarshalText ¶
UnmarshalText implements encoding.TextUnmarshaler.
type Hasher ¶
type Hasher struct {
E *Encoder
// contains filtered or unexported fields
}
A Hasher streams objects into an instance of Bigfile's hash function.
func (*Hasher) WriteDistinguisher ¶
WriteDistinguisher writes a distinguisher prefix to the encoder.
type PolicyTypeAbove ¶
type PolicyTypeAbove uint64
PolicyTypeAbove requires the input to be spent above a given block height.
type PolicyTypeAfter ¶
PolicyTypeAfter requires the input to be spent after a given timestamp.
type PolicyTypeHash ¶
type PolicyTypeHash Hash256
PolicyTypeHash requires the input to reveal a SHA256 hash preimage.
type PolicyTypeOpaque ¶
type PolicyTypeOpaque Address
PolicyTypeOpaque is the opaque hash of a policy. It is not satisfiable.
type PolicyTypePublicKey ¶
type PolicyTypePublicKey PublicKey
PolicyTypePublicKey requires the input to be signed by a given key.
type PolicyTypeThreshold ¶
type PolicyTypeThreshold struct {
N uint8 `json:"n"`
Of []SpendPolicy `json:"of"`
}
PolicyTypeThreshold requires at least N sub-policies to be satisfied.
type PolicyTypeUnlockConditions ¶
type PolicyTypeUnlockConditions UnlockConditions
PolicyTypeUnlockConditions reproduces the requirements imposed by Bigfile'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 ¶
DecodeFrom implements types.DecoderFrom.
func (PublicKey) MarshalText ¶
MarshalText implements encoding.TextMarshaler.
func (*PublicKey) UnmarshalText ¶
UnmarshalText implements encoding.TextUnmarshaler.
type SatisfiedPolicy ¶
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 ¶
func (sp *SatisfiedPolicy) DecodeFrom(d *Decoder)
DecodeFrom implements types.DecoderFrom.
func (SatisfiedPolicy) EncodeTo ¶
func (sp SatisfiedPolicy) EncodeTo(e *Encoder)
EncodeTo implements types.EncoderTo.
func (SatisfiedPolicy) MarshalJSON ¶
func (sp SatisfiedPolicy) MarshalJSON() ([]byte, error)
MarshalJSON implements json.Marshaler.
func (*SatisfiedPolicy) UnmarshalJSON ¶
func (sp *SatisfiedPolicy) UnmarshalJSON(b []byte) error
UnmarshalJSON implements json.Unmarshaler.
type Signature ¶
type Signature [64]byte
A Signature is an Ed25519 signature.
func (*Signature) DecodeFrom ¶
DecodeFrom implements types.DecoderFrom.
func (Signature) MarshalText ¶
MarshalText implements encoding.TextMarshaler.
func (*Signature) UnmarshalText ¶
UnmarshalText implements encoding.TextUnmarshaler.
type Specifier ¶
type Specifier [16]byte
A Specifier is a fixed-size, 0-padded identifier.
func NewSpecifier ¶
NewSpecifier returns a specifier containing the provided name.
func (*Specifier) DecodeFrom ¶
DecodeFrom implements types.DecoderFrom.
func (Specifier) MarshalText ¶
MarshalText implements encoding.TextMarshaler.
func (*Specifier) UnmarshalText ¶
UnmarshalText implements encoding.TextUnmarshaler.
type SpendPolicy ¶
type SpendPolicy struct {
Type interface {
// contains filtered or unexported methods
}
}
A SpendPolicy describes the conditions under which an input may be spent.
func AnyoneCanSpend ¶
func AnyoneCanSpend() SpendPolicy
AnyoneCanSpend returns a policy that has no requirements.
func ParseSpendPolicy ¶
func ParseSpendPolicy(s string) (SpendPolicy, error)
ParseSpendPolicy parses a spend policy from a string.
func PolicyAbove ¶
func PolicyAbove(height uint64) SpendPolicy
PolicyAbove returns a policy that requires the input to be spent above a given block height.
func PolicyAfter ¶
func PolicyAfter(t time.Time) SpendPolicy
PolicyAfter returns a policy that requires the input to be spent after a given timestamp.
func PolicyHash ¶
func PolicyHash(h Hash256) SpendPolicy
PolicyHash returns a policy that requires the input to reveal a SHA256 hash preimage.
func PolicyOpaque ¶
func PolicyOpaque(p SpendPolicy) SpendPolicy
PolicyOpaque returns a policy with the same address as p, but without its semantics.
func PolicyPublicKey ¶
func PolicyPublicKey(pk PublicKey) SpendPolicy
PolicyPublicKey returns a policy that requires the input to be signed by a given key.
func PolicyThreshold ¶
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 ¶
func (p SpendPolicy) Address() Address
Address computes the opaque address for a given policy.
func (*SpendPolicy) DecodeFrom ¶
func (p *SpendPolicy) DecodeFrom(d *Decoder)
DecodeFrom implements types.DecoderFrom.
func (SpendPolicy) EncodeTo ¶
func (p SpendPolicy) EncodeTo(e *Encoder)
EncodeTo implements types.EncoderTo.
func (SpendPolicy) MarshalJSON ¶
func (p SpendPolicy) MarshalJSON() ([]byte, error)
MarshalJSON implements json.Marshaler.
func (*SpendPolicy) UnmarshalJSON ¶
func (p *SpendPolicy) UnmarshalJSON(b []byte) (err error)
UnmarshalJSON implements json.Unmarshaler.
type StateElement ¶
type StateElement struct {
LeafIndex uint64 `json:"leafIndex"`
MerkleProof []Hash256 `json:"merkleProof,omitempty"`
// contains filtered or unexported fields
}
A StateElement is a generic element within the state accumulator.
func (StateElement) Copy ¶ added in v0.0.2
func (se StateElement) Copy() StateElement
Copy returns a deep copy of the element. It must be used whenever the element's memory is copied.
func (*StateElement) DecodeFrom ¶
func (se *StateElement) DecodeFrom(d *Decoder)
DecodeFrom implements types.DecoderFrom.
func (StateElement) EncodeTo ¶
func (se StateElement) EncodeTo(e *Encoder)
EncodeTo implements types.EncoderTo.
func (StateElement) Move ¶ added in v0.0.2
func (se StateElement) Move() StateElement
Move returns a shallow copy of the element. It must only be used when the element's memory is not shared.
func (StateElement) Share ¶ added in v0.0.2
func (se StateElement) Share() StateElement
Share returns a shallow copy of the element. It must be used whenever the element's memory is intentionally aliased.
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 ¶
func (sp StorageProof) MarshalJSON() ([]byte, error)
MarshalJSON implements json.Marshaler.
func (*StorageProof) UnmarshalJSON ¶
func (sp *StorageProof) UnmarshalJSON(b []byte) error
UnmarshalJSON implements json.Unmarshaler.
type Transaction ¶
type Transaction struct {
BigfileInputs []BigfileInput `json:"bigfileInputs,omitempty"`
BigfileOutputs []BigfileOutput `json:"bigfileOutputs,omitempty"`
FileContracts []FileContract `json:"fileContracts,omitempty"`
FileContractRevisions []FileContractRevision `json:"fileContractRevisions,omitempty"`
StorageProofs []StorageProof `json:"storageProofs,omitempty"`
BigfundInputs []BigfundInput `json:"bigfundInputs,omitempty"`
BigfundOutputs []BigfundOutput `json:"bigfundOutputs,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) BigfileOutputID ¶ added in v1.0.9
func (txn *Transaction) BigfileOutputID(i int) BigfileOutputID
BigfileOutputID returns the ID of the bigfile output at index i.
func (*Transaction) BigfundClaimOutputID ¶ added in v1.0.4
func (txn *Transaction) BigfundClaimOutputID(i int) BigfileOutputID
BigfundClaimOutputID returns the ID of the bigfile claim output for the bigfund input at index i.
func (*Transaction) BigfundOutputID ¶ added in v1.0.4
func (txn *Transaction) BigfundOutputID(i int) BigfundOutputID
BigfundOutputID returns the ID of the bigfund output at index i.
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 ¶
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 ¶
func (txn Transaction) MarshalJSON() ([]byte, error)
MarshalJSON implements json.Marshaler.
The transaction and UTXO IDs are calculated and included for convenience. These fields are ignored during unmarshalling.
func (*Transaction) MerkleLeafHash ¶ added in v1.0.8
func (txn *Transaction) MerkleLeafHash() Hash256
MerkleLeafHash returns the hash of the transaction as a leaf in a Merkle tree.
func (*Transaction) TotalFees ¶
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 ¶
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 ¶
An UnlockKey can provide one of the signatures required by a set of UnlockConditions.
func (*UnlockKey) DecodeFrom ¶
DecodeFrom implements types.DecoderFrom.
func (UnlockKey) MarshalText ¶
MarshalText implements encoding.TextMarshaler.
func (*UnlockKey) UnmarshalText ¶
UnmarshalText implements encoding.TextUnmarshaler.
type V1BigfileOutput ¶ added in v1.0.9
type V1BigfileOutput BigfileOutput
V1BigfileOutput provides v1 encoding for BigfileOutput.
func (V1BigfileOutput) Cast ¶ added in v1.0.9
func (bigo V1BigfileOutput) Cast() BigfileOutput
Cast provides type safety for DecodeSliceCast.
func (*V1BigfileOutput) DecodeFrom ¶ added in v1.0.9
func (bigo *V1BigfileOutput) DecodeFrom(d *Decoder)
DecodeFrom implements types.DecoderFrom.
func (V1BigfileOutput) EncodeTo ¶ added in v1.0.9
func (bigo V1BigfileOutput) EncodeTo(e *Encoder)
EncodeTo implements types.EncoderTo.
type V1BigfundOutput ¶ added in v1.0.4
type V1BigfundOutput BigfundOutput
V1BigfundOutput provides v1 encoding for BigfundOutput.
func (V1BigfundOutput) Cast ¶ added in v1.0.4
func (bfo V1BigfundOutput) Cast() BigfundOutput
Cast provides type safety for DecodeSliceCast.
func (*V1BigfundOutput) DecodeFrom ¶ added in v1.0.4
func (bfo *V1BigfundOutput) DecodeFrom(d *Decoder)
DecodeFrom implements types.DecoderFrom.
func (V1BigfundOutput) EncodeTo ¶ added in v1.0.4
func (bfo V1BigfundOutput) EncodeTo(e *Encoder)
EncodeTo implements types.EncoderTo.
type V1Block ¶
type V1Block Block
V1Block provides v1 encoding for Block.
func (*V1Block) DecodeFrom ¶
DecodeFrom implements types.DecoderFrom.
type V1Currency ¶
type V1Currency Currency
V1Currency provides v1 encoding for Currency.
func (V1Currency) Cast ¶
func (c V1Currency) Cast() Currency
Cast provides type safety for DecodeSliceCast.
func (*V1Currency) DecodeFrom ¶
func (c *V1Currency) DecodeFrom(d *Decoder)
DecodeFrom implements types.DecoderFrom.
func (V1Currency) EncodeTo ¶
func (c V1Currency) EncodeTo(e *Encoder)
EncodeTo implements types.EncoderTo.
type V2BigfileInput ¶ added in v1.0.9
type V2BigfileInput struct {
Parent BigfileElement `json:"parent"`
SatisfiedPolicy SatisfiedPolicy `json:"satisfiedPolicy"`
}
A V2BigfileInput spends an unspent BigfileElement in the state accumulator by revealing its public key and signing the transaction.
func (*V2BigfileInput) DecodeFrom ¶ added in v1.0.9
func (in *V2BigfileInput) DecodeFrom(d *Decoder)
DecodeFrom implements types.DecoderFrom.
func (V2BigfileInput) EncodeTo ¶ added in v1.0.9
func (in V2BigfileInput) EncodeTo(e *Encoder)
EncodeTo implements types.EncoderTo.
type V2BigfileOutput ¶ added in v1.0.9
type V2BigfileOutput BigfileOutput
V2BigfileOutput provides v2 encoding for BigfileOutput.
func (V2BigfileOutput) Cast ¶ added in v1.0.9
func (bigo V2BigfileOutput) Cast() BigfileOutput
Cast provides type safety for DecodeSliceCast.
func (*V2BigfileOutput) DecodeFrom ¶ added in v1.0.9
func (bigo *V2BigfileOutput) DecodeFrom(d *Decoder)
DecodeFrom implements types.DecoderFrom.
func (V2BigfileOutput) EncodeTo ¶ added in v1.0.9
func (bigo V2BigfileOutput) EncodeTo(e *Encoder)
EncodeTo implements types.EncoderTo.
type V2BigfundInput ¶ added in v1.0.4
type V2BigfundInput struct {
Parent BigfundElement `json:"parent"`
ClaimAddress Address `json:"claimAddress"`
SatisfiedPolicy SatisfiedPolicy `json:"satisfiedPolicy"`
}
A V2BigfundInput spends an unspent BigfundElement in the state accumulator by revealing its public key and signing the transaction. Inputs also include a ClaimAddress, specifying the recipient of the bigfiles that were earned by the BigfundElement.
func (*V2BigfundInput) DecodeFrom ¶ added in v1.0.4
func (in *V2BigfundInput) DecodeFrom(d *Decoder)
DecodeFrom implements types.DecoderFrom.
func (V2BigfundInput) EncodeTo ¶ added in v1.0.4
func (in V2BigfundInput) EncodeTo(e *Encoder)
EncodeTo implements types.EncoderTo.
type V2BigfundOutput ¶ added in v1.0.4
type V2BigfundOutput BigfundOutput
V2BigfundOutput provides v2 encoding for BigfundOutput.
func (V2BigfundOutput) Cast ¶ added in v1.0.4
func (bfo V2BigfundOutput) Cast() BigfundOutput
Cast provides type safety for DecodeSliceCast.
func (*V2BigfundOutput) DecodeFrom ¶ added in v1.0.4
func (bfo *V2BigfundOutput) DecodeFrom(d *Decoder)
DecodeFrom implements types.DecoderFrom.
func (V2BigfundOutput) EncodeTo ¶ added in v1.0.4
func (bfo V2BigfundOutput) EncodeTo(e *Encoder)
EncodeTo implements types.EncoderTo.
type V2Block ¶
type V2Block Block
V2Block provides v2 encoding for Block.
func (*V2Block) DecodeFrom ¶
DecodeFrom implements types.DecoderFrom.
type V2BlockData ¶
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 ¶
func (b *V2BlockData) DecodeFrom(d *Decoder)
DecodeFrom implements types.DecoderFrom.
func (V2BlockData) EncodeTo ¶
func (b V2BlockData) EncodeTo(e *Encoder)
EncodeTo implements types.EncoderTo.
type V2Currency ¶
type V2Currency Currency
V2Currency provides v2 encoding for Currency.
func (V2Currency) Cast ¶
func (c V2Currency) Cast() Currency
Cast provides type safety for DecodeSliceCast.
func (*V2Currency) DecodeFrom ¶
func (c *V2Currency) DecodeFrom(d *Decoder)
DecodeFrom implements types.DecoderFrom.
func (V2Currency) EncodeTo ¶
func (c V2Currency) EncodeTo(e *Encoder)
EncodeTo implements types.EncoderTo.
type V2FileContract ¶
type V2FileContract struct {
Capacity uint64 `json:"capacity"`
Filesize uint64 `json:"filesize"`
FileMerkleRoot Hash256 `json:"fileMerkleRoot"`
ProofHeight uint64 `json:"proofHeight"`
ExpirationHeight uint64 `json:"expirationHeight"`
RenterOutput BigfileOutput `json:"renterOutput"`
HostOutput BigfileOutput `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 ¶
func (fc *V2FileContract) DecodeFrom(d *Decoder)
DecodeFrom implements types.DecoderFrom.
func (V2FileContract) EncodeTo ¶
func (fc V2FileContract) EncodeTo(e *Encoder)
EncodeTo implements types.EncoderTo.
func (V2FileContract) MissedHostOutput ¶
func (fc V2FileContract) MissedHostOutput() BigfileOutput
MissedHostOutput returns the host output that will be created if the contract resolves missed.
type V2FileContractElement ¶
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) Copy ¶ added in v0.0.2
func (v2fce V2FileContractElement) Copy() V2FileContractElement
Copy returns a deep copy of the element. It must be used whenever the element's memory is copied.
func (*V2FileContractElement) DecodeFrom ¶
func (fce *V2FileContractElement) DecodeFrom(d *Decoder)
DecodeFrom implements types.DecoderFrom.
func (V2FileContractElement) EncodeTo ¶
func (fce V2FileContractElement) EncodeTo(e *Encoder)
EncodeTo implements types.EncoderTo.
func (V2FileContractElement) Move ¶ added in v0.0.2
func (v2fce V2FileContractElement) Move() V2FileContractElement
Move returns a shallow copy of the element. It must only be used when the element's memory is not shared.
func (V2FileContractElement) Share ¶ added in v0.0.2
func (v2fce V2FileContractElement) Share() V2FileContractElement
Share returns a shallow copy of the element. It must be used whenever the element's memory is intentionally aliased.
type V2FileContractExpiration ¶
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 ¶
func (*V2FileContractExpiration) DecodeFrom(d *Decoder)
DecodeFrom implements types.DecoderFrom.
func (V2FileContractExpiration) EncodeTo ¶
func (V2FileContractExpiration) EncodeTo(e *Encoder)
EncodeTo implements types.EncoderTo.
type V2FileContractRenewal ¶
type V2FileContractRenewal struct {
FinalRenterOutput BigfileOutput `json:"finalRenterOutput"`
FinalHostOutput BigfileOutput `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 ¶
func (ren *V2FileContractRenewal) DecodeFrom(d *Decoder)
DecodeFrom implements types.DecoderFrom.
func (V2FileContractRenewal) EncodeTo ¶
func (ren V2FileContractRenewal) EncodeTo(e *Encoder)
EncodeTo implements types.EncoderTo.
type V2FileContractResolution ¶
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 ¶
func (res *V2FileContractResolution) DecodeFrom(d *Decoder)
DecodeFrom implements types.DecoderFrom.
func (V2FileContractResolution) EncodeTo ¶
func (res V2FileContractResolution) EncodeTo(e *Encoder)
EncodeTo implements types.EncoderTo.
func (V2FileContractResolution) MarshalJSON ¶
func (res V2FileContractResolution) MarshalJSON() ([]byte, error)
MarshalJSON implements json.Marshaler.
func (*V2FileContractResolution) UnmarshalJSON ¶
func (res *V2FileContractResolution) UnmarshalJSON(b []byte) error
UnmarshalJSON implements json.Marshaler.
type V2FileContractResolutionType ¶
type V2FileContractResolutionType interface {
// contains filtered or unexported methods
}
V2FileContractResolutionType enumerates the types of file contract resolution.
type V2FileContractRevision ¶
type V2FileContractRevision struct {
Parent V2FileContractElement `json:"parent"`
Revision V2FileContract `json:"revision"`
}
A V2FileContractRevision updates the state of an existing file contract.
func (*V2FileContractRevision) DecodeFrom ¶
func (rev *V2FileContractRevision) DecodeFrom(d *Decoder)
DecodeFrom implements types.DecoderFrom.
func (V2FileContractRevision) EncodeTo ¶
func (rev V2FileContractRevision) EncodeTo(e *Encoder)
EncodeTo implements types.EncoderTo.
type V2StorageProof ¶
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 ¶
func (sp *V2StorageProof) DecodeFrom(d *Decoder)
DecodeFrom implements types.DecoderFrom.
func (V2StorageProof) EncodeTo ¶
func (sp V2StorageProof) EncodeTo(e *Encoder)
EncodeTo implements types.EncoderTo.
func (V2StorageProof) MarshalJSON ¶
func (sp V2StorageProof) MarshalJSON() ([]byte, error)
MarshalJSON implements json.Marshaler.
func (*V2StorageProof) UnmarshalJSON ¶
func (sp *V2StorageProof) UnmarshalJSON(b []byte) error
UnmarshalJSON implements json.Unmarshaler.
type V2Transaction ¶
type V2Transaction struct {
BigfileInputs []V2BigfileInput `json:"bigfileInputs,omitempty"`
BigfileOutputs []BigfileOutput `json:"bigfileOutputs,omitempty"`
BigfundInputs []V2BigfundInput `json:"bigfundInputs,omitempty"`
BigfundOutputs []BigfundOutput `json:"bigfundOutputs,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 ¶
func (*V2Transaction) AttestationID(txid TransactionID, i int) AttestationID
AttestationID returns the ID for the attestation at index i.
func (*V2Transaction) BigfileOutputID ¶ added in v1.0.9
func (*V2Transaction) BigfileOutputID(txid TransactionID, i int) BigfileOutputID
BigfileOutputID returns the ID for the bigfile output at index i.
func (*V2Transaction) BigfundOutputID ¶ added in v1.0.4
func (*V2Transaction) BigfundOutputID(txid TransactionID, i int) BigfundOutputID
BigfundOutputID returns the ID for the bigfund output at index i.
func (*V2Transaction) DecodeFrom ¶
func (txn *V2Transaction) DecodeFrom(d *Decoder)
DecodeFrom implements types.DecoderFrom.
func (*V2Transaction) DeepCopy ¶
func (txn *V2Transaction) DeepCopy() V2Transaction
DeepCopy returns a copy of txn that does not alias any of its memory.
func (V2Transaction) EncodeTo ¶
func (txn V2Transaction) EncodeTo(e *Encoder)
EncodeTo implements types.EncoderTo.
func (*V2Transaction) EphemeralBigfileOutput ¶ added in v1.0.9
func (txn *V2Transaction) EphemeralBigfileOutput(i int) BigfileElement
EphemeralBigfileOutput returns a BigfileElement for the bigfile output at index i.
func (*V2Transaction) EphemeralBigfundOutput ¶ added in v1.0.4
func (txn *V2Transaction) EphemeralBigfundOutput(i int) BigfundElement
EphemeralBigfundOutput returns a BigfundElement for the bigfund output at index i.
func (*V2Transaction) FullHash ¶
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 ¶
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 ¶
func (txn V2Transaction) MarshalJSON() ([]byte, error)
MarshalJSON implements json.Marshaler.
For convenience, the transaction's ID is also calculated and included. This field is ignored during unmarshalling.
func (*V2Transaction) MerkleLeafHash ¶ added in v1.0.8
func (txn *V2Transaction) MerkleLeafHash() Hash256
MerkleLeafHash returns the hash of the transaction as a leaf in a Merkle tree.
func (*V2Transaction) V2FileContractID ¶
func (*V2Transaction) V2FileContractID(txid TransactionID, i int) FileContractID
V2FileContractID returns the ID for the v2 file contract at index i.
type V2TransactionSemantics ¶
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 ¶
func (txn V2TransactionSemantics) EncodeTo(e *Encoder)
EncodeTo implements types.EncoderTo.
type V2TransactionsMultiproof ¶
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 ¶
func (txns *V2TransactionsMultiproof) DecodeFrom(d *Decoder)
DecodeFrom implements types.DecoderFrom.
func (V2TransactionsMultiproof) EncodeTo ¶
func (txns V2TransactionsMultiproof) EncodeTo(e *Encoder)
EncodeTo implements types.EncoderTo.