types

package
v1.3.0 Latest Latest
Warning

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

Go to latest
Published: Apr 24, 2020 License: BSD-3-Clause Imports: 17 Imported by: 10

Documentation

Index

Constants

View Source
const (
	// MaxNamesPerBot defines the maximum amount of names allowed per unique bot.
	MaxNamesPerBot = 5
	// MaxAddressesPerBot defines the maximum amount of addresses allowed per unique bot.
	MaxAddressesPerBot = 10
)
View Source
const (
	// BotMonth is defined as 30 days of exactly 24 hours, expressed in seconds.
	BotMonth = 60 * 60 * 24 * 30
	// MaxBotPrepaidMonths defines the amount of months that is allowed to be maximum
	// paid upfront, as to keep a 3bot active.
	MaxBotPrepaidMonths = 24
	// MaxBotPrepaidMonthsInSeconds defines the amount of time that is allowed to be maximum
	// paid upfront, which is the equavalent of roughly 2 years.
	MaxBotPrepaidMonthsInSeconds = MaxBotPrepaidMonths * BotMonth
)
View Source
const (
	// RegexpBotName is used to validate a (raw) 3bot name (string).
	RegexpBotName = `^[A-Za-z]{1}[A-Za-z\-0-9]{3,61}[A-Za-z0-9]{1}(\.[A-Za-z]{1}[A-Za-z\-0-9]{3,55}[A-Za-z0-9]{1})*$`
	// MaxLengthBotName defines the maximum length a 3bot name can have.
	MaxLengthBotName = 63
)
View Source
const (
	// MinBotID defines the minimum value a botID can have,
	// in other words the smallest identifier value a Bot can have.
	MinBotID = 1
	// MaxBotID defines the maximum value a Bot ID can have,
	// in other words the biggest identifier value a Bot can have.
	MaxBotID = math.MaxUint32
)
View Source
const (
	// RegexpHostname is used to validate a (raw) hostname (string).
	RegexpHostname = `` /* 181-byte string literal not displayed */
	// MaxLengthHostname defines the maximum length a hostname can have,
	// within the context of tfchain.
	MaxLengthHostname = 63
)
View Source
const (
	// TransactionVersionBotRegistration defines the Transaction version
	// for a BotRegistration Transaction, used to register a new 3bot,
	// where new means that the used public key cannot yet exist.
	TransactionVersionBotRegistration types.TransactionVersion = iota + 144
	// TransactionVersionBotRecordUpdate defines the Transaction version
	// for a Tx used to update a 3bot Record by the owner. where owner
	// means the 3bot that created the record to be updated initially using the BotRegistration Tx.
	TransactionVersionBotRecordUpdate
	// TransactionVersionBotNameTransfer defines the Transaction version
	// for a Tx used to transfer one or multiple names from the active
	// 3bot that up to the point of that Tx to another 3bot.
	TransactionVersionBotNameTransfer
)
View Source
const (
	BotFeePerAdditionalNameMultiplier           = 50
	BotFeeForNetworkAddressInfoChangeMultiplier = 20
	BotRegistrationFeeMultiplier                = 90
	BotMonthlyFeeMultiplier                     = 10
)

3bot Multiplier fees that have to be multiplied with the OneCoin definition, in order to know the amount in the used chain currency (TFT).

View Source
const TransactionNonceLength = 8

TransactionNonceLength defines the length of a TransactionNonce

Variables

View Source
var (
	// ErrTooManyBotNames is the error returned in case a bot which has more than 5
	// names defined is attempted to be (un)marshaled, or in case an amount of names
	// to be added to the bot's record would overflow this limit of 5.
	ErrTooManyBotNames = errors.New("a 3bot can have a maximum of 5 names")
	// ErrBotNameNotUnique is the error returned in case a 3bot name is added
	// that is already registered in this 3bot.
	ErrBotNameNotUnique = errors.New("the name is already registerd with this 3bot")
	// ErrNetworkAddressNotUnique is the error returned in case a network address is added
	// that is already registered in this 3bot.
	ErrNetworkAddressNotUnique = errors.New("the network address is already registerd with this 3bot")
	// ErrBotNameDoesNotExist is the error returned in case a 3bot name is removed
	// that is not registered in this 3bot.
	ErrBotNameDoesNotExist = errors.New("the name is not registerd with this 3bot")
	// ErrNetworkAddressDoesNotExist is the error returned in case a network address is removed
	// that is not registered in this 3bot.
	ErrNetworkAddressDoesNotExist = errors.New("the network address is not registerd with this 3bot")
	// ErrTooManyBotAddresses is the error returned in case a bot which has more than 10
	// addresses defined is attempted to be (un)marshaled, or in case an amount of addresses
	// to be added to the bot's record would overflow this limit of 10.
	ErrTooManyBotAddresses = errors.New("a 3bot can have a maximum of 10 addresses")
	// ErrBotExpirationExtendOverflow is returned in case a 3bot's expiration date is extended
	// using too many months (a max of 24 is allowed)
	ErrBotExpirationExtendOverflow = errors.New("a 3bot can only have up to 24 months prepaid")
)
View Source
var (
	// ErrNilBotName is the error returned in case a new bot name is attempted to be
	// created (from memory or bytes) from nil.
	ErrNilBotName = errors.New("nil bot name")
	// ErrBotNameTooLong is the error returned in case a new bot name is attempted to be
	// created using a too long string.
	ErrBotNameTooLong = errors.New("the length of a hostname can maximum be 127 bytes long")
	// ErrInvalidBotName is the error returned in case a to-be-created (or decoded)
	// botname.
	ErrInvalidBotName = errors.New("invalid bot name")
)
View Source
var (
	// ErrNilHostname is the error returned in case a new network address is attempted to be
	// created (from memory or bytes) from nil.
	ErrNilHostname = errors.New("nil hostname")
	// ErrHostnameTooLong is the error returned in case a new network address is attempted to be
	// created with a too long string.
	ErrHostnameTooLong = errors.New("the length of a hostname can maximum be 63 bytes long")
	// ErrInvalidNetworkAddress is the error returned in case a to-be-created (or decoded)
	// network address is invalid (meaning it is no valid hostname or IPv4/IPv6 address).
	ErrInvalidNetworkAddress = errors.New("invalid network address")
)
View Source
var (
	SpecifierBotRegistrationTransaction = types.Specifier{'b', 'o', 't', ' ', 'r', 'e', 'g', 'i', 's', 't', 'e', 'r', ' ', 't', 'x'}
	SpecifierBotRecordUpdateTransaction = types.Specifier{'b', 'o', 't', ' ', 'r', 'e', 'c', 'u', 'p', 'd', 'a', 't', 'e', ' ', 't', 'x'}
	SpecifierBotNameTransferTransaction = types.Specifier{'b', 'o', 't', ' ', 'n', 'a', 'm', 'e', 't', 'r', 'a', 'n', 's', ' ', 't', 'x'}
)
View Source
var (
	ErrBotKeyAlreadyRegistered  = errors.New("bot key is already registered")
	ErrBotNameAlreadyRegistered = errors.New("bot name is already registered")
)

