cross

package
v2.1.0+incompatible Latest Latest
Warning

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

Go to latest
Published: Feb 2, 2020 License: ISC Imports: 17 Imported by: 6

Documentation

Index

Constants

View Source
const (
	// Entangle Transcation type
	ExpandedTxEntangle_Doge = 0xF0
	ExpandedTxEntangle_Ltc  = 0xF1
)

Variables

View Source
var (
	ErrInvalidMsgLen       = errors.New("invalid message length, need 32 bytes")
	ErrInvalidSignatureLen = errors.New("invalid signature length")
	ErrInvalidRecoveryID   = errors.New("invalid signature recovery id")
	ErrInvalidKey          = errors.New("invalid private key")
	ErrInvalidPubkey       = errors.New("invalid public key")
	ErrSignFailed          = errors.New("signing failed")
	ErrRecoverFailed       = errors.New("recovery failed")
	ErrCryptoType          = errors.New("invalid crypto type")
)
View Source
var (
	BucketKey = []byte("entangle-tx")
)
View Source
var (
	ErrHeightTooClose = errors.New("the block heigth to close for entangling")
)
View Source
var (
	NoEntangle = errors.New("no entangle info in transcation")
)

Functions

func CheckTransactionisBlock

func CheckTransactionisBlock(txhash string, block *rpcclient.DogecoinMsgBlock) bool

func EnoughAmount

func EnoughAmount(reserve int64, items []*EntangleItem, keepInfo *KeepedAmount) bool

func GetMaxHeight

func GetMaxHeight(items map[uint32]*EntangleTxInfo) uint64

func IsEntangleTx

func IsEntangleTx(tx *wire.MsgTx) (map[uint32]*EntangleTxInfo, error)

func MakeAddress

func MakeAddress(puk ecdsa.PublicKey) (error, czzutil.Address)

func MakeEntangleTx

func MakeEntangleTx(params *chaincfg.Params, inputs []*wire.TxIn, feeRate, inAmount czzutil.Amount,
	changeAddr czzutil.Address, info *EntangleTxInfo) (*wire.MsgTx, error)

func MakeMergeCoinbaseTx

func MakeMergeCoinbaseTx(tx *wire.MsgTx, pool *PoolAddrItem, items []*EntangleItem, lastScriptInfo []byte) error

MakeMegerTx

tx (coinbase tx):
	in:
	1 empty hash of coinbase txin
	2 pooladdr1 of txin
	3 pooladdr2 of txin
	out:
		1. coinbase txout
		2. pooladdr1 txout
		3. pooladdr2 txout
		   '''''''''''''''
			entangle txout1
					.
					.
					.
			entangle txoutn
		   '''''''''''''''

func OverEntangleAmount

func OverEntangleAmount(tx *wire.MsgTx, pool *PoolAddrItem, items []*EntangleItem, lastScriptInfo []byte) bool

func PreCalcEntangleAmount

func PreCalcEntangleAmount(item *EntangleItem, keepInfo *KeepedAmount)

func RecoverPublicFromBytes

func RecoverPublicFromBytes(pub []byte, t ExpandedTxType) (*ecdsa.PublicKey, error)

RecoverPublic returns the public key of the marshal bytes.

func SignEntangleTx

func SignEntangleTx(tx *wire.MsgTx, inputAmount []czzutil.Amount,
	priv *czzec.PrivateKey) error

func UnmarshalPubkey1

func UnmarshalPubkey1(pub []byte) (*ecdsa.PublicKey, error)

UnmarshalPubkey converts bytes to a secp256k1 public key.

func VerifyTxsSequence

func VerifyTxsSequence(infos []*EtsInfo) error

Types

type CacheEntangleInfo

type CacheEntangleInfo struct {
	DB database.DB
}

func (*CacheEntangleInfo) FetchEntangleUtxoView

func (c *CacheEntangleInfo) FetchEntangleUtxoView(info *EntangleTxInfo) bool

type EntangleItem

type EntangleItem struct {
	EType ExpandedTxType
	Value *big.Int
	Addr  czzutil.Address
}

func ToEntangleItems

func ToEntangleItems(txs []*czzutil.Tx, addrs map[chainhash.Hash][]*TmpAddressPair) []*EntangleItem

func (*EntangleItem) Clone

func (ii *EntangleItem) Clone() *EntangleItem

type EntangleTxInfo

type EntangleTxInfo struct {
	ExTxType  ExpandedTxType
	Index     uint32
	Height    uint64
	Amount    *big.Int
	ExtTxHash []byte
}

func EntangleTxFromScript

func EntangleTxFromScript(script []byte) (*EntangleTxInfo, error)

func (*EntangleTxInfo) Parse

func (info *EntangleTxInfo) Parse(data []byte) error

func (*EntangleTxInfo) Serialize

func (info *EntangleTxInfo) Serialize() []byte

type EntangleVerify

type EntangleVerify struct {
	DogeCoinRPC []*rpcclient.Client
	LtcCoinRPC  []*rpcclient.Client
	Cache       *CacheEntangleInfo
}

func (*EntangleVerify) VerifyEntangleTx

func (ev *EntangleVerify) VerifyEntangleTx(tx *wire.MsgTx) ([]*TuplePubIndex, error)

type EtsInfo

type EtsInfo struct {
	FeePerKB int64
	Tx       *wire.MsgTx
}

entangle tx Sequence infomation

type ExpandedTxType

type ExpandedTxType uint8

type KeepedAmount

type KeepedAmount struct {
	Count byte
	Items []KeepedItem
}

func KeepedAmountFromScript

func KeepedAmountFromScript(script []byte) (*KeepedAmount, error)

func (*KeepedAmount) Add

func (info *KeepedAmount) Add(item KeepedItem)

func (*KeepedAmount) GetValue

func (info *KeepedAmount) GetValue(t ExpandedTxType) *big.Int

func (*KeepedAmount) Parse

func (info *KeepedAmount) Parse(data []byte) error

func (*KeepedAmount) Serialize

func (info *KeepedAmount) Serialize() []byte

type KeepedItem

type KeepedItem struct {
	ExTxType ExpandedTxType
	Amount   *big.Int
}

type PoolAddrItem

type PoolAddrItem struct {
	POut   []wire.OutPoint
	Script [][]byte
	Amount []*big.Int
}

type TmpAddressPair

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

the tool function for entangle tx

func ToAddressFromEntangle

func ToAddressFromEntangle(tx *czzutil.Tx, ev *EntangleVerify) ([]*TmpAddressPair, error)

type TuplePubIndex

type TuplePubIndex struct {
	EType ExpandedTxType
	Index uint32
	Pub   []byte
}

Jump to

Keyboard shortcuts

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