txmodels

package
v0.4.11 Latest Latest
Warning

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

Go to latest
Published: Sep 11, 2023 License: ISC Imports: 17 Imported by: 2

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func GetPayToAddressScript

func GetPayToAddressScript(destAddress string, params *chaincfg.Params) ([]byte, error)

GetPayToAddressScript creates regular pay-to-address script.

destAddress is hex-encoded jaxutil.Address

Types

type CSVStorage

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

func NewCSVStorage

func NewCSVStorage(path string) *CSVStorage

func (*CSVStorage) Close

func (storage *CSVStorage) Close()

func (*CSVStorage) FetchData

func (storage *CSVStorage) FetchData() (UTXORows, error)

func (*CSVStorage) SaveRows

func (storage *CSVStorage) SaveRows(rows []UTXO) error

type DraftTx

type DraftTx struct {
	Amount         int64
	NetworkFee     int64
	UTXO           UTXORows
	ReceiverScript []byte
	DestAddress    string
}

func (DraftTx) Destination

func (tx DraftTx) Destination() string

func (*DraftTx) SetMultiSig2of2

func (tx *DraftTx) SetMultiSig2of2(firstPubKey, secondPubKey *jaxutil.AddressPubKey, params *chaincfg.Params) error

SetMultiSig2of2 creates multiSig script, what can be spent only whist 2 of 2 signatures.

firstPubKey and secondPubKey is hex-encoded jaxutil.AddressPubKey, NOT an address.

func (*DraftTx) SetPayToAddress

func (tx *DraftTx) SetPayToAddress(destAddress string, params *chaincfg.Params) error

SetPayToAddress creates regular pay-to-address script.

destAddress is hex-encoded jaxutil.Address

type EADUTXOs added in v0.3.10

type EADUTXOs []UTXO

func (EADUTXOs) Append added in v0.3.10

func (rows EADUTXOs) Append(new ...UTXO) UTXOs

nolint: predeclared

func (EADUTXOs) CollectForAmount added in v0.3.10

func (rows EADUTXOs) CollectForAmount(amount int64, shardID uint32) (UTXOs, int64)

func (EADUTXOs) GetSingle added in v0.3.10

func (rows EADUTXOs) GetSingle(amount int64, shardID uint32) *UTXO

func (EADUTXOs) GetSum added in v0.3.10

func (rows EADUTXOs) GetSum() int64

func (EADUTXOs) Len added in v0.3.10

func (rows EADUTXOs) Len() int

func (EADUTXOs) Less added in v0.3.10

func (rows EADUTXOs) Less(i, j int) bool

func (EADUTXOs) List added in v0.3.10

func (rows EADUTXOs) List() []UTXO

func (EADUTXOs) Swap added in v0.3.10

func (rows EADUTXOs) Swap(i, j int)

type IndexKey

type IndexKey struct {
	Shard uint32
	Hash  string
}

type ShortUTXO

type ShortUTXO struct {
	Value        int64  `json:"value" csv:"value"`
	PKScript     string `json:"pk_script" csv:"pk_script"`
	RedeemScript string `json:"redeem_script" csv:"redeem_script" `
}

func (*ShortUTXO) GetScript

func (utxo *ShortUTXO) GetScript(jaxutil.Address) ([]byte, error)

type SwapTransaction

type SwapTransaction struct {
	TxHash       string         `json:"tx_hash" csv:"tx_hash"`
	Source       string         `json:"source" csv:"source"`
	Destinations map[string]int `json:"destinations" csv:"destinations"`
	SignedTx     string         `json:"signed_tx" csv:"signed_tx"`

	RawTX *wire.MsgTx `json:"-" csv:"-"`
}

func (SwapTransaction) MarshalBinary

func (t SwapTransaction) MarshalBinary() ([]byte, error)

func (*SwapTransaction) UnmarshalBinary

func (t *SwapTransaction) UnmarshalBinary(data []byte) error

type Transaction

type Transaction struct {
	TxHash      string `json:"tx_hash" csv:"tx_hash"`
	Source      string `json:"source" csv:"source"`
	Destination string `json:"destination" csv:"destination"`
	Amount      int64  `json:"amount" csv:"amount"`
	ShardID     uint32 `json:"shard_id" csv:"shard_id"`
	SignedTx    string `json:"signed_tx" csv:"signed_tx"`

	RawTX *wire.MsgTx `json:"-" csv:"-"`
}

func (Transaction) MarshalBinary

func (t Transaction) MarshalBinary() ([]byte, error)

func (*Transaction) UnmarshalBinary

func (t *Transaction) UnmarshalBinary(data []byte) error

type UTXO

type UTXO struct {
	ShardID    uint32 `json:"shard_id" csv:"shard_id"`
	Address    string `json:"address" csv:"address"`
	Height     int64  `json:"height" csv:"height"`
	TxHash     string `json:"tx_hash" csv:"tx_hash"`
	OutIndex   uint32 `json:"out_index" csv:"out_index"`
	Value      int64  `json:"value" csv:"value"`
	Used       bool   `json:"used" csv:"used"`
	PKScript   string `json:"pk_script" csv:"pk_script"`
	ScriptType string `json:"script_type" csv:"script_type"`
}