Bot validation errors

View Source
var (
	BotSignatureSpecifierSender   = [...]byte{'s', 'e', 'n', 'd', 'e', 'r'}
	BotSignatureSpecifierReceiver = [...]byte{'r', 'e', 'c', 'e', 'i', 'v', 'e', 'r'}
)

Specifiers used to ensure the bot-signatures are unique within each Tx.

View Source
var (
	ErrBotNotFound     = errors.New("3bot not found")
	ErrBotKeyNotFound  = errors.New("3bot public key not found")
	ErrBotNameNotFound = errors.New("3bot name not found")
	ErrBotNameExpired  = errors.New("3bot name expired")
)

public BotRecordReadRegistry errors

Functions

func ComputeMonthlyBotFees

func ComputeMonthlyBotFees(months uint8, oneCoin types.Currency) types.Currency

ComputeMonthlyBotFees computes the total monthly fees required for the given months, using the given oneCoin value as the currency's unit value.

Types

type BotID

type BotID uint32

BotID defines the identifier type for 3bots, each 3bot has a unique identifier using this type.

func (*BotID) LoadString

func (id *BotID) LoadString(str string) error

LoadString loads a botID from a string

func (BotID) String

func (id BotID) String() string

String implements fmt.Stringer.String

type BotIdentifierSignaturePair

type BotIdentifierSignaturePair struct {
	Identifier BotID           `json:"id"`
	Signature  types.ByteSlice `json:"signature"`
}

BotIdentifierSignaturePair pairs a bot identifier and a signature assumed to be created by the bot linked to that ID.

type BotMonthsAndFlagsData

type BotMonthsAndFlagsData struct {
	NrOfMonths   uint8
	HasAddresses bool
	HasNames     bool
	HasRefund    bool
}

BotMonthsAndFlagsData is a utility structure that is used to encode the NrOfMonths (paid up front for a 3bot) as well as several flags in a single byte.

func (BotMonthsAndFlagsData) MarshalRivine

func (maf BotMonthsAndFlagsData) MarshalRivine(w io.Writer) error

MarshalRivine implements RivineMarshaler.MarshalRivine

func (BotMonthsAndFlagsData) MarshalSia

func (maf BotMonthsAndFlagsData) MarshalSia(w io.Writer) error

MarshalSia implements SiaMarshaler.MarshalSia, alias of MarshalRivine for backwards-compatibility reasons.

func (*BotMonthsAndFlagsData) UnmarshalRivine

func (maf *BotMonthsAndFlagsData) UnmarshalRivine(r io.Reader) error

UnmarshalRivine implements RivineUnmarshaler.UnmarshalRivine

func (*BotMonthsAndFlagsData) UnmarshalSia

func (maf *BotMonthsAndFlagsData) UnmarshalSia(r io.Reader) error

UnmarshalSia implements SiaUnmarshaler.UnmarshalSia, alias of UnmarshalRivine for backwards-compatibility reasons.

type BotName

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

BotName defines the name type for 3bots. Each 3bot can define up to 5 unique (DNS) names.

func NewBotName

func NewBotName(name string) (BotName, error)

NewBotName creates a new BotName from a given (valid) string.

func (BotName) Compare

func (bn BotName) Compare(obn BotName) int

Compare returns an integer comparing two bot names lexicographically (case insensitive). The result will be 0 if a==b, -1 if a < b, and +1 if a > b.

func (BotName) Equals

func (bn BotName) Equals(obn BotName) bool

Equals returns true if this BotName and the given BotName are equal (case insensitive).

func (*BotName) LoadString

func (bn *BotName) LoadString(str string) (err error)

LoadString loads the BotName from a human-readable string.

func (BotName) MarshalJSON

func (bn BotName) MarshalJSON() ([]byte, error)

MarshalJSON marshals a byte slice as a hex string.

func (BotName) MarshalRivine

func (bn BotName) MarshalRivine(w io.Writer) error

MarshalRivine implements RivineMarshaler.MarshalRivine

func (BotName) MarshalSia

func (bn BotName) MarshalSia(w io.Writer) error

MarshalSia implements SiaMarshaler.MarshalSia

func (BotName) String

func (bn BotName) String() string

String returns this BotName in a (human-readable) string format.

func (*BotName) UnmarshalJSON

func (bn *BotName) UnmarshalJSON(b []byte) error

UnmarshalJSON decodes the json (hex-encoded) string of the byte slice.

func (*BotName) UnmarshalRivine

func (bn *BotName) UnmarshalRivine(r io.Reader) error

UnmarshalRivine implements RivineUnmarshaler.UnmarshalRivine

func (*BotName) UnmarshalSia

func (bn *BotName) UnmarshalSia(r io.Reader) error

UnmarshalSia implements SiaUnmarshaler.UnmarshalSia

type BotNameSortedSet

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

BotNameSortedSet represents a sorted set of (unique) bot names.

A BotNameSortedSet does not expose it elements, as this is not a feature-requirement of tfchain, all it aims for is to ensure the set consists only of unique elements.

func (*BotNameSortedSet) AddName

func (bnss *BotNameSortedSet) AddName(name BotName) error

AddName adds a new (unique) bot name to this sorted set of bot names, returning an error if the name already exists within this sorted set.

func (*BotNameSortedSet) BinaryDecode

func (bnss *BotNameSortedSet) BinaryDecode(r io.Reader, length int) error

BinaryDecode can be used instead of UnmarshalRivine, should one need to decode the length prefix in a way other than the standard tfchain-slice approach. The decoding of the length has to happen prior to calling this method.

func (BotNameSortedSet) BinaryEncode

func (bnss BotNameSortedSet) BinaryEncode(w io.Writer) (int, error)

BinaryEncode can be used instead of MarshalRivine, should one want to encode the length prefix in a way other than the standard tfchain-slice approach. The encoding of the length has to happen prior to calling this method.

func (BotNameSortedSet) Difference

func (bnss BotNameSortedSet) Difference(other BotNameSortedSet) []BotName

Difference returns the difference of this and the other set, meaning it will return all bot names which are in this set but not in the other.

func (BotNameSortedSet) Intersection

func (bnss BotNameSortedSet) Intersection(other BotNameSortedSet) []BotName

Intersection returns the intersection of this and the other set, meaning it will return all bot names which are in this set AND in the other.

func (BotNameSortedSet) Len

func (bnss BotNameSortedSet) Len() int

Len returns the amount of network addresses in this sorted set.

func (BotNameSortedSet) MarshalJSON

func (bnss BotNameSortedSet) MarshalJSON() ([]byte, error)

MarshalJSON implements encoding/json.Marshaler.MarshalJSON

func (BotNameSortedSet) MarshalRivine

func (bnss BotNameSortedSet) MarshalRivine(w io.Writer) error

MarshalRivine implements rivbin.RivineMarshaler.MarshalRivine

func (BotNameSortedSet) MarshalSia

