dcrharness

package module
v0.0.0-...-202b68f Latest Latest
Warning

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

Go to latest
Published: Mar 27, 2020 License: ISC Imports: 21 Imported by: 0

README

Decred harness

ISC License

  • memwallet Offers a simple in-memory HD wallet capable of properly syncing to the generated chain, creating new addresses, and crafting fully signed transactions paying to an arbitrary set of outputs.

  • nodecls Provides wrapper that launches a new dcrd-instance using command-line call.

Build

set GO111MODULE=on
go build ./...
go clean -testcache
go test ./...

License

This code is licensed under the copyfree ISC License.

Documentation

Index

Constants

View Source
const TxTreeRegular int8 = 0

TxTreeRegular is the value for a normal transaction tree for a transaction's location in a block.

Variables

This section is empty.

Functions

func CreateBlock

func CreateBlock(prevBlock *dcrutil.Block, inclusionTxs []*dcrutil.Tx,
	blockVersion int32, blockTime time.Time, miningAddr dcrutil.Address,
	mineTo []wire.TxOut, net *chaincfg.Params) (*dcrutil.Block, error)

CreateBlock creates a new block building from the previous block with a specified blockversion and timestamp. If the timestamp passed is zero (not initialized), then the timestamp of the previous block will be used plus 1 second is used. Passing nil for the previous block results in a block that builds off of the genesis block for the specified chain.

func GenerateAndSubmitBlock

func GenerateAndSubmitBlock(client coinharness.RPCClient, args *GenerateBlockArgs) (*dcrutil.Block, error)

GenerateAndSubmitBlock creates a block whose contents include the passed transactions and submits it to the running simnet node. For generating blocks with only a coinbase tx, callers can simply pass nil instead of transactions to be mined. Additionally, a custom block version can be set by the caller. An uninitialized time.Time should be used for the blockTime parameter if one doesn't wish to set a custom time.

func GenerateAndSubmitBlockWithCustomCoinbaseOutputs

func GenerateAndSubmitBlockWithCustomCoinbaseOutputs(client coinharness.RPCClient, args *GenerateBlockArgs) (*dcrutil.Block, error)

GenerateAndSubmitBlockWithCustomCoinbaseOutputs creates a block whose contents include the passed coinbase outputs and transactions and submits it to the running simnet node. For generating blocks with only a coinbase tx, callers can simply pass nil instead of transactions to be mined. Additionally, a custom block version can be set by the caller. A blockVersion of -1 indicates that the current default block version should be used. An uninitialized time.Time should be used for the blockTime parameter if one doesn't wish to set a custom time. The mineTo list of outputs will be added to the coinbase; this is not checked for correctness until the block is submitted; thus, it is the caller's responsibility to ensure that the outputs are correct. If the list is empty, the coinbase reward goes to the wallet managed by the Harness.

func IsCoinBaseTx

func IsCoinBaseTx(tx *coinharness.MessageTx) bool

func NetworkFor

func NetworkFor(net coinharness.Network) string

networkFor resolves network argument for node and wallet console commands

func NewTestSeed

func NewTestSeed(salt uint32) coinharness.Seed

NewTestSeed generates new test wallet seed using predefined array hdSeed and a custom salt number The wallet's final HD seed is: [hdSeed || salt]. This method ensures that each harness instance uses a deterministic root seed based on its salt.

func NewTxFromBytes

func NewTxFromBytes(txBytes []byte) (*coinharness.Tx, error)

func PayToAddrScript

func PayToAddrScript(addr coinharness.Address) ([]byte, error)

func PrivateKeyKeyToAddr

func PrivateKeyKeyToAddr(key coinharness.PrivateKey, net coinharness.Network) (coinharness.Address, error)

PrivateKeyKeyToAddr maps the passed private to corresponding p2pkh address.

func ReadBlockHeader

func ReadBlockHeader(header []byte) coinharness.BlockHeader

func TransactionRawToTx

func TransactionRawToTx(wireTx *wire.MsgTx) *coinharness.MessageTx

func TransactionTxToRaw

func TransactionTxToRaw(chTx *coinharness.MessageTx) *wire.MsgTx

func TxSerializeSize

func TxSerializeSize(msg *coinharness.MessageTx) int

Types

type Address

type Address struct {
	Address dcrutil.Address
}

func (*Address) Internal

func (c *Address) Internal() interface{}

func (*Address) IsForNet

func (c *Address) IsForNet(net coinharness.Network) bool

func (*Address) ScriptAddress

func (c *Address) ScriptAddress() []byte

func (*Address) String

func (c *Address) String() string

type BlockHeader

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

func (*BlockHeader) Height

func (h *BlockHeader) Height() int64

type ConsoleCommandCook

type ConsoleCommandCook struct {
}

func (*ConsoleCommandCook) CookArguments

func (cook *ConsoleCommandCook) CookArguments(par *coinharness.ConsoleCommandNodeParams) map[string]interface{}

cookArguments prepares arguments for the command-line call

type ConsoleNodeFactory

type ConsoleNodeFactory struct {
	// NodeExecutablePathProvider returns path to the dcrd executable
	NodeExecutablePathProvider commandline.ExecutablePathProvider
	ConsoleCommandCook         ConsoleCommandCook
	RPCClientFactory           RPCClientFactory
}

ConsoleNodeFactory produces a new ConsoleNode-instance upon request

func (*ConsoleNodeFactory) NewNode

