tx

package
v0.0.1 Latest Latest
Warning

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

Go to latest
Published: Sep 7, 2020 License: BSD-3-Clause Imports: 18 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	// ErrNotStateBased is returned when the transaction is not state based
	ErrNotStateBased = errors.New("not state based")

	// ErrNotUTXO is returned when the transaction is not utxo
	ErrNotUTXO = errors.New("not UTXO")
)

Functions

This section is empty.

Types

type NewTxFunc

type NewTxFunc = func() (Tx, error)

NewTxFunc represents a new transaction function

type Serializer

type Serializer interface {
	// Serialize serializes the transaction
	Serialize() ([]byte, error)
	// SerializedSize returns the size of the serialized transaction
	SerializedSize() uint64
}

Serializer represents a serializable object

type Tx

type Tx interface {
	Serializer

	// Copy returns a copy of the transaction
	Copy() Tx

	// Crypto returns the transaction crypto
	Crypto() *cryptos.Crypto

	// TxUTXO returns a TxUTXO transaction
	TxUTXO() (TxUTXO, bool)
	// TxStateBased returns a TxStateBased transaction
	TxStateBased() (TxStateBased, bool)
}

func New

func New(c *cryptos.Crypto) (Tx, error)

New returns a new transaction for the given crypto

func NewBCH

func NewBCH() (Tx, error)

NewBCH creates a new transaction for bitcoin-cash

func NewBTC

func NewBTC() (Tx, error)

NewBTC creates a new transaction for bitcoin

func NewDCR

func NewDCR() (Tx, error)

NewDCR creates a new transaction for decred

func NewDOGE

func NewDOGE() (Tx, error)

NewDOGE creates a new transaction for dogecoin

func NewLTC

func NewLTC() (Tx, error)

NewLTC creates a new transaction for litecoin

type TxStateBased

type TxStateBased interface{}

TxStateBased represents a state based transaction

type TxUTXO

type TxUTXO interface {
	// AddOutput adds an output to the transaction
	AddOutput(value uint64, script []byte)
	// AddInput adds an input to the transaction
	AddInput(txID []byte, idx uint32, script []byte, amount uint64) error
	// InputSignature returns the signature for an existing input
	InputSignature(idx int, hashType uint32, privKey key.Private) ([]byte, error)
	// SetInputSequenceNumber sets the sequence number for a given input
	SetInputSequenceNumber(idx int, seq uint32)
	// InputSequenceNumber returns the sequence number of a given input
	InputSequenceNumber(idx int) uint32
	// SetLockTimeUInt32 sets the locktime
	SetLockTimeUInt32(lt uint32)
	// SetLockTime sets the locktime
	SetLockTime(lt time.Time)
	// SetLockDuration sets the locktime as a duration (counting from time.Now().UTC())
	SetLockDuration(d time.Duration)
	// InputSignatureScript returns the signatureScript field of an input
	InputSignatureScript(idx int) []byte
	// SetInputSignatureScript sets the signatureScript field of an input
	SetInputSignatureScript(idx int, ss []byte)
	// SignP2PKInput signs an p2pk input
	SignP2PKInput(idx int, hashType uint32, privKey key.Private) error
	// SignP2PKHInput signs a p2pkh input
	SignP2PKHInput(idx int, hashType uint32, privKey key.Private) error
}

TxUTXO represents a utxo transaction

Jump to

Keyboard shortcuts

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