Documentation ¶
Index ¶
- Constants
- Variables
- func CheckTransactionisBlock(txhash string, block *rpcclient.DogecoinMsgBlock) bool
- func ComputeDiff(params *chaincfg.Params, target *big.Int, address czzutil.Address, ...) *big.Int
- func EnoughAmount(reserve int64, items []*EntangleItem, keepInfo *KeepedAmount, fork bool) bool
- func GetMaxHeight(items map[uint32]*EntangleTxInfo) uint64
- func Hash(es *EntangleState) chainhash.Hash
- func IsEntangleTx(tx *wire.MsgTx) (map[uint32]*EntangleTxInfo, error)
- func IsSendToZeroAddress(PkScript []byte) (bool, error)
- func MakeAddress(puk ecdsa.PublicKey) (error, czzutil.Address)
- func MakeEntangleTx(params *chaincfg.Params, inputs []*wire.TxIn, feeRate, inAmount czzutil.Amount, ...) (*wire.MsgTx, error)
- func MakeMergeCoinbaseTx(tx *wire.MsgTx, pool *PoolAddrItem, items []*EntangleItem, ...) error
- func MakeMergerCoinbaseTx2(height *big.Int, tx *wire.MsgTx, items []*EntangleItem2, state *EntangleState) error
- func OverEntangleAmount(tx *wire.MsgTx, pool *PoolAddrItem, items []*EntangleItem, ...) bool
- func PreCalcEntangleAmount(item *EntangleItem, keepInfo *KeepedAmount, fork bool)
- func RecoverPublicFromBytes(pub []byte, t ExpandedTxType) (*ecdsa.PublicKey, error)
- func SignEntangleTx(tx *wire.MsgTx, inputAmount []czzutil.Amount, priv *czzec.PrivateKey) error
- func SummayPunishedInfos(infos map[uint64]UserTimeOutBurnInfo) map[uint64]LHPunishedItems
- func UnmarshalPubkey1(pub []byte) (*ecdsa.PublicKey, error)
- func ValidAssetType(utype uint32) bool
- func ValidPK(pk []byte) bool
- func VerifyTxsSequence(infos []*EtsInfo) error
- type AddBeaconPledge
- type BaseAmountUint
- type BeaconAddressInfo
- type BurnInfos
- type BurnItem
- type BurnProofInfo
- type BurnTxInfo
- type CacheEntangleInfo
- type EnAssetItem
- type EntangleEntity
- type EntangleEntitys
- type EntangleItem
- type EntangleItem2
- type EntangleState
- func (es *EntangleState) AddEntangleItem(addr string, aType uint32, lightID uint64, height, amount *big.Int) (*big.Int, error)
- func (es *EntangleState) AddPoolAmount(amount1, amount2 *big.Int)
- func (es *EntangleState) AddressInWhiteList(addr string, self bool) bool
- func (es *EntangleState) AppendAmountForBeaconAddress(addr string, amount *big.Int) error
- func (es *EntangleState) AppendCoinbase(addr string, coinbases []string) error
- func (es *EntangleState) AppendWhiteList(addr string, wlist []*WhiteUnit) error
- func (es *EntangleState) BurnAsset(addr string, aType uint32, lightID, height uint64, amount *big.Int) (*big.Int, error)
- func (es *EntangleState) DecodeRLP(s *rlp.Stream) error
- func (es *EntangleState) EncodeRLP(w io.Writer) error
- func (es *EntangleState) FinishBeaconAddressPunished(eid uint64, amount *big.Int) error
- func (es *EntangleState) FinishHandleUserBurn(lightID, height uint64, addr czzutil.Address, atype uint32, amount *big.Int) error
- func (es *EntangleState) GetCoinbase(addr string) []string
- func (es *EntangleState) LimitStakingAmount(eid uint64, atype uint32) *big.Int
- func (es *EntangleState) Load() error
- func (es *EntangleState) RegisterBeaconAddress(addr string, to []byte, amount *big.Int, fee, keeptime uint64, ...) error
- func (es *EntangleState) Save() error
- func (es *EntangleState) SetInitPoolAmount(amount1, amount2 *big.Int)
- func (es *EntangleState) SubPoolAmount1(amount *big.Int)
- func (es *EntangleState) SubPoolAmount2(amount *big.Int)
- func (es *EntangleState) ToBytes() []byte
- func (es *EntangleState) TourAllUserBurnInfo(height uint64) map[uint64]UserTimeOutBurnInfo
- func (es *EntangleState) UnregisterBeaconAddress(addr string) error
- func (es *EntangleState) UpdateCfgForBeaconAddress(addr string, fee, keeptime uint64, assetType uint32) error
- func (es *EntangleState) UpdateCoinbase(addr, update, newAddr string) error
- func (es *EntangleState) UpdateQuotaOnBlock(height uint64) error
- func (es *EntangleState) UpdateStateToPunished(infos map[uint64]UserTimeOutBurnInfo)
- type EntangleTxInfo
- type EntangleVerify
- func (ev *EntangleVerify) VerifyAddBeaconPledgeTx(tx *wire.MsgTx, eState *EntangleState) (*AddBeaconPledge, error)
- func (ev *EntangleVerify) VerifyBeaconRegistrationTx(tx *wire.MsgTx, eState *EntangleState) (*BeaconAddressInfo, error)
- func (ev *EntangleVerify) VerifyEntangleTx(tx *wire.MsgTx) ([]*TuplePubIndex, error)
- type EtsInfo
- type ExpandedTxType
- type FreeQuotaItem
- type KeepedAmount
- type KeepedItem
- type LHPunishedItem
- type LHPunishedItems
- type PoolAddrItem
- type SortStoreBeaconAddress
- type SortStoreUserInfos
- type SortStoreUserItems
- type StoreBeaconAddress
- type StoreUserInfos
- type StoreUserItme
- type TimeOutBurnInfo
- type TmpAddressPair
- type TuplePubIndex
- type TypeTimeOutBurnInfo
- type UserEntangleInfos
- type UserTimeOutBurnInfo
- type WhiteUnit
Constants ¶
const ( // Entangle Transcation type ExpandedTxEntangle_Doge = 0xF0 ExpandedTxEntangle_Ltc = 0xF1 ExpandedTxEntangle_Btc = 0xF2 ExpandedTxEntangle_Bsv = 0xF3 ExpandedTxEntangle_Bch = 0xF4 )
const ( LhAssetBTC uint32 = 1 << iota LhAssetBCH LhAssetBSV LhAssetLTC LhAssetUSDT LhAssetDOGE )
Variables ¶
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") )
var ( NoEntangle = errors.New("no entangle info in transcation") NoBeaconRegistration = errors.New("no BeaconRegistration info in transcation") NoAddBeaconPledge = errors.New("no AddBeaconPledge info in transcation") )
var ( ErrInvalidParam = errors.New("Invalid Param") ErrLessThanMin = errors.New("less than min staking amount for beaconAddress") ErrRepeatRegister = errors.New("repeat register on this address") ErrNotRepeatRegister = errors.New("repeat not register on this address") ErrRepeatToAddress = errors.New("repeat to Address on this register") ErrNoRegister = errors.New("not found the beaconAddress") ErrAddressInWhiteList = errors.New("the address in the whitelist") ErrNoUserReg = errors.New("not entangle user in the beaconAddress") ErrNoUserAsset = errors.New("user no entangle asset in the beaconAddress") ErrNotEnouthBurn = errors.New("not enough burn amount in beaconAddress") ErrNotMatchUser = errors.New("cann't find user address") ErrBurnProof = errors.New("burn proof info not match") ErrStakingNotEnough = errors.New("staking not enough") )
var ( MinStakingAmountForBeaconAddress = new(big.Int).Mul(big.NewInt(1000000), big.NewInt(1e8)) MaxWhiteListCount = 4 MAXBASEFEE = 100000 MAXFREEQUOTA = 100000 // about 30 days LimitRedeemHeightForBeaconAddress = 5000 MaxCoinBase = 4 )
var ( BucketKey = []byte("entangle-tx") EntangleStateKey = []byte("entanglestate") )
var (
ErrHeightTooClose = errors.New("the block heigth to close for entangling")
)
Functions ¶
func CheckTransactionisBlock ¶
func CheckTransactionisBlock(txhash string, block *rpcclient.DogecoinMsgBlock) bool
func ComputeDiff ¶
func EnoughAmount ¶
func EnoughAmount(reserve int64, items []*EntangleItem, keepInfo *KeepedAmount, fork bool) bool
func GetMaxHeight ¶
func GetMaxHeight(items map[uint32]*EntangleTxInfo) uint64
func Hash ¶
func Hash(es *EntangleState) chainhash.Hash
func IsEntangleTx ¶
func IsEntangleTx(tx *wire.MsgTx) (map[uint32]*EntangleTxInfo, error)
func IsSendToZeroAddress ¶
func MakeEntangleTx ¶
func MakeMergeCoinbaseTx ¶
func MakeMergeCoinbaseTx(tx *wire.MsgTx, pool *PoolAddrItem, items []*EntangleItem, lastScriptInfo []byte, fork bool) error
func MakeMergerCoinbaseTx2 ¶
func MakeMergerCoinbaseTx2(height *big.Int, tx *wire.MsgTx, items []*EntangleItem2, state *EntangleState) error
func OverEntangleAmount ¶
func OverEntangleAmount(tx *wire.MsgTx, pool *PoolAddrItem, items []*EntangleItem, lastScriptInfo []byte, fork bool, state *EntangleState) bool
func PreCalcEntangleAmount ¶
func PreCalcEntangleAmount(item *EntangleItem, keepInfo *KeepedAmount, fork bool)
func RecoverPublicFromBytes ¶
func RecoverPublicFromBytes(pub []byte, t ExpandedTxType) (*ecdsa.PublicKey, error)
RecoverPublic returns the public key of the marshal bytes.
func SignEntangleTx ¶
func SummayPunishedInfos ¶
func SummayPunishedInfos(infos map[uint64]UserTimeOutBurnInfo) map[uint64]LHPunishedItems
func UnmarshalPubkey1 ¶
UnmarshalPubkey converts bytes to a secp256k1 public key.
func ValidAssetType ¶
///////////////////////////////////////////////////////////////
func VerifyTxsSequence ¶
Types ¶
type AddBeaconPledge ¶
type AddBeaconPledge struct { Address string `json:"address"` ToAddress []byte `json:"to_address"` StakingAmount *big.Int `json:"staking_amount"` }
func AddBeaconPledgeTxFromScript ¶
func AddBeaconPledgeTxFromScript(script []byte) (*AddBeaconPledge, error)
func IsAddBeaconPledgeTx ¶
type BaseAmountUint ¶
type BeaconAddressInfo ¶
type BeaconAddressInfo struct { ExchangeID uint64 `json:"exchange_id"` Address string `json:"address"` ToAddress []byte `json:"toAddress"` StakingAmount *big.Int `json:"staking_amount"` // in EntangleAmount *big.Int `json:"entangle_amount"` // out,express by czz,all amount of user's entangle EnAssets []*EnAssetItem `json:"en_assets"` // out,the extrinsic asset Frees []*FreeQuotaItem `json:"frees"` // extrinsic asset AssetFlag uint32 `json:"asset_flag"` Fee uint64 `json:"fee"` KeepTime uint64 `json:"keep_time"` // the time as the block count for finally redeem time WhiteList []*WhiteUnit `json:"white_list"` CoinBaseAddress []string `json:"CoinBaseAddress"` }
func BeaconRegistrationTxFromScript ¶
func BeaconRegistrationTxFromScript(script []byte) (*BeaconAddressInfo, error)
Beacon
func IsBeaconRegistrationTx ¶
type BurnInfos ¶
type BurnInfos struct { Items []*BurnItem RAllAmount *big.Int // redeem asset for outside asset by burned czz BAllAmount *big.Int // all burned asset on czz by the account }
func (*BurnInfos) GetAllAmountByOrigin ¶
GetAllAmountByOrigin returns all burned amount asset (czz)
func (*BurnInfos) GetAllBurnedAmountByOutside ¶
type BurnProofInfo ¶
type BurnTxInfo ¶
type BurnTxInfo struct { ExTxType ExpandedTxType Address string LightID uint64 Amount *big.Int }
func BurnInfoFromScript ¶
func BurnInfoFromScript(script []byte) (*BurnTxInfo, error)
type CacheEntangleInfo ¶
func (*CacheEntangleInfo) FetchEntangleUtxoView ¶
func (c *CacheEntangleInfo) FetchEntangleUtxoView(info *EntangleTxInfo) bool
func (*CacheEntangleInfo) LoadEntangleState ¶
func (c *CacheEntangleInfo) LoadEntangleState(height int32, hash chainhash.Hash) *EntangleState
type EnAssetItem ¶
type EnAssetItem BaseAmountUint
type EntangleEntity ¶
type EntangleEntity struct { ExchangeID uint64 `json:"exchange_id"` Address string `json:"address"` AssetType uint32 `json:"asset_type"` Height *big.Int `json:"height"` // newest height for entangle OldHeight *big.Int `json:"old_height"` // oldest height for entangle EnOutsideAmount *big.Int `json:"en_outside_amount"` // out asset OriginAmount *big.Int `json:"origin_amount"` // origin asset(czz) by entangle in MaxRedeem *big.Int `json:"max_redeem"` // out asset BurnAmount *BurnInfos `json:"burn_amount"` }
/////////////////////////////////////////////////////////////// Address > EntangleEntity
func (*EntangleEntity) GetValidRedeemAmount ¶
func (e *EntangleEntity) GetValidRedeemAmount() *big.Int
the returns maybe negative
type EntangleEntitys ¶
type EntangleEntitys []*EntangleEntity
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 EntangleItem2 ¶
func (*EntangleItem2) Clone ¶
func (ii *EntangleItem2) Clone() *EntangleItem2
type EntangleState ¶
type EntangleState struct { EnInfos map[string]*BeaconAddressInfo EnEntitys map[uint64]UserEntangleInfos PoolAmount1 *big.Int PoolAmount2 *big.Int CurExchangeID uint64 }
func NewEntangleState ¶
func NewEntangleState() *EntangleState
func (*EntangleState) AddEntangleItem ¶
func (es *EntangleState) AddEntangleItem(addr string, aType uint32, lightID uint64, height, amount *big.Int) (*big.Int, error)
AddEntangleItem add item in the state, keep BeaconAddress have enough amount to entangle,
func (*EntangleState) AddPoolAmount ¶
func (es *EntangleState) AddPoolAmount(amount1, amount2 *big.Int)
func (*EntangleState) AddressInWhiteList ¶
func (es *EntangleState) AddressInWhiteList(addr string, self bool) bool
func (*EntangleState) AppendAmountForBeaconAddress ¶
func (es *EntangleState) AppendAmountForBeaconAddress(addr string, amount *big.Int) error
func (*EntangleState) AppendCoinbase ¶
func (es *EntangleState) AppendCoinbase(addr string, coinbases []string) error
func (*EntangleState) AppendWhiteList ¶
func (es *EntangleState) AppendWhiteList(addr string, wlist []*WhiteUnit) error
func (*EntangleState) BurnAsset ¶
func (es *EntangleState) BurnAsset(addr string, aType uint32, lightID, height uint64, amount *big.Int) (*big.Int, error)
BurnAsset user burn the czz asset to exchange the outside asset,the caller keep the burn was true. verify the txid,keep equal amount czz returns the amount czz by user's burnned, took out fee by beaconaddress
func (*EntangleState) FinishBeaconAddressPunished ¶
func (es *EntangleState) FinishBeaconAddressPunished(eid uint64, amount *big.Int) error
func (*EntangleState) FinishHandleUserBurn ¶
func (es *EntangleState) FinishHandleUserBurn(lightID, height uint64, addr czzutil.Address, atype uint32, amount *big.Int) error
FinishHandleUserBurn the BeaconAddress finish the burn item
func (*EntangleState) GetCoinbase ¶
func (es *EntangleState) GetCoinbase(addr string) []string
func (*EntangleState) LimitStakingAmount ¶
func (es *EntangleState) LimitStakingAmount(eid uint64, atype uint32) *big.Int
Minimum pledge amount = 1 million CZZ + (cumulative cross-chain buying CZZ - cumulative cross-chain selling CZZ) x exchange rate ratio
func (*EntangleState) Load ¶
func (es *EntangleState) Load() error
func (*EntangleState) RegisterBeaconAddress ¶
func (es *EntangleState) RegisterBeaconAddress(addr string, to []byte, amount *big.Int, fee, keeptime uint64, assetType uint32, wu []*WhiteUnit, cba []string) error
/////////////////////////////////////////////////////////////// keep staking enough amount asset
func (*EntangleState) Save ¶
func (es *EntangleState) Save() error
func (*EntangleState) SetInitPoolAmount ¶
func (es *EntangleState) SetInitPoolAmount(amount1, amount2 *big.Int)
func (*EntangleState) SubPoolAmount1 ¶
func (es *EntangleState) SubPoolAmount1(amount *big.Int)
func (*EntangleState) SubPoolAmount2 ¶
func (es *EntangleState) SubPoolAmount2(amount *big.Int)
func (*EntangleState) ToBytes ¶
func (es *EntangleState) ToBytes() []byte
func (*EntangleState) TourAllUserBurnInfo ¶
func (es *EntangleState) TourAllUserBurnInfo(height uint64) map[uint64]UserTimeOutBurnInfo
TourAllUserBurnInfo Tours all user's burned asset and check which is timeout to redeem
func (*EntangleState) UnregisterBeaconAddress ¶
func (es *EntangleState) UnregisterBeaconAddress(addr string) error
UnregisterBeaconAddress need to check all the proves and handle all the user's burn coins
func (*EntangleState) UpdateCfgForBeaconAddress ¶
func (es *EntangleState) UpdateCfgForBeaconAddress(addr string, fee, keeptime uint64, assetType uint32) error
func (*EntangleState) UpdateCoinbase ¶
func (es *EntangleState) UpdateCoinbase(addr, update, newAddr string) error
func (*EntangleState) UpdateQuotaOnBlock ¶
func (es *EntangleState) UpdateQuotaOnBlock(height uint64) error
//////////////////////////////////////////////////////////////////// UpdateQuotaOnBlock called in insertBlock for update user's quota state
func (*EntangleState) UpdateStateToPunished ¶
func (es *EntangleState) UpdateStateToPunished(infos map[uint64]UserTimeOutBurnInfo)
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 Params *chaincfg.Params }
func (*EntangleVerify) VerifyAddBeaconPledgeTx ¶
func (ev *EntangleVerify) VerifyAddBeaconPledgeTx(tx *wire.MsgTx, eState *EntangleState) (*AddBeaconPledge, error)
func (*EntangleVerify) VerifyBeaconRegistrationTx ¶
func (ev *EntangleVerify) VerifyBeaconRegistrationTx(tx *wire.MsgTx, eState *EntangleState) (*BeaconAddressInfo, error)
func (*EntangleVerify) VerifyEntangleTx ¶
func (ev *EntangleVerify) VerifyEntangleTx(tx *wire.MsgTx) ([]*TuplePubIndex, error)
type ExpandedTxType ¶
type ExpandedTxType uint8
type FreeQuotaItem ¶
type FreeQuotaItem BaseAmountUint
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 LHPunishedItem ¶
type LHPunishedItems ¶
type LHPunishedItems []*LHPunishedItem
type PoolAddrItem ¶
type SortStoreBeaconAddress ¶
type SortStoreBeaconAddress []*StoreBeaconAddress
func (SortStoreBeaconAddress) Len ¶
func (vs SortStoreBeaconAddress) Len() int
func (SortStoreBeaconAddress) Less ¶
func (vs SortStoreBeaconAddress) Less(i, j int) bool
func (SortStoreBeaconAddress) Swap ¶
func (vs SortStoreBeaconAddress) Swap(i, j int)
type SortStoreUserInfos ¶
type SortStoreUserInfos []*StoreUserInfos
func (SortStoreUserInfos) Len ¶
func (vs SortStoreUserInfos) Len() int
func (SortStoreUserInfos) Less ¶
func (vs SortStoreUserInfos) Less(i, j int) bool
func (SortStoreUserInfos) Swap ¶
func (vs SortStoreUserInfos) Swap(i, j int)
type SortStoreUserItems ¶
type SortStoreUserItems []*StoreUserItme
func (SortStoreUserItems) Len ¶
func (vs SortStoreUserItems) Len() int
func (SortStoreUserItems) Less ¶
func (vs SortStoreUserItems) Less(i, j int) bool
func (SortStoreUserItems) Swap ¶
func (vs SortStoreUserItems) Swap(i, j int)
type StoreBeaconAddress ¶
type StoreBeaconAddress struct { Address string Lh *BeaconAddressInfo }
type StoreUserInfos ¶
type StoreUserInfos struct { EID uint64 UserInfos UserEntangleInfos }
type StoreUserItme ¶
type StoreUserItme struct { Addr string UserInfos EntangleEntitys }
type TimeOutBurnInfo ¶
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 }
type TypeTimeOutBurnInfo ¶
type TypeTimeOutBurnInfo []*TimeOutBurnInfo
type UserEntangleInfos ¶
type UserEntangleInfos map[string]EntangleEntitys
type UserTimeOutBurnInfo ¶
type UserTimeOutBurnInfo map[string]TypeTimeOutBurnInfo