func (factory *ConsoleNodeFactory) NewNode(config *coinharness.TestNodeConfig) coinharness.Node

NewNode creates and returns a fully initialized instance of the ConsoleNode.

type ConsoleWalletFactory

type ConsoleWalletFactory struct {
	// WalletExecutablePathProvider returns path to the btcd executable
	WalletExecutablePathProvider commandline.ExecutablePathProvider
	ConsoleCommandCook           WalletConsoleCommandCook
	RPCClientFactory             RPCClientFactory
}

ConsoleWalletFactory produces a new ConsoleWallet-instance upon request

func (*ConsoleWalletFactory) NewWallet

NewWallet creates and returns a fully initialized instance of the ConsoleWallet.

type ExtendedKey

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

func (*ExtendedKey) Child

func (*ExtendedKey) PrivateKey

func (k *ExtendedKey) PrivateKey() (coinharness.PrivateKey, error)

type GenerateBlockArgs

type GenerateBlockArgs struct {
	Txns          []*dcrutil.Tx
	BlockVersion  int32
	BlockTime     time.Time
	MineTo        []wire.TxOut
	MiningAddress dcrutil.Address
	Network       *chaincfg.Params
}

GenerateBlockArgs bundles GenerateBlock() arguments to minimize diff in case a new argument for the function is added

type InMemoryWalletFactory

type InMemoryWalletFactory struct {
}

InMemoryWalletFactory produces a new InMemoryWallet-instance upon request

func (*InMemoryWalletFactory) NewWallet

NewWallet creates and returns a fully initialized instance of the InMemoryWallet.

type Network

type Network struct {
	Net *chaincfg.Params
}

func (*Network) CoinbaseMaturity

func (n *Network) CoinbaseMaturity() int64

func (*Network) Params

func (n *Network) Params() interface{}

type PrivateKey

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

func (*PrivateKey) PublicKey

func (k *PrivateKey) PublicKey() coinharness.PublicKey

type PublicKey

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

type RPCClient

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

func (*RPCClient) AddNode

func (c *RPCClient) AddNode(args *coinharness.AddNodeArguments) error

func (*RPCClient) CreateNewAccount

func (c *RPCClient) CreateNewAccount(account string) error

func (*RPCClient) Disconnect

func (c *RPCClient) Disconnect()

func (*RPCClient) Generate

func (c *RPCClient) Generate(blocks uint32) (result []coinharness.Hash, e error)

func (*RPCClient) GetBalance

func (c *RPCClient) GetBalance() (*coinharness.GetBalanceResult, error)

func (*RPCClient) GetBestBlock

func (c *RPCClient) GetBestBlock() (coinharness.Hash, int64, error)

func (*RPCClient) GetBlock

func (c *RPCClient) GetBlock(hash coinharness.Hash) (*coinharness.MsgBlock, error)

func (*RPCClient) GetBlockCount

func (c *RPCClient) GetBlockCount() (int64, error)

func (*RPCClient) GetBuildVersion

func (c *RPCClient) GetBuildVersion() (coinharness.BuildVersion, error)

func (*RPCClient) GetNewAddress

func (c *RPCClient) GetNewAddress(account string) (coinharness.Address, error)

func (*RPCClient) GetPeerInfo

func (c *RPCClient) GetPeerInfo() ([]coinharness.PeerInfo, error)

func (*RPCClient) GetRawMempool

func (c *RPCClient) GetRawMempool(command interface{}) (result []coinharness.Hash, e error)

func (*RPCClient) Internal

func (c *RPCClient) Internal() interface{}

func (*RPCClient) ListAccounts

func (c *RPCClient) ListAccounts() (map[string]coin.Amount, error)

func (*RPCClient) ListUnspent

func (c *RPCClient) ListUnspent() ([]*coinharness.Unspent, error)

func (*RPCClient) LoadTxFilter

func (c *RPCClient) LoadTxFilter(reload bool, addr []coinharness.Address) error

func (*RPCClient) NotifyBlocks

func (c *RPCClient) NotifyBlocks() error

func (*RPCClient) SendRawTransaction

func (c *RPCClient) SendRawTransaction(tx *coinharness.MessageTx, allowHighFees bool) (result coinharness.Hash, e error)

func (*RPCClient) Shutdown

func (c *RPCClient) Shutdown()

func (*RPCClient) SubmitBlock

func (c *RPCClient) SubmitBlock(block coinharness.Block) error

func (*RPCClient) ValidateAddress

func (c *RPCClient) ValidateAddress(address coinharness.Address) (*coinharness.ValidateAddressResult, error)

func (*RPCClient) WalletInfo

func (c *RPCClient) WalletInfo() (*coinharness.WalletInfoResult, error)

func (*RPCClient) WalletLock

func (c *RPCClient) WalletLock() error

func (*RPCClient) WalletUnlock

func (c *RPCClient) WalletUnlock(passphrase string, timeoutSecs int64) error

type RPCClientFactory

type RPCClientFactory struct {
}

func (*RPCClientFactory) NewRPCConnection

type WalletConsoleCommandCook

type WalletConsoleCommandCook struct {
}

func (*WalletConsoleCommandCook) CookArguments

func (cook *WalletConsoleCommandCook) CookArguments(par *coinharness.ConsoleCommandWalletParams) map[string]interface{}

cookArguments prepares arguments for the command-line call

Jump to

Keyboard shortcuts

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