txmodels

package
v1.6.1 Latest Latest
Warning

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

Go to latest
Published: Mar 10, 2021 License: ISC Imports: 8 Imported by: 3

Documentation

Overview

Copyright (c) 2020 The JaxNetwork developers Use of this source code is governed by an ISC license that can be found in the LICENSE file.

Copyright (c) 2020 The JaxNetwork developers Use of this source code is governed by an ISC license that can be found in the LICENSE file.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func GetPayToAddressScript added in v0.1.6

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

SetPayToAddress creates regular pay-to-address script.

destAddress is hex-encoded btcutil.Address

Types

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 *btcutil.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 btcutil.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 btcutil.Address

type IndexKey added in v0.1.6

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(btcutil.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 added in v0.1.6

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

func (*SwapTransaction) UnmarshalBinary added in v0.1.6

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) 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 added in v0.1.6

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 added in v0.1.6

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

func (*UTXOIndex) LastBlock added in v0.1.6

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

func (*UTXOIndex) MarkUsed

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

func (*UTXOIndex) MarshalBinary added in v0.1.6

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

func (*UTXOIndex) ResetUsedFlag added in v0.1.6

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 added in v0.1.6

func (index *UTXOIndex) RowsCopy() UTXORows

func (*UTXOIndex) UnmarshalBinary added in v0.1.6

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

type UTXORows

type UTXORows []UTXO

func (UTXORows) CollectForAmount

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

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) Swap

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

Jump to

Keyboard shortcuts

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