Documentation ¶
Index ¶
- func AppendBlocks(chain *protocol.Chain, num uint64) error
- func CreateCoinbaseTx(controlProgram []byte, height, txsFee uint64) (*types.Tx, error)
- func CreateSpendInput(tx *types.Tx, outputIndex uint64) (*types.SpendInput, error)
- func CreateTxFromTx(baseTx *types.Tx, outputIndex uint64, outputAmount uint64, ctrlProgram []byte) (*types.Tx, error)
- func MockBlock() *bc.Block
- func MockChain(testDB dbm.DB) (*protocol.Chain, *database.Store, *protocol.TxPool, error)
- func MockSign(tpl *txbuilder.Template, hsm *pseudohsm.HSM, password string) (bool, error)
- func MockTx(utxo *account.UTXO, testAccount *account.Account) (*txbuilder.Template, *types.TxData, error)
- func MockUTXO(controlProg *account.CtrlProgram) *account.UTXO
- func NewBlock(chain *protocol.Chain, txs []*types.Tx, controlProgram []byte) (*types.Block, error)
- func ReplaceCoinbase(block *types.Block, coinbaseTx *types.Tx) (err error)
- func SignInstructionFor(input *types.SpendInput, db dbm.DB, signer *signers.Signer) (*txbuilder.SigningInstruction, error)
- type TxGenerator
- func (g *TxGenerator) AddRetirement(assetAlias string, amount uint64) error
- func (g *TxGenerator) AddSpendInput(accountAlias, assetAlias string, amount uint64) error
- func (g *TxGenerator) AddTxInput(txInput *types.TxInput, signInstruction *txbuilder.SigningInstruction) error
- func (g *TxGenerator) AddTxInputFromUtxo(utxo *account.UTXO, accountAlias string) error
- func (g *TxGenerator) AddTxOutput(accountAlias, assetAlias string, amount uint64) error
- func (g *TxGenerator) Reset()
- func (g *TxGenerator) Sign(passwords []string) (*types.Tx, error)
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func AppendBlocks ¶
AppendBlocks append empty blocks to chain, mainly used to mature the coinbase tx
func CreateCoinbaseTx ¶
CreateCoinbaseTx create coinbase tx at block height
func CreateSpendInput ¶
CreateSpendInput create SpendInput which spent the output from tx
func CreateTxFromTx ¶
func CreateTxFromTx(baseTx *types.Tx, outputIndex uint64, outputAmount uint64, ctrlProgram []byte) (*types.Tx, error)
CreateTxFromTx create a tx spent the output in outputIndex at baseTx
func MockTx ¶
func MockTx(utxo *account.UTXO, testAccount *account.Account) (*txbuilder.Template, *types.TxData, error)
MockTx mock a tx
func ReplaceCoinbase ¶
ReplaceCoinbase replace the coinbase tx of block with coinbaseTx
func SignInstructionFor ¶
func SignInstructionFor(input *types.SpendInput, db dbm.DB, signer *signers.Signer) (*txbuilder.SigningInstruction, error)
SignInstructionFor read CtrlProgram from db, construct SignInstruction for SpendInput
Types ¶
type TxGenerator ¶
type TxGenerator struct { Builder *txbuilder.TemplateBuilder AccountManager *account.Manager Assets *asset.Registry Hsm *pseudohsm.HSM }
TxGenerator used to generate new tx
func NewTxGenerator ¶
func NewTxGenerator(accountManager *account.Manager, assets *asset.Registry, hsm *pseudohsm.HSM) *TxGenerator
NewTxGenerator create a TxGenerator
func (*TxGenerator) AddRetirement ¶
func (g *TxGenerator) AddRetirement(assetAlias string, amount uint64) error
AddRetirement add a retirement output
func (*TxGenerator) AddSpendInput ¶
func (g *TxGenerator) AddSpendInput(accountAlias, assetAlias string, amount uint64) error
AddSpendInput add a spend input
func (*TxGenerator) AddTxInput ¶
func (g *TxGenerator) AddTxInput(txInput *types.TxInput, signInstruction *txbuilder.SigningInstruction) error
AddTxInput add a tx input and signing instruction
func (*TxGenerator) AddTxInputFromUtxo ¶
func (g *TxGenerator) AddTxInputFromUtxo(utxo *account.UTXO, accountAlias string) error
AddTxInputFromUtxo add a tx input which spent the utxo
func (*TxGenerator) AddTxOutput ¶
func (g *TxGenerator) AddTxOutput(accountAlias, assetAlias string, amount uint64) error
AddTxOutput add a tx output
func (*TxGenerator) Reset ¶
func (g *TxGenerator) Reset()
Reset reset transaction builder, used to create a new tx