Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
var ( // ErrI3vcoinSourceAlreadyAdded is the error returned when a user tries to // provide the same source i3vcoin input multiple times. ErrI3vcoinSourceAlreadyAdded = errors.New("source i3vcoin input has already been used") // ErrI3vcoinInputAlreadyUsed warns a user that a i3vcoin input has already // been used in the transaction graph. ErrI3vcoinInputAlreadyUsed = errors.New("cannot use the same i3vcoin input twice in a graph") // ErrNoSuchI3vcoinInput warns a user that they are trying to reference a // i3vcoin input which does not yet exist. ErrNoSuchI3vcoinInput = errors.New("no i3vcoin input exists with that index") // ErrI3vcoinInputsOutputsMismatch warns a user that they have constructed a // transaction which does not spend the same amount of i3vcoins that it // consumes. ErrI3vcoinInputsOutputsMismatch = errors.New("i3vcoin input value to transaction does not match i3vcoin output value of transaction") )
var ( // AnyoneCanSpendUnlockHash is the unlock hash of unlock conditions that are // trivially spendable. AnyoneCanSpendUnlockHash types.UnlockHash = types.UnlockConditions{}.UnlockHash() )
Functions ¶
func MinimumTransactionSet ¶
func MinimumTransactionSet(requiredTxns []types.Transaction, relatedTxns []types.Transaction) []types.Transaction
MinimumTransactionSet takes two transaction sets as input and returns a combined transaction set. The first input is the set of required transactions, which the caller is indicating must all be a part of the final set.The second input is a set of related transactions that the caller believes may contain parent transactions of the required transactions. MinimumCombinedSet will scan through the related transactions and pull in any which are required parents of the required transactions, returning the final result.
The final transaction set which gets returned will contain all of the required transactions, and will contain any of the related transactions which are necessary for the required transactions to be confirmed.
NOTE: Both of the inputs are proper transaction sets. A proper transaction set is already sorted so that no parent comes after a child in the array.
func SprintTxnWithObjectIDs ¶
func SprintTxnWithObjectIDs(t types.Transaction) string
SprintTxnWithObjectIDs creates a string representing this Transaction in human-readable form with all object IDs included to allow for easy dependency matching (by humans) in debug-logs.
Types ¶
type SimpleTransaction ¶
type SimpleTransaction struct { I3vcoinInputs []int // Which inputs to use, by index. I3vcoinOutputs []types.Currency // The values of each output. MinerFees []types.Currency // The fees used. }
SimpleTransaction specifies what outputs it spends, and what outputs it creates, by index. When passed in TransactionGraph, it will be automatically transformed into a valid transaction.
Currently, there is only support for I3vcoinInputs, I3vcoinOutputs, and MinerFees, however the code has been structured so that support for I3vfunds and FileContracts can be easily added in the future.
type TransactionGraph ¶
type TransactionGraph struct {
// contains filtered or unexported fields
}
TransactionGraph is a helper tool to allow a user to easily construct elaborate transaction graphs. The transaction tool will handle creating valid transactions, providing the user with a clean interface for building transactions.
func NewTransactionGraph ¶
func NewTransactionGraph() *TransactionGraph
NewTransactionGraph will return a blank transaction graph that is ready for use.
func (*TransactionGraph) AddI3vcoinSource ¶
func (tg *TransactionGraph) AddI3vcoinSource(scoid types.I3vcoinOutputID, value types.Currency) (int, error)
AddI3vcoinSource will add a new source of i3vcoins to the transaction graph, returning the index that this source can be referenced by. The provided output must have the address AnyoneCanSpendUnlockHash.
The value is used as an input so that the graph can check whether all transactions are spending as many i3vcoins as they create.
func (*TransactionGraph) AddTransaction ¶
func (tg *TransactionGraph) AddTransaction(st SimpleTransaction) (newI3vcoinInputs []int, err error)
AddTransaction will add a new transaction to the transaction graph, following the guide of the input. The indexes of all the outputs created will be returned.
func (*TransactionGraph) Transactions ¶
func (tg *TransactionGraph) Transactions() []types.Transaction
Transactions will return the transactions that were built up in the graph.