func (*UTXO) CanBeSpend

func (utxo *UTXO) CanBeSpend(shardID uint32) bool

func (*UTXO) ToShort

func (utxo *UTXO) ToShort() ShortUTXO

type UTXOIndex

type UTXOIndex struct {
	sync.RWMutex
	// contains filtered or unexported fields
}

UTXOIndex is a storage for UTXO data.

func NewUTXOIndex

func NewUTXOIndex() *UTXOIndex

func (*UTXOIndex) AddUTXO

func (index *UTXOIndex) AddUTXO(utxo UTXO)

func (*UTXOIndex) CollectForAmount

func (index *UTXOIndex) CollectForAmount(amount int64, shardID uint32) (UTXORows, int64)

CollectForAmount aggregates UTXOs to meet the requested amount. All selected UTXOs will be marked as USED.

func (*UTXOIndex) CollectForAmountFiltered

func (index *UTXOIndex) CollectForAmountFiltered(amount int64, shardID uint32,
	filter map[string]struct{}) (UTXORows, int64)

func (*UTXOIndex) GetForAmountFiltered

func (index *UTXOIndex) GetForAmountFiltered(amount int64, shardID uint32,
	filter map[string]struct{}) *UTXO

func (*UTXOIndex) LastBlock

func (index *UTXOIndex) LastBlock(shardID uint32) int64

func (*UTXOIndex) MarkUsed

func (index *UTXOIndex) MarkUsed(txHash string, utxoIndexID, shardID uint32)

func (*UTXOIndex) MarshalBinary

func (index *UTXOIndex) MarshalBinary() (data []byte, err error)

func (*UTXOIndex) ResetUsedFlag

func (index *UTXOIndex) ResetUsedFlag()

func (*UTXOIndex) RmUTXO

func (index *UTXOIndex) RmUTXO(txHash string, utxoIndexID, shardID uint32)

func (*UTXOIndex) Rows

func (index *UTXOIndex) Rows() UTXORows

func (*UTXOIndex) RowsCopy

func (index *UTXOIndex) RowsCopy() UTXORows

func (*UTXOIndex) UnmarshalBinary

func (index *UTXOIndex) UnmarshalBinary(data []byte) error

type UTXORepo

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

func NewUTXORepo

func NewUTXORepo(dataDir string, additionalKeys ...string) UTXORepo

func (*UTXORepo) Balance

func (collector *UTXORepo) Balance(shardID uint32, addresses ...string) (int64, error)

func (*UTXORepo) CollectFromRPC

func (collector *UTXORepo) CollectFromRPC(rpcClient *rpcclient.Client, shardID uint32, filter map[string]bool) error

func (*UTXORepo) GetForAmount

func (collector *UTXORepo) GetForAmount(amount int64, shardID uint32, addresses ...string) (*UTXO, error)

func (*UTXORepo) Index

func (collector *UTXORepo) Index() *UTXOIndex

func (*UTXORepo) ListUTXOs

func (collector *UTXORepo) ListUTXOs(skip, take int64, flags map[string]string) (int64, UTXORows, error)

func (*UTXORepo) ReadIndex

func (collector *UTXORepo) ReadIndex() error

func (*UTXORepo) RedeemScript

func (collector *UTXORepo) RedeemScript(address string) (script string)

func (*UTXORepo) ResetUsedFlag

func (collector *UTXORepo) ResetUsedFlag()

func (*UTXORepo) SaveIndex

func (collector *UTXORepo) SaveIndex() error

func (*UTXORepo) SelectForAmount

func (collector *UTXORepo) SelectForAmount(amount int64, shardID uint32, addresses ...string) (UTXORows, error)

func (*UTXORepo) SetIndex

func (collector *UTXORepo) SetIndex(index *UTXOIndex)

type UTXORows

type UTXORows []UTXO

func (UTXORows) Append added in v0.3.10

func (rows UTXORows) Append(new ...UTXO) UTXOs

nolint: predeclared

func (UTXORows) CollectForAmount

func (rows UTXORows) CollectForAmount(amount int64, shardID uint32) (UTXOs, int64)

func (UTXORows) GetSingle

func (rows UTXORows) GetSingle(amount int64, shardID uint32) *UTXO

func (UTXORows) GetSum

func (rows UTXORows) GetSum() int64

func (UTXORows) Len

func (rows UTXORows) Len() int

func (UTXORows) Less

func (rows UTXORows) Less(i, j int) bool

func (UTXORows) List added in v0.3.10

func (rows UTXORows) List() []UTXO

func (UTXORows) Swap

func (rows UTXORows) Swap(i, j int)

type UTXOs added in v0.3.10

type UTXOs interface {
	sort.Interface
	GetSum() int64
	CollectForAmount(amount int64, shardID uint32) (UTXOs, int64)
	GetSingle(amount int64, shardID uint32) *UTXO
	List() []UTXO
	Append(...UTXO) UTXOs
}

Jump to

Keyboard shortcuts

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