2020-05-17 20:30:16 +00:00
|
|
|
/*
|
|
|
|
Package blockchain provides functions to access various blockchain data.
|
|
|
|
*/
|
2018-08-21 10:57:48 +00:00
|
|
|
package blockchain
|
|
|
|
|
|
|
|
import (
|
2020-03-03 14:21:42 +00:00
|
|
|
"github.com/nspcc-dev/neo-go/pkg/interop/account"
|
|
|
|
"github.com/nspcc-dev/neo-go/pkg/interop/block"
|
|
|
|
"github.com/nspcc-dev/neo-go/pkg/interop/contract"
|
|
|
|
"github.com/nspcc-dev/neo-go/pkg/interop/header"
|
2018-08-21 10:57:48 +00:00
|
|
|
)
|
|
|
|
|
2020-06-08 15:36:19 +00:00
|
|
|
// Transaction represents a NEO transaction. It's similar to Transaction class
|
|
|
|
// in Neo .net framework.
|
|
|
|
type Transaction struct {
|
|
|
|
// Hash represents the hash (256 bit BE value in a 32 byte slice) of the
|
|
|
|
// given transaction (which also is its ID).
|
|
|
|
Hash []byte
|
|
|
|
// Version represents the transaction version.
|
|
|
|
Version int
|
|
|
|
// Nonce is a random number to avoid hash collision.
|
|
|
|
Nonce int
|
|
|
|
// Sender represents the sender (160 bit BE value in a 20 byte slice) of the
|
|
|
|
// given Transaction.
|
|
|
|
Sender []byte
|
|
|
|
// SysFee represents fee to be burned.
|
|
|
|
SysFee int
|
|
|
|
// NetFee represents fee to be distributed to consensus nodes.
|
|
|
|
NetFee int
|
|
|
|
// ValidUntilBlock is the maximum blockchain height exceeding which
|
|
|
|
// transaction should fail verification.
|
|
|
|
ValidUntilBlock int
|
|
|
|
// Script represents code to run in NeoVM for this transaction.
|
|
|
|
Script []byte
|
|
|
|
}
|
|
|
|
|
2020-05-17 20:30:16 +00:00
|
|
|
// GetHeight returns current block height (index of the last accepted block).
|
|
|
|
// Note that when transaction is being run as a part of new block this block is
|
|
|
|
// considered as not yet accepted (persisted) and thus you'll get an index of
|
|
|
|
// the previous (already accepted) block. This function uses
|
|
|
|
// `Neo.Blockchain.GetHeight` syscall.
|
2018-08-21 10:57:48 +00:00
|
|
|
func GetHeight() int {
|
|
|
|
return 0
|
|
|
|
}
|
|
|
|
|
2020-05-17 20:30:16 +00:00
|
|
|
// GetHeader returns header found by the given hash (256 bit hash in BE format
|
|
|
|
// represented as a slice of 32 bytes) or index (integer). Refer to the `header`
|
|
|
|
// package for possible uses of returned structure. This function uses
|
|
|
|
// `Neo.Blockchain.GetHeader` syscall.
|
2018-08-21 10:57:48 +00:00
|
|
|
func GetHeader(heightOrHash interface{}) header.Header {
|
|
|
|
return header.Header{}
|
|
|
|
}
|
|
|
|
|
2020-05-17 20:30:16 +00:00
|
|
|
// GetBlock returns block found by the given hash or index (with the same
|
|
|
|
// encoding as for GetHeader). Refer to the `block` package for possible uses
|
|
|
|
// of returned structure. This function uses `Neo.Blockchain.GetBlock` syscall.
|
2018-08-21 10:57:48 +00:00
|
|
|
func GetBlock(heightOrHash interface{}) block.Block {
|
|
|
|
return block.Block{}
|
|
|
|
}
|
|
|
|
|
2020-06-08 15:36:19 +00:00
|
|
|
// GetTransaction returns transaction found by the given hash (256 bit in BE
|
|
|
|
// format represented as a slice of 32 bytes). This function uses
|
|
|
|
// `System.Blockchain.GetTransaction` syscall.
|
|
|
|
func GetTransaction(hash []byte) Transaction {
|
|
|
|
return Transaction{}
|
2018-08-21 10:57:48 +00:00
|
|
|
}
|
|
|
|
|
2020-05-17 20:35:56 +00:00
|
|
|
// GetTransactionHeight returns transaction's height (index of the block that
|
|
|
|
// includes it) by the given ID (256 bit in BE format represented as a slice of
|
2020-06-08 15:40:01 +00:00
|
|
|
// 32 bytes). This function uses `System.Blockchain.GetTransactionHeight` syscall.
|
2020-05-17 20:35:56 +00:00
|
|
|
func GetTransactionHeight(hash []byte) int {
|
|
|
|
return 0
|
|
|
|
}
|
|
|
|
|
2020-05-17 20:30:16 +00:00
|
|
|
// GetContract returns contract found by the given script hash (160 bit in BE
|
|
|
|
// format represented as a slice of 20 bytes). Refer to the `contract` package
|
|
|
|
// for details on how to use the returned structure. This function uses
|
|
|
|
// `Neo.Blockchain.GetContract` syscall.
|
2018-08-21 10:57:48 +00:00
|
|
|
func GetContract(scriptHash []byte) contract.Contract {
|
|
|
|
return contract.Contract{}
|
|
|
|
}
|
|
|
|
|
2020-05-17 20:30:16 +00:00
|
|
|
// GetAccount returns account found by the given script hash (160 bit in BE
|
|
|
|
// format represented as a slice of 20 bytes). Refer to the `account` package
|
|
|
|
// for details on how to use the returned structure. This function uses
|
|
|
|
// `Neo.Blockchain.GetAccount` syscall.
|
2018-08-21 10:57:48 +00:00
|
|
|
func GetAccount(scriptHash []byte) account.Account {
|
|
|
|
return account.Account{}
|
|
|
|
}
|
|
|
|
|
2020-05-17 20:30:16 +00:00
|
|
|
// GetValidators returns a slice of current validators public keys represented
|
|
|
|
// as a compressed serialized byte slice (33 bytes long). This function uses
|
|
|
|
// `Neo.Blockchain.GetValidators` syscall.
|
2018-08-21 10:57:48 +00:00
|
|
|
func GetValidators() [][]byte {
|
|
|
|
return nil
|
|
|
|
}
|