Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Input ¶
type Input struct { // TransactionID points to a particular TX TransactionID []byte // OutIndex points to a particular output in the TX OutIndex int64 // Sign is calculated with Signer Sign []byte // PubKey represents a public key of a sender PubKey []byte }
Input represents an input
type Output ¶
type Output struct { // Value has amount of coins Value int64 // Address represents a PKH (public key hash) of a destination Address []byte }
Output represents an output
type Signer ¶
type Signer interface {
Sign(*Transaction, *btcec.PrivateKey) error
}
Signer represents a signer interface
type Storage ¶
type Storage interface { // FindTransactionByID finds a tx by given ID FindTransactionByID(TxID []byte) ([]byte, Transaction, error) // FindUTXOByPKH finds a set of UTXO by a given public key hash ( address ) FindUTXOByPKH(context.Context, btcutil.AddressPubKeyHash) (UTXOSet, error) // TotalUTXOByPKH returns a sum of UTXO by a given public key hash ( address ) TotalUTXOByPKH(context.Context, btcutil.AddressPubKeyHash) (int64, error) }
Storage represents a storage for transactions A storage for transaction might differ from blockchain storage
type Transaction ¶
type Transaction struct { // ID calculated with Hash method ID []byte // Inputs has a set of Input Inputs []Input // Outputs has a set of Output Outputs []Output }
Transaction represents a TX
func New ¶
func New(us UTXOSet, from, to btcutil.AddressPubKeyHash, a amount.Amount) (Transaction, error)
New creates a TX
func NewCoinBase ¶
func NewCoinBase(to btcutil.AddressPubKeyHash, reward amount.Amount) (Transaction, error)
NewCoinBase creates new coinbase TX with given reward
func (Transaction) Hash ¶
func (tx Transaction) Hash() ([]byte, error)
Hash returns SHA256(SHA256(TX))
func (Transaction) Serialize ¶
func (tx Transaction) Serialize() ([]byte, error)
Serialize serializes TX This is not the best way to serialize TX.
type UTXO ¶
UTXO represents an unspent transaction output https://bitcoin.org/en/glossary/unspent-transaction-output
type UTXOSet ¶
type UTXOSet []UTXO
UTXOSet represents a set of UTXOs
func NewUTXOSetFromTX ¶
func NewUTXOSetFromTX(tx Transaction) UTXOSet
NewUTXOSetFromTX create UTXOSet from a TX It used in tests only
type Verifier ¶
type Verifier interface {
Verify(*Transaction) error
}
Verifier represents a simpleSigner TX verifier
func NewSimpleVerifier ¶
NewSimpleVerifier return a new Verifier