func (bnss BotNameSortedSet) MarshalSia(w io.Writer) error

MarshalSia implements siabin.SiaMarshaler.MarshalSia

func (*BotNameSortedSet) RemoveName

func (bnss *BotNameSortedSet) RemoveName(name BotName) error

RemoveName removes an existing bot name from this sorted set of bot names, returning an error if the name did not yet exist in this sorted set.

func (*BotNameSortedSet) UnmarshalJSON

func (bnss *BotNameSortedSet) UnmarshalJSON(data []byte) error

UnmarshalJSON implements encoding/json.Unmarshaler.UnmarshalJSON

func (*BotNameSortedSet) UnmarshalRivine

func (bnss *BotNameSortedSet) UnmarshalRivine(r io.Reader) error

UnmarshalRivine implements rivbin.RivineUnmarshaler.UnmarshalRivine

func (*BotNameSortedSet) UnmarshalSia

func (bnss *BotNameSortedSet) UnmarshalSia(r io.Reader) error

UnmarshalSia implements siabin.SiaUnmarshaler.UnmarshalSia

type BotNameTransferTransaction

type BotNameTransferTransaction struct {
	// Sender is in this context the 3bot that owns and transfers the names
	// defined in this Tx to the 3bot defined in this Tx as the Receiver.
	// The Sender has to be different from the Receiver.
	Sender BotIdentifierSignaturePair `json:"sender"`
	// Receiver is in this context the 3bot that receives the names
	// defined in this Tx from the 3bot defined in this Tx as the Sender.
	// The Receiver has to be different from the Sender.
	Receiver BotIdentifierSignaturePair `json:"receiver"`

	// Names to be transferred from sender to receiver. Note that after each Tx,
	// no more than 5 names can be linked to a single 3bot record.
	Names []BotName `json:"names"`

	// TransactionFee defines the regular Tx fee.
	TransactionFee types.Currency `json:"txfee"`

	// CoinInputs are only used for the required fees,
	// which contains the regular Tx fee as well as the additional fees,
	// to be paid for a 3bot record update. At least one CoinInput is required.
	// If this 3bot record update is only to pay for extending the 3bot activity,
	// than no fees are required other than the monthly fees as defined by this bots usage.
	CoinInputs []types.CoinInput `json:"coininputs"`
	// RefundCoinOutput is an optional coin output that can be used
	// to refund coins paid as inputs for the required fees.
	RefundCoinOutput *types.CoinOutput `json:"refundcoinoutput,omitempty"`
}

BotNameTransferTransaction defines the Transaction (with version 0x92) used to transfer one or multiple names from the active 3bot that up to the point of the Tx to another 3bot.

func BotNameTransferTransactionFromTransaction

func BotNameTransferTransactionFromTransaction(tx types.Transaction) (BotNameTransferTransaction, error)

BotNameTransferTransactionFromTransaction creates a BotNameTransferTransaction, using a regular in-memory tfchain transaction.

Past the (tx) Version validation it piggy-backs onto the `BotNameTransferTransactionFromTransactionData` constructor.

func BotNameTransferTransactionFromTransactionData

func BotNameTransferTransactionFromTransactionData(txData types.TransactionData) (BotNameTransferTransaction, error)

BotNameTransferTransactionFromTransactionData creates a BotNameTransferTransaction, using the TransactionData from a regular in-memory tfchain transaction.

func (BotNameTransferTransaction) MarshalRivine

func (bnttx BotNameTransferTransaction) MarshalRivine(w io.Writer) error

MarshalRivine implements RivineMarshaler.MarshalRivine

func (BotNameTransferTransaction) MarshalSia

func (bnttx BotNameTransferTransaction) MarshalSia(w io.Writer) error

MarshalSia implements SiaMarshaler.MarshalSia, alias of MarshalRivine for backwards-compatibility reasons.

func (*BotNameTransferTransaction) RequiredBotFee

func (bnttx *BotNameTransferTransaction) RequiredBotFee(oneCoin types.Currency) types.Currency

RequiredBotFee computes the required Bot Fee, that is to be applied as a required additional fee on top of the regular required (minimum) Tx fee.

func (*BotNameTransferTransaction) RevertReceiverBotRecordUpdate

func (bnttx *BotNameTransferTransaction) RevertReceiverBotRecordUpdate(record *BotRecord) error

RevertReceiverBotRecordUpdate reverts the given record update, within the context of the given blockTime, using the information of this BotRecordUpdateTransaction.

This method should only be called once for the given record, as it has no way of checking whether or not it already reverted the update of the given record.

NOTE: implicit updates such as time jumps in expiration time (due to an inactive bot that became active again) and names that were implicitly removed because the bot was inactive, are not reverted by this method, and have to be added manually reverted.

func (*BotNameTransferTransaction) RevertSenderBotRecordUpdate

func (bnttx *BotNameTransferTransaction) RevertSenderBotRecordUpdate(record *BotRecord) error

RevertSenderBotRecordUpdate reverts the given record update, within the context of the given blockTime, using the information of this BotRecordUpdateTransaction.

This method should only be called once for the given record, as it has no way of checking whether or not it already reverted the update of the given record.

func (*BotNameTransferTransaction) Transaction

func (bnttx *BotNameTransferTransaction) Transaction(oneCoin types.Currency) types.Transaction

Transaction returns this BotNameTransferTransaction as regular tfchain transaction, using TransactionVersionBotNameTransfer as the type.

func (*BotNameTransferTransaction) TransactionData

func (bnttx *BotNameTransferTransaction) TransactionData(oneCoin types.Currency) types.TransactionData

TransactionData returns this BotNameTransferTransaction as regular tfchain transaction data.

func (*BotNameTransferTransaction) UnmarshalRivine

func (bnttx *BotNameTransferTransaction) UnmarshalRivine(r io.Reader) error

UnmarshalRivine implements RivineUnmarshaler.UnmarshalRivine

func (*BotNameTransferTransaction) UnmarshalSia

func (bnttx *BotNameTransferTransaction) UnmarshalSia(r io.Reader) error

UnmarshalSia implements SiaUnmarshaler.UnmarshalSia, alias of UnmarshalRivine for backwards-compatibility reasons.

func (*BotNameTransferTransaction) UpdateReceiverBotRecord

func (bnttx *BotNameTransferTransaction) UpdateReceiverBotRecord(blockTime types.Timestamp, record *BotRecord) error

UpdateReceiverBotRecord updates the given (receiver bot) record, within the context of the given blockTime, using the information of this BotNameTransferTransaction.

This method should only be called once for the given (receiver bot) record, as it has no way of checking whether or not it already updated the given record.

func (*BotNameTransferTransaction) UpdateSenderBotRecord

func (bnttx *BotNameTransferTransaction) UpdateSenderBotRecord(blockTime types.Timestamp, record *BotRecord) error

UpdateSenderBotRecord updates the given (sender bot) record, within the context of the given blockTime, using the information of this BotNameTransferTransaction.

This method should only be called once for the given (sender bot) record, as it has no way of checking whether or not it already updated the given record.

