tx

package
v0.0.0-...-bcfd2cf Latest Latest
Warning

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

Go to latest
Published: Mar 10, 2023 License: GPL-3.0 Imports: 12 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ErrTxNotFound = fmt.Errorf("tx %w", errorx.ErrKeyNotFound)

ErrTxNotFound wraps the key not found error in a transaction not found

Functions

func IsID

func IsID(text string) bool

IsID returns true is the string is a block hash

func NewService

func NewService(k kv.DB, c *cache.Cache) *service

NewService instantiates a new Service layer for customer

func Routes

func Routes(g *echo.Group, s Service)

Routes mounts all /tx based routes on the main group

Types

type Input

type Input struct {
	TxID                  string   `json:"txid,omitempty"`
	Vout                  uint32   `json:"vout"`
	IsCoinbase            bool     `json:"is_coinbase"`
	Scriptsig             string   `json:"scriptsig"`
	ScriptsigAsm          string   `json:"scriptsig_asm"`
	InnerRedeemscriptAsm  string   `json:"inner_redeemscript_asm"`
	InnerWitnessscriptAsm string   `json:"inner_witnessscript_asm"`
	Sequence              uint32   `json:"sequence"`
	Witness               []string `json:"witness"`
	Prevout               uint32   `json:"prevout"`
}

Input model part of Tx

type Output

type Output struct {
	Scriptpubkey        string `json:"scriptpubkey"`
	ScriptpubkeyAsm     string `json:"scriptpubkey_asm"`
	ScriptpubkeyType    string `json:"scriptpubkey_type"`
	ScriptpubkeyAddress string `json:"scriptpubkey_address"`
	Value               int64  `json:"value"`
	Index               uint32 `json:"index"` // this shoudln't be here, useful for dgraph

}

Output model part of Tx

type Service

type Service interface {
	GetFromHash(hash string) (transaction Tx, err error)
	GetOutputsFromHash(hash string) (outputs []Output, err error)
	GetSpentOutputFromHash(hash string, vout uint32) (output Output, err error)
	GetSpendingFromHash(hash string, vout uint32) (transaction Tx, err error)
	IsSpent(tx string, index uint32) bool
}

Service interface exports available methods for tx service

type Status

type Status struct {
	Confirmed   bool      `json:"confirmed"`
	BlockHeight int32     `json:"block_height"`
	BlockHash   string    `json:"block_hash"`
	BlockTime   time.Time `json:"block_time"`
}

Status model part of Tx

type Tx

type Tx struct {
	TxID     string   `json:"txid,omitempty"`
	Version  int32    `json:"version"`
	Locktime uint32   `json:"locktime"`
	Size     float32  `json:"size"`
	Weight   float32  `json:"weight"`
	Fee      float32  `json:"fee"`
	Vin      []Input  `json:"input,omitempty"`
	Vout     []Output `json:"output,omitempty"`
	Status   []Status `json:"status,omitempty"` // I don't get why this should be an array, dgraph set it to array by default
}

Tx model defined by standard

Jump to

Keyboard shortcuts

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