type BotNameTransferTransactionController

type BotNameTransferTransactionController struct {
	Registry            BotRecordReadRegistry
	RegistryPoolAddress types.UnlockHash
	OneCoin             types.Currency
}

BotNameTransferTransactionController defines a tfchain-specific transaction controller, for a transaction type reserved at type 0x92. It allows the transfer of names and update of the record of the two existing 3bot that participate in this transfer.

func (BotNameTransferTransactionController) DecodeTransactionData

func (bnttc BotNameTransferTransactionController) DecodeTransactionData(r io.Reader) (types.TransactionData, error)

DecodeTransactionData implements TransactionController.DecodeTransactionData

func (BotNameTransferTransactionController) EncodeTransactionData

func (bnttc BotNameTransferTransactionController) EncodeTransactionData(w io.Writer, txData types.TransactionData) error

EncodeTransactionData implements TransactionController.EncodeTransactionData

func (BotNameTransferTransactionController) EncodeTransactionIDInput

func (bnttc BotNameTransferTransactionController) EncodeTransactionIDInput(w io.Writer, txData types.TransactionData) error

EncodeTransactionIDInput implements TransactionIDEncoder.EncodeTransactionIDInput

func (BotNameTransferTransactionController) GetCustomMinerPayouts

func (bnttc BotNameTransferTransactionController) GetCustomMinerPayouts(extension interface{}) ([]types.MinerPayout, error)

GetCustomMinerPayouts implements TransactionCustomMinerPayoutGetter.GetCustomMinerPayouts

func (BotNameTransferTransactionController) JSONDecodeTransactionData

func (bnttc BotNameTransferTransactionController) JSONDecodeTransactionData(data []byte) (types.TransactionData, error)

JSONDecodeTransactionData implements TransactionController.JSONDecodeTransactionData

func (BotNameTransferTransactionController) JSONEncodeTransactionData

func (bnttc BotNameTransferTransactionController) JSONEncodeTransactionData(txData types.TransactionData) ([]byte, error)

JSONEncodeTransactionData implements TransactionController.JSONEncodeTransactionData

func (BotNameTransferTransactionController) SignExtension

func (bnttc BotNameTransferTransactionController) SignExtension(extension interface{}, sign func(*types.UnlockFulfillmentProxy, types.UnlockConditionProxy, ...interface{}) error) (interface{}, error)

SignExtension implements TransactionExtensionSigner.SignExtension

func (BotNameTransferTransactionController) SignatureHash

func (bnttc BotNameTransferTransactionController) SignatureHash(t types.Transaction, extraObjects ...interface{}) (crypto.Hash, error)

SignatureHash implements TransactionSignatureHasher.SignatureHash

type BotNameTransferTransactionExtension

type BotNameTransferTransactionExtension struct {
	Sender   BotIdentifierSignaturePair
	Receiver BotIdentifierSignaturePair
	Names    []BotName
}

BotNameTransferTransactionExtension defines the BotNameTransferTransaction Extension Data

func (*BotNameTransferTransactionExtension) RequiredBotFee

func (bnttxe *BotNameTransferTransactionExtension) RequiredBotFee(oneCoin types.Currency) types.Currency

RequiredBotFee computes the required Bot Fee, that is to be applied as a required additional fee on top of the regular required (minimum) Tx fee.

type BotRecord

type BotRecord struct {
	ID         BotID                   `json:"id"`
	Addresses  NetworkAddressSortedSet `json:"addresses,omitempty"`
	Names      BotNameSortedSet        `json:"names,omitempty"`
	PublicKey  types.PublicKey         `json:"publickey"`
	Expiration CompactTimestamp        `json:"expiration"`
}

BotRecord is the record type used to store a unique 3bot in the TransactionDB. Per 3bot there is one BotRecord. Once a record is created it is never deleted, but it can be modified by the 3bot using one of the available Transaction types.

func (*BotRecord) AddNames

func (record *BotRecord) AddNames(names ...BotName) error

AddNames adds one or multiple unique (DNS) names to this 3bot record.

func (*BotRecord) AddNetworkAddresses

func (record *BotRecord) AddNetworkAddresses(addresses ...NetworkAddress) error

AddNetworkAddresses adds one or multiple unique network addresses to this 3bot record.

func (*BotRecord) ExtendExpirationDate

func (record *BotRecord) ExtendExpirationDate(blockTime types.Timestamp, addedMonths uint8) error

ExtendExpirationDate extends the expiration day of this 3bot record based on the block time and the months to add.

func (*BotRecord) IsExpired

func (record *BotRecord) IsExpired(blockTime types.Timestamp) bool

IsExpired returns if this record indicate the bot is expired.

func (BotRecord) MarshalRivine

func (record BotRecord) MarshalRivine(w io.Writer) error

MarshalRivine implements RivineMarshaler.MarshalRivine

func (BotRecord) MarshalSia

func (record BotRecord) MarshalSia(w io.Writer) error

MarshalSia implements SiaMarshaler.MarshalSia, alias of MarshalRivine for backwards-compatibility reasons.

func (*BotRecord) RemoveNames

func (record *BotRecord) RemoveNames(names ...BotName) error

RemoveNames removes one or multiple unique (DNS) names from this 3bot record.

func (*BotRecord) RemoveNetworkAddresses

func (record *BotRecord) RemoveNetworkAddresses(addresses ...NetworkAddress) error

RemoveNetworkAddresses removes one or multiple unique network addresses from this 3bot record.

func (*BotRecord) ResetNames

func (record *BotRecord) ResetNames()

ResetNames removes all names (if any) from the current record, reseting it to a nil set of bot names.

func (*BotRecord) UnmarshalRivine

func (record *BotRecord) UnmarshalRivine(r io.Reader) error

UnmarshalRivine implements RivineUnmarshaler.UnmarshalRivine

func (*BotRecord) UnmarshalSia

func (record *BotRecord) UnmarshalSia(r io.Reader) error

UnmarshalSia implements SiaUnmarshaler.UnmarshalSia, alias of UnmarshalRivine for backwards-compatibility reasons.

type BotRecordAddressUpdate

type BotRecordAddressUpdate struct {
	Add    []NetworkAddress `json:"add,omitempty"`
	Remove []NetworkAddress `json:"remove,omitempty"`
}

BotRecordAddressUpdate contains all information required for an update to the addresses of a bot's record.

type BotRecordNameUpdate

type BotRecordNameUpdate struct {
	Add    []BotName `json:"add,omitempty"`
	Remove []BotName `json:"remove,omitempty"`
}

BotRecordNameUpdate contains all information required for an update to the names of a bot's record.

type BotRecordReadRegistry

type BotRecordReadRegistry interface {
	// GetRecordForID returns the record mapped to the given BotID.
	GetRecordForID(id BotID) (*BotRecord, error)
	// GetRecordForKey returns the record mapped to the given Key.
	GetRecordForKey(key types.PublicKey) (*BotRecord, error)
	// GetRecordForName returns the record mapped to the given Name.
	GetRecordForName(name BotName) (*BotRecord, error)
	// GetBotTransactionIdentifiers returns the identifiers of all transactions
	// that created and updated the given bot's record.
	//
	// The transaction identifiers are returned in the (stable) order as defined by the blockchain.
	GetBotTransactionIdentifiers(id BotID) ([]types.TransactionID, error)
}

BotRecordReadRegistry defines the public READ API expected from a bot record Read-Only registry.

type BotRecordUpdateTransaction

type BotRecordUpdateTransaction struct {
	// Identifier of the 3bot, used to find the 3bot record to be updated,
	// and verify that the Tx is authorized to do so.
	Identifier BotID `json:"id"`

	// Addresses can be used to add and/or remove network addresses
	// to/from the existing 3bot record. Note that after each Tx,
	// no more than 10 addresses can be linked to a single 3bot record.
	Addresses BotRecordAddressUpdate `json:"addresses,omitempty"`

	// Names can be used to add and/or remove names
	// to/from the existing 3bot record. Note that after each Tx,
	// no more than 5 names can be linked to a single 3bot record.
	Names BotRecordNameUpdate `json:"names,omitempty"`

	// NrOfMonths defines the optional amount of months that
	// is desired to be paid upfront in this update. Note that the amount of
	// months defined here defines how much additional fees are to be paid.
	// The NrOfMonths has to be within this inclusive range [0,24].
	NrOfMonths uint8 `json:"nrofmonths"`

	// TransactionFee defines the regular Tx fee.
	TransactionFee types.Currency `json:"txfee"`

	// CoinInputs are only used for the required fees,
	// which contains the regular Tx fee as well as the additional fees,
	// to be paid for a 3bot record update. At least one CoinInput is required.
	// If this 3bot record update is only to pay for extending the 3bot activity,
	// than no fees are required other than the monthly fees as defined by this bots usage.
	CoinInputs []types.CoinInput `json:"coininputs"`
	// RefundCoinOutput is an optional coin output that can be used
	// to refund coins paid as inputs for the required fees.
	RefundCoinOutput *types.CoinOutput `json:"refundcoinoutput,omitempty"`

	// Signature is used to proof the ownership of the 3bot record to be updated,
	// and is verified using the public key defined in the 3bot linked
	// to the given (3bot) identifier.
	Signature types.ByteSlice `json:"signature"`
}

BotRecordUpdateTransaction defines the Transaction (with version 0x91) used to update a 3bot Record by the owner. where owner means the 3bot that created the record to be updated initially using the BotRegistration Tx.

func BotRecordUpdateTransactionFromTransaction

func BotRecordUpdateTransactionFromTransaction(tx types.Transaction) (BotRecordUpdateTransaction, error)

BotRecordUpdateTransactionFromTransaction creates a BotRecordUpdateTransaction, using a regular in-memory tfchain transaction.

Past the (tx) Version validation it piggy-backs onto the `BotRecordUpdateTransactionFromTransactionData` constructor.

func BotRecordUpdateTransactionFromTransactionData

func BotRecordUpdateTransactionFromTransactionData(txData types.TransactionData) (BotRecordUpdateTransaction, error)

BotRecordUpdateTransactionFromTransactionData creates a BotRecordUpdateTransaction, using the TransactionData from a regular in-memory tfchain transaction.

func (BotRecordUpdateTransaction) MarshalRivine

func (brutx BotRecordUpdateTransaction) MarshalRivine(w io.Writer) error

MarshalRivine implements RivineMarshaler.MarshalRivine

func (BotRecordUpdateTransaction) MarshalSia

func (brutx BotRecordUpdateTransaction) MarshalSia(w io.Writer) error

MarshalSia implements SiaMarshaler.MarshalSia, alias of MarshalRivine for backwards-compatibility reasons.

func (*BotRecordUpdateTransaction) RequiredBotFee

func (brutx *BotRecordUpdateTransaction) RequiredBotFee(oneCoin types.Currency) (fee types.Currency)

RequiredBotFee computes the required Bot Fee, that is to be applied as a required additional fee on top of the regular required (minimum) Tx fee.

func (*BotRecordUpdateTransaction) RevertBotRecordUpdate

func (brutx *BotRecordUpdateTransaction) RevertBotRecordUpdate(record *BotRecord) error

RevertBotRecordUpdate reverts the given record update, within the context of the given blockTime, using the information of this BotRecordUpdateTransaction.

This method should only be called once for the given record, as it has no way of checking whether or not it already reverted the update of the given record.

NOTE: implicit updates such as time jumps in expiration time (due to an inactive bot that became active again) and names that were implicitly removed because the bot was inactive, are not reverted by this method, and have to be added manually reverted.

func (*BotRecordUpdateTransaction) Transaction

func (brutx *BotRecordUpdateTransaction) Transaction(oneCoin types.Currency) types.Transaction

Transaction returns this BotRecordUpdateTransaction as regular tfchain transaction, using TransactionVersionBotRecordUpdate as the type.

func (*BotRecordUpdateTransaction) TransactionData

func (brutx *BotRecordUpdateTransaction) TransactionData(oneCoin types.Currency) types.TransactionData

TransactionData returns this BotRecordUpdateTransaction as regular tfchain transaction data.

func (*BotRecordUpdateTransaction) UnmarshalRivine

func (brutx *BotRecordUpdateTransaction) UnmarshalRivine(r io.Reader) error

UnmarshalRivine implements RivineUnmarshaler.UnmarshalRivine

func (*BotRecordUpdateTransaction) UnmarshalSia

func (brutx *BotRecordUpdateTransaction) UnmarshalSia(r io.Reader) error

UnmarshalSia implements SiaUnmarshaler.UnmarshalSia, alias of UnmarshalRivine for backwards-compatibility reasons.

func (*BotRecordUpdateTransaction) UpdateBotRecord

func (brutx *BotRecordUpdateTransaction) UpdateBotRecord(blockTime types.Timestamp, record *BotRecord) error

UpdateBotRecord updates the given record, within the context of the given blockTime, using the information of this BotRecordUpdateTransaction.

This method should only be called once for the given record, as it has no way of checking whether or not it already updated the given record.

type BotRecordUpdateTransactionExtension

type BotRecordUpdateTransactionExtension struct {
	Identifier    BotID
	Signature     types.ByteSlice
	AddressUpdate BotRecordAddressUpdate
	NameUpdate    BotRecordNameUpdate
	NrOfMonths    uint8
}

BotRecordUpdateTransactionExtension defines the BotRecordUpdateTransaction Extension Data

func (*BotRecordUpdateTransactionExtension) RequiredBotFee

func (brutxe *BotRecordUpdateTransactionExtension) RequiredBotFee(oneCoin types.Currency) (fee types.Currency)

RequiredBotFee computes the required Bot Fee, that is to be applied as a required additional fee on top of the regular required (minimum) Tx fee.

type BotRegistrationTransaction

type BotRegistrationTransaction struct {
	// Addresses contains the optional network addresses used to reach the 3bot.
	// Normally at least one is given, none are required however.
	// All addresses (max 10) can be of any of the following types: IPv4, IPv6, hostname
	Addresses []NetworkAddress `json:"addresses,omitempty"`
	// Names contains the optional names (max 5) that can be used to reach the bot,
	// using a name, instead of one of its network addresses, comparable to how DNS works.
	Names []BotName `json:"names,omitempty"`

	// NrOfMonths defines the amount of months that
	// is desired to be paid upfront. Note that the amount of
	// months defined here indicates how much additional fees are to be paid.
	// The NrOfMonths has to be within this inclusive range [1,24].
	NrOfMonths uint8 `json:"nrofmonths"`

	// TransactionFee defines the regular Tx fee.
	TransactionFee types.Currency `json:"txfee"`

	// CoinInputs are only used for the required fees,
	// which contains the regular Tx fee as well as the additional fees,
	// to be paid for a 3bot registration. At least one CoinInput is required.
	CoinInputs []types.CoinInput `json:"coininputs"`
	// RefundCoinOutput is an optional coin output that can be used
	// to refund coins paid as inputs for the required fees.
	RefundCoinOutput *types.CoinOutput `json:"refundcoinoutput,omitempty"`

	// Identification is used to identify the 3bot and verify its identity.
	// The identification is only given at registration, for all other
	// 3bot Tx types it is identified by a combination of its unique ID and signature.
	Identification PublicKeySignaturePair `json:"identification"`
}

BotRegistrationTransaction defines the Transaction (with version 0x90) used to register a new 3bot, where new means that the used public key (identification) cannot yet exist.

func BotRegistrationTransactionFromTransaction

func BotRegistrationTransactionFromTransaction(tx types.Transaction) (BotRegistrationTransaction, error)

BotRegistrationTransactionFromTransaction creates a BotRegistrationTransaction, using a regular in-memory tfchain transaction.

Past the (tx) Version validation it piggy-backs onto the `BotRegistrationTransactionFromTransactionData` constructor.

func BotRegistrationTransactionFromTransactionData

func BotRegistrationTransactionFromTransactionData(txData types.TransactionData) (BotRegistrationTransaction, error)

BotRegistrationTransactionFromTransactionData creates a BotRegistrationTransaction, using the TransactionData from a regular in-memory tfchain transaction.

func (BotRegistrationTransaction) MarshalRivine

func (brtx BotRegistrationTransaction) MarshalRivine(w io.Writer) error

MarshalRivine implements RivineMarshaler.MarshalRivine

func (BotRegistrationTransaction) MarshalSia

func (brtx BotRegistrationTransaction) MarshalSia(w io.Writer) error

MarshalSia implements SiaMarshaler.MarshalSia, alias of MarshalRivine for backwards-compatibility reasons.

func (*BotRegistrationTransaction) RequiredBotFee

func (brtx *BotRegistrationTransaction) RequiredBotFee(oneCoin types.Currency) types.Currency

RequiredBotFee computes the required Bot Fee, that is to be applied as a required additional fee on top of the regular required (minimum) Tx fee.

func (*BotRegistrationTransaction) Transaction

func (brtx *BotRegistrationTransaction) Transaction(oneCoin types.Currency) types.Transaction

Transaction returns this BotRegistrationTransaction as regular tfchain transaction, using TransactionVersionBotRegistration as the type.

func (*BotRegistrationTransaction) TransactionData

func (brtx *BotRegistrationTransaction) TransactionData(oneCoin types.Currency) types.TransactionData

TransactionData returns this BotRegistrationTransaction as regular tfchain transaction data.

func (*BotRegistrationTransaction) UnmarshalRivine

func (brtx *BotRegistrationTransaction) UnmarshalRivine(r io.Reader) error

UnmarshalRivine implements RivineUnmarshaler.UnmarshalRivine

func (*BotRegistrationTransaction) UnmarshalSia

func (brtx *BotRegistrationTransaction) UnmarshalSia(r io.Reader) error

UnmarshalSia implements SiaUnmarshaler.UnmarshalSia, alias of UnmarshalRivine for backwards-compatibility reasons.

type BotRegistrationTransactionController

type BotRegistrationTransactionController struct {
	Registry            BotRecordReadRegistry
	RegistryPoolAddress types.UnlockHash
	OneCoin             types.Currency
}

BotRegistrationTransactionController defines a tfchain-specific transaction controller, for a transaction type reserved at type 0x90. It allows the registration of a new3bot.

func (BotRegistrationTransactionController) DecodeTransactionData

func (brtc BotRegistrationTransactionController) DecodeTransactionData(r io.Reader) (types.TransactionData, error)

DecodeTransactionData implements TransactionController.DecodeTransactionData

func (BotRegistrationTransactionController) EncodeTransactionData

func (brtc BotRegistrationTransactionController) EncodeTransactionData(w io.Writer, txData types.TransactionData) error

EncodeTransactionData implements TransactionController.EncodeTransactionData

func (BotRegistrationTransactionController) EncodeTransactionIDInput

func (brtc BotRegistrationTransactionController) EncodeTransactionIDInput(w io.Writer, txData types.TransactionData) error

EncodeTransactionIDInput implements TransactionIDEncoder.EncodeTransactionIDInput

func (BotRegistrationTransactionController) GetCommonExtensionData

func (brtc BotRegistrationTransactionController) GetCommonExtensionData(extension interface{}) (types.CommonTransactionExtensionData, error)

GetCommonExtensionData implements TransactionCommonExtensionDataGetter.GetCommonExtensionData

func (BotRegistrationTransactionController) GetCustomMinerPayouts

func (brtc BotRegistrationTransactionController) GetCustomMinerPayouts(extension interface{}) ([]types.MinerPayout, error)

GetCustomMinerPayouts implements TransactionCustomMinerPayoutGetter.GetCustomMinerPayouts

func (BotRegistrationTransactionController) JSONDecodeTransactionData

func (brtc BotRegistrationTransactionController) JSONDecodeTransactionData(data []byte) (types.TransactionData, error)

JSONDecodeTransactionData implements TransactionController.JSONDecodeTransactionData

func (BotRegistrationTransactionController) JSONEncodeTransactionData

func (brtc BotRegistrationTransactionController) JSONEncodeTransactionData(txData types.TransactionData) ([]byte, error)

JSONEncodeTransactionData implements TransactionController.JSONEncodeTransactionData

func (BotRegistrationTransactionController) SignExtension

func (brtc BotRegistrationTransactionController) SignExtension(extension interface{}, sign func(*types.UnlockFulfillmentProxy, types.UnlockConditionProxy, ...interface{}) error) (interface{}, error)

SignExtension implements TransactionExtensionSigner.SignExtension

func (BotRegistrationTransactionController) SignatureHash

func (brtc BotRegistrationTransactionController) SignatureHash(t types.Transaction, extraObjects ...interface{}) (crypto.Hash, error)

SignatureHash implements TransactionSignatureHasher.SignatureHash

type BotRegistrationTransactionExtension

type BotRegistrationTransactionExtension struct {
	Addresses      []NetworkAddress
	Names          []BotName
	NrOfMonths     uint8
	Identification PublicKeySignaturePair
}

BotRegistrationTransactionExtension defines the BotRegistrationTransaction Extension Data

func (*BotRegistrationTransactionExtension) RequiredBotFee

func (brtxe *BotRegistrationTransactionExtension) RequiredBotFee(oneCoin types.Currency) types.Currency

RequiredBotFee computes the required Bot Fee, that is to be applied as a required additional fee on top of the regular required (minimum) Tx fee.

type BotUpdateRecordTransactionController

type BotUpdateRecordTransactionController struct {
	Registry            BotRecordReadRegistry
	RegistryPoolAddress types.UnlockHash
	OneCoin             types.Currency
}

BotUpdateRecordTransactionController defines a tfchain-specific transaction controller, for a transaction type reserved at type 0x91. It allows the update of the record of an existing 3bot.

func (BotUpdateRecordTransactionController) DecodeTransactionData

func (brutc BotUpdateRecordTransactionController) DecodeTransactionData(r io.Reader) (types.TransactionData, error)

DecodeTransactionData implements TransactionController.DecodeTransactionData

func (BotUpdateRecordTransactionController) EncodeTransactionData

func (brutc BotUpdateRecordTransactionController) EncodeTransactionData(w io.Writer, txData types.TransactionData) error

EncodeTransactionData implements TransactionController.EncodeTransactionData

func (BotUpdateRecordTransactionController) EncodeTransactionIDInput

func (brutc BotUpdateRecordTransactionController) EncodeTransactionIDInput(w io.Writer, txData types.TransactionData) error

EncodeTransactionIDInput implements TransactionIDEncoder.EncodeTransactionIDInput

func (BotUpdateRecordTransactionController) GetCustomMinerPayouts

func (brutc BotUpdateRecordTransactionController) GetCustomMinerPayouts(extension interface{}) ([]types.MinerPayout, error)

GetCustomMinerPayouts implements TransactionCustomMinerPayoutGetter.GetCustomMinerPayouts

func (BotUpdateRecordTransactionController) JSONDecodeTransactionData

func (brutc BotUpdateRecordTransactionController) JSONDecodeTransactionData(data []byte) (types.TransactionData, error)

JSONDecodeTransactionData implements TransactionController.JSONDecodeTransactionData

func (BotUpdateRecordTransactionController) JSONEncodeTransactionData

func (brutc BotUpdateRecordTransactionController) JSONEncodeTransactionData(txData types.TransactionData) ([]byte, error)

JSONEncodeTransactionData implements TransactionController.JSONEncodeTransactionData

func (BotUpdateRecordTransactionController) SignExtension

func (brutc BotUpdateRecordTransactionController) SignExtension(extension interface{}, sign func(*types.UnlockFulfillmentProxy, types.UnlockConditionProxy, ...interface{}) error) (interface{}, error)

SignExtension implements TransactionExtensionSigner.SignExtension

func (BotUpdateRecordTransactionController) SignatureHash

func (brutc BotUpdateRecordTransactionController) SignatureHash(t types.Transaction, extraObjects ...interface{}) (crypto.Hash, error)

SignatureHash implements TransactionSignatureHasher.SignatureHash

type CompactTimestamp

type CompactTimestamp uint64

CompactTimestamp binary marshals the regular Unix Epoch (seconds) Timestamp, in a custom format, such that it only requires 3 bytes in space. It does so by being only accurate up to 60 seconds, and by starting the Timestamp since `CompactTimestampNullpoint`.

const (
	// CompactTimestampNullpoint defines the time at which the Timestamp starts (~Jan '18)
	CompactTimestampNullpoint CompactTimestamp = 1515000000
	// CompactTimestampAccuracyInSeconds defines the lowest possible value that gets recorded in seconds
	CompactTimestampAccuracyInSeconds CompactTimestamp = 60
)

func NowAsCompactTimestamp

func NowAsCompactTimestamp() CompactTimestamp

NowAsCompactTimestamp returns the current Epoch Unix seconds time as a Tfchain Compact timestamp.

func SiaTimestampAsCompactTimestamp

func SiaTimestampAsCompactTimestamp(ts types.Timestamp) CompactTimestamp

SiaTimestampAsCompactTimestamp converts a Sia/Rivine Timestamp to a Tfchain Compact timestamp.

func (CompactTimestamp) MarshalRivine

func (cts CompactTimestamp) MarshalRivine(w io.Writer) error

MarshalRivine implements RivineMarshaler.MarshalRivine

func (CompactTimestamp) MarshalSia

func (cts CompactTimestamp) MarshalSia(w io.Writer) error

MarshalSia implements SiaMarshaler.MarshalSia, Alias of MarshalRivine for backwards-compatibility.

func (*CompactTimestamp) SetUInt32

func (cts *CompactTimestamp) SetUInt32(x uint32)

SetUInt32 sets an uint32 version of this CompactTimestamp as the internal value of this compact time stmap.

func (CompactTimestamp) SiaTimestamp

func (cts CompactTimestamp) SiaTimestamp() types.Timestamp

SiaTimestamp returns this CompactTimestamp as a Unix Epoch Seconds timestamp, the type wrapped by a Sia/Rivine timestamp.

func (CompactTimestamp) UInt32

func (cts CompactTimestamp) UInt32() uint32

UInt32 returns this CompactTimestamp as an uint32 number.

func (*CompactTimestamp) UnmarshalJSON

func (cts *CompactTimestamp) UnmarshalJSON(b []byte) error

UnmarshalJSON implements json.Unmarshaler.UnmarshalJSON

func (*CompactTimestamp) UnmarshalRivine

func (cts *CompactTimestamp) UnmarshalRivine(r io.Reader) error

UnmarshalRivine implements RivineUnmarshaler.UnmarshalRivine

func (*CompactTimestamp) UnmarshalSia

func (cts *CompactTimestamp) UnmarshalSia(r io.Reader) error

UnmarshalSia implements SiaUnmarshaler.UnmarshalSia, Alias of UnmarshalRivine for backwards-compatibility.

type NetworkAddress

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

NetworkAddress represents a NetworkAddress, meaning an IPv4/6 address or (domain) hostname.

func NewNetworkAddress

func NewNetworkAddress(addr string) (NetworkAddress, error)

NewNetworkAddress creates a new NetworkAddress from a given (valid) string.

func (NetworkAddress) Compare

func (na NetworkAddress) Compare(ona NetworkAddress) int

Compare returns an integer comparing two network addresses. If the types are equal the addresses are compared lexicographically, otherwise the compare result of the network address types is returned. The final result will be 0 if a==b, -1 if a < b, and +1 if a > b.

func (NetworkAddress) Equals

func (na NetworkAddress) Equals(ona NetworkAddress) bool

Equals returns true if this NetworkAddress and the given NetworkAddress are equal.

func (*NetworkAddress) LoadString

func (na *NetworkAddress) LoadString(str string) (err error)

LoadString loads the NetworkAddress from a human-readable string.

func (NetworkAddress) MarshalJSON

func (na NetworkAddress) MarshalJSON() ([]byte, error)

MarshalJSON marshals a byte slice as a hex string.

func (NetworkAddress) MarshalRivine

func (na NetworkAddress) MarshalRivine(w io.Writer) error

MarshalRivine marshals this NetworkAddress in a compact binary format.

func (NetworkAddress) MarshalSia

func (na NetworkAddress) MarshalSia(w io.Writer) error

MarshalSia marshals this NetworkAddress in a compact binary format. Alias of MarshalRivine, for backwards-compatibility

func (NetworkAddress) String

func (na NetworkAddress) String() string

String returns this NetworkAddress in a (human-readable) string format.

func (*NetworkAddress) UnmarshalJSON

func (na *NetworkAddress) UnmarshalJSON(b []byte) error

UnmarshalJSON decodes the json (hex-encoded) string of the byte slice.

func (*NetworkAddress) UnmarshalRivine

func (na *NetworkAddress) UnmarshalRivine(r io.Reader) error

UnmarshalRivine unmarshals this NetworkAddress from a compact binary format.

func (*NetworkAddress) UnmarshalSia

func (na *NetworkAddress) UnmarshalSia(r io.Reader) error

UnmarshalSia unmarshals this NetworkAddress from a semi-compact binary format. Alias of UnmarshalRivine, for backwards-compatibility

type NetworkAddressSortedSet

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

NetworkAddressSortedSet represents a sorted set of (unique) network addresses.

A NetworkAddressSortedSet does not expose it elements, as this is not a feature-requirement of tfchain, all it aims for is to ensure the set consists only of unique elements.

func (*NetworkAddressSortedSet) AddAddress

func (nass *NetworkAddressSortedSet) AddAddress(address NetworkAddress) error

AddAddress adds a new (unique) network address to this sorted set of network addresses, returning an error if the address already exists within this sorted set.

func (*NetworkAddressSortedSet) BinaryDecode

func (nass *NetworkAddressSortedSet) BinaryDecode(r io.Reader, length int) error

BinaryDecode can be used instead of UnmarshalRivine, should one need to decode the length prefix in a way other than the standard tfchain-slice approach. The decoding of the length has to happen prior to calling this method.

func (NetworkAddressSortedSet) BinaryEncode

func (nass NetworkAddressSortedSet) BinaryEncode(w io.Writer) (int, error)

BinaryEncode can be used instead of MarshalRivine, should one want to encode the length prefix in a way other than the standard tfchain-slice approach. The encoding of the length has to happen prior to calling this method.

func (NetworkAddressSortedSet) Len

func (nass NetworkAddressSortedSet) Len() int

Len returns the amount of network addresses in this sorted set.

func (NetworkAddressSortedSet) MarshalJSON

func (nass NetworkAddressSortedSet) MarshalJSON() ([]byte, error)

MarshalJSON implements encoding/json.Marshaler.MarshalJSON

func (NetworkAddressSortedSet) MarshalRivine

func (nass NetworkAddressSortedSet) MarshalRivine(w io.Writer) error

MarshalRivine implements rivbin.RivineMarshaler.MarshalRivine

func (NetworkAddressSortedSet) MarshalSia

func (nass NetworkAddressSortedSet) MarshalSia(w io.Writer) error

MarshalSia implements siabin.SiaMarshaler.MarshalSia

func (*NetworkAddressSortedSet) RemoveAddress

func (nass *NetworkAddressSortedSet) RemoveAddress(address NetworkAddress) error

RemoveAddress removes an existing network address from this sorted set of network addresses, returning an error if the address did not yet exist in this sorted set.

func (*NetworkAddressSortedSet) UnmarshalJSON

func (nass *NetworkAddressSortedSet) UnmarshalJSON(data []byte) error

UnmarshalJSON implements encoding/json.Unmarshaler.UnmarshalJSON

func (*NetworkAddressSortedSet) UnmarshalRivine

func (nass *NetworkAddressSortedSet) UnmarshalRivine(r io.Reader) error

UnmarshalRivine implements rivbin.RivineUnmarshaler.UnmarshalRivine

func (*NetworkAddressSortedSet) UnmarshalSia

func (nass *NetworkAddressSortedSet) UnmarshalSia(r io.Reader) error

UnmarshalSia implements siabin.SiaUnmarshaler.UnmarshalSia

type NetworkAddressType

type NetworkAddressType uint8

NetworkAddressType defines the type of a network address.

const (
	// NetworkAddressHostname represents a valid hostname, assumed to be a valid FQDN,
	// and defined as described in RFC 1178.
	NetworkAddressHostname NetworkAddressType = iota
	// NetworkAddressIPv4 represents an IPv4 address, meaning an address identified by 4 bytes,
	// and defined as described in RFC 791.
	NetworkAddressIPv4
	// NetworkAddressIPv6 represents an IPv6 address, meaning an address identified by 6 bytes,
	// and defined as described in RFC 2460.
	NetworkAddressIPv6
)

type PublicKeySignaturePair

type PublicKeySignaturePair struct {
	PublicKey types.PublicKey `json:"publickey"`
	Signature types.ByteSlice `json:"signature"`
}

PublicKeySignaturePair pairs a public key and a signature that can be validated with it.

func (PublicKeySignaturePair) MarshalRivine

func (pksp PublicKeySignaturePair) MarshalRivine(w io.Writer) error

MarshalRivine implements RivineMarshaler.MarshalRivine

func (PublicKeySignaturePair) MarshalSia

func (pksp PublicKeySignaturePair) MarshalSia(w io.Writer) error

MarshalSia implements SiaMarshaler.MarshalSia

func (*PublicKeySignaturePair) UnmarshalRivine

func (pksp *PublicKeySignaturePair) UnmarshalRivine(r io.Reader) error

UnmarshalRivine implements RivineUnmarshaler.UnmarshalRivine

func (*PublicKeySignaturePair) UnmarshalSia

func (pksp *PublicKeySignaturePair) UnmarshalSia(r io.Reader) error

UnmarshalSia implements SiaUnmarshaler.UnmarshalSia

type TransactionNonce

type TransactionNonce [TransactionNonceLength]byte

TransactionNonce is a nonce used to ensure the uniqueness of an otherwise potentially non-unique Tx

func RandomTransactionNonce

func RandomTransactionNonce() (nonce TransactionNonce)

RandomTransactionNonce creates a random Transaction nonce

func (TransactionNonce) MarshalJSON

func (tn TransactionNonce) MarshalJSON() ([]byte, error)

MarshalJSON implements JSON.Marshaller.MarshalJSON encodes the Nonce as a base64-encoded string

func (*TransactionNonce) UnmarshalJSON

func (tn *TransactionNonce) UnmarshalJSON(in []byte) error

UnmarshalJSON implements JSON.Unmarshaller.UnmarshalJSON piggy-backing on the base64-decoding used for byte slices in the std JSON lib

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL