dcrm

package
v0.0.0-...-872243e Latest Latest
Warning

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

Go to latest
Published: Sep 27, 2019 License: GPL-3.0, LGPL-3.0 Imports: 68 Imported by: 0

Documentation

Overview

Package helpers provides convenience functions to simplify wallet code. This package is intended for internal wallet use only.

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

Index

Constants

View Source
const (
	// RedeemP2PKHSigScriptSize is the worst case (largest) serialize size
	// of a transaction input script that redeems a compressed P2PKH output.
	// It is calculated as:
	//
	//   - OP_DATA_73
	//   - 72 bytes DER signature + 1 byte sighash
	//   - OP_DATA_33
	//   - 33 bytes serialized compressed pubkey
	RedeemP2PKHSigScriptSize = 1 + 73 + 1 + 33

	// P2PKHPkScriptSize is the size of a transaction output script that
	// pays to a compressed pubkey hash.  It is calculated as:
	//
	//   - OP_DUP
	//   - OP_HASH160
	//   - OP_DATA_20
	//   - 20 bytes pubkey hash
	//   - OP_EQUALVERIFY
	//   - OP_CHECKSIG
	P2PKHPkScriptSize = 1 + 1 + 1 + 20 + 1 + 1

	// RedeemP2PKHInputSize is the worst case (largest) serialize size of a
	// transaction input redeeming a compressed P2PKH output.  It is
	// calculated as:
	//
	//   - 32 bytes previous tx
	//   - 4 bytes output index
	//   - 1 byte compact int encoding value 107
	//   - 107 bytes signature script
	//   - 4 bytes sequence
	RedeemP2PKHInputSize = 32 + 4 + 1 + RedeemP2PKHSigScriptSize + 4

	// P2PKHOutputSize is the serialize size of a transaction output with a
	// P2PKH output script.  It is calculated as:
	//
	//   - 8 bytes output value
	//   - 1 byte compact int encoding value 25
	//   - 25 bytes P2PKH output script
	P2PKHOutputSize = 8 + 1 + P2PKHPkScriptSize

	// P2WPKHPkScriptSize is the size of a transaction output script that
	// pays to a witness pubkey hash. It is calculated as:
	//
	//   - OP_0
	//   - OP_DATA_20
	//   - 20 bytes pubkey hash
	P2WPKHPkScriptSize = 1 + 1 + 20

	// P2WPKHOutputSize is the serialize size of a transaction output with a
	// P2WPKH output script. It is calculated as:
	//
	//   - 8 bytes output value
	//   - 1 byte compact int encoding value 22
	//   - 22 bytes P2PKH output script
	P2WPKHOutputSize = 8 + 1 + P2WPKHPkScriptSize

	// RedeemP2WPKHScriptSize is the size of a transaction input script
	// that spends a pay-to-witness-public-key hash (P2WPKH). The redeem
	// script for P2WPKH spends MUST be empty.
	RedeemP2WPKHScriptSize = 0

	// RedeemP2WPKHInputSize is the worst case size of a transaction
	// input redeeming a P2WPKH output. It is calculated as:
	//
	//   - 32 bytes previous tx
	//   - 4 bytes output index
	//   - 1 byte encoding empty redeem script
	//   - 0 bytes redeem script
	//   - 4 bytes sequence
	RedeemP2WPKHInputSize = 32 + 4 + 1 + RedeemP2WPKHScriptSize + 4

	// RedeemNestedP2WPKHScriptSize is the worst case size of a transaction
	// input script that redeems a pay-to-witness-key hash nested in P2SH
	// (P2SH-P2WPKH). It is calculated as:
	//
	//   - 1 byte compact int encoding value 22
	//   - OP_0
	//   - 1 byte compact int encoding value 20
	//   - 20 byte key hash
	RedeemNestedP2WPKHScriptSize = 1 + 1 + 1 + 20

	// RedeemNestedP2WPKHInputSize is the worst case size of a
	// transaction input redeeming a P2SH-P2WPKH output. It is
	// calculated as:
	//
	//   - 32 bytes previous tx
	//   - 4 bytes output index
	//   - 1 byte compact int encoding value 23
	//   - 23 bytes redeem script (scriptSig)
	//   - 4 bytes sequence
	RedeemNestedP2WPKHInputSize = 32 + 4 + 1 +
		RedeemNestedP2WPKHScriptSize + 4

	// RedeemP2WPKHInputWitnessWeight is the worst case weight of
	// a witness for spending P2WPKH and nested P2WPKH outputs. It
	// is calculated as:
	//
	//   - 1 wu compact int encoding value 2 (number of items)
	//   - 1 wu compact int encoding value 73
	//   - 72 wu DER signature + 1 wu sighash
	//   - 1 wu compact int encoding value 33
	//   - 33 wu serialized compressed pubkey
	RedeemP2WPKHInputWitnessWeight = 1 + 1 + 73 + 1 + 33
)

Worst case script and input/output size estimates.

View Source
const (
	VERSION           = 0.1
	RPCCLIENT_TIMEOUT = 30

	SERVER_HOST       = "47.107.50.83" //"localhost"
	SERVER_PORT       = 8000           //18443
	USER              = "xxmm"
	PASSWD            = "123456"
	USESSL            = false
	WALLET_PASSPHRASE = "WalletPassphrase"
)
View Source
const BITCOIN_BASE58_TABLE = "123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz"

Variables

View Source
var (
	//err code 1
	ErrEncodeSendMsgFail          = `{Code:1,Error:"encode send msg fail."}`
	ErrParamError                 = `{Code:2,Error:"parameters error."}`
	ErrGetOtherNodesDataFail      = `{Code:3,Error:"NetWork Error,Get Data From Other Node Fail."}`
	ErrUnknownChType              = `{Code:4,Error:"unknown channel type."}`
	ErrGetChValueFail             = `{Code:5,Error:"get channel value fail."}`
	ErrNoGetLOAccout              = `{Code:6,Error:"There's no proper account to do lockout."}`
	ErrNoFindWorker               = `{Code:7,Error:"can not find worker."}`
	ErrOutsideTxFail              = `{Code:8,Error:"outside tx fail."}`
	ErrReqAddrTimeout             = `{Code:9,Error:"request dcrm address timeout."}`
	ErrGetWorkerIdError           = `{Code:10,Error:"get worker id error."}`
	ErrGetPrexDataError           = `{Code:11,Error:"get msg prefix data error."}`
	ErrValidateRealFusionAddrFail = `{Code:12,Error:"validate real fusion from fail."}`
	ErrValidateRealDcrmFromFail   = `{Code:13,Error:"validate real dcrm from fail."}`
	ErrSendTxToNetFail            = `{Code:14,Error:"send tx to outside net fail."}`
	ErrSendDataToGroupFail        = `{Code:15,Error:"send data to group fail."}`
	ErrInternalMsgFormatError     = `{Code:16,Error:"msg data format error."}`
	ErrGetNoResFromGroupMem       = `{Code:17,Error:"no get any result from other group node."}`
	ErrCoinTypeNotSupported       = `{Code:18,Error:"coin type is not supported."}`
	ErrTokenTypeError             = `{Code:19,Error:"token type error."}`
	ErrValidateLIFromAddrFail     = `{Code:20,Error:"lockin validate from address fail."}`
	ErrValidateLIValueFail        = `{Code:21,Error:"lockin validate value fail."}`
	ErrConfirmAddrFail            = `{Code:22,Error:"the dcrm address confirm validate fail."}`
	ErrGroupNotReady              = `{Code:23,Error:"the group is not ready.please try again."}`
	ErrGetGenPubkeyFail           = `{Code:24,Error:"get generate pubkey fail."}`
	ErrGetGenSaveDataFail         = `{Code:25,Error:"get generate save data fail."}`
	ErrCreateDbFail               = `{Code:26,Error:"create db fail."}`
	ErrGetRealEosUserFail         = `{Code:27,Error:"cannot get real eos account."}`
	ErrDcrmSigWrongSize           = `{Code:28,Error:"wrong size for dcrm sig."}`
	ErrDcrmSigFail                = `{Code:29,Error:"dcrm sign fail."}`
	ErrInvalidDcrmAddr            = `{Code:30,Error:"invalid dcrm address."}`
	ErrGetC1Timeout               = `{Code:31,Error:"get C1 timeout."}`
	ErrGetEnodeByUIdFail          = `{Code:32,Error:"can not find proper enodes by uid."}`
	ErrGetD1Timeout               = `{Code:33,Error:"get D1 timeout."}`
	ErrGetSHARE1Timeout           = `{Code:34,Error:"get SHARE1 timeout."}`
	ErrGetAllSHARE1Fail           = `{Code:35,Error:"get all SHARE1 msg fail."}`
	ErrGetAllD1Fail               = `{Code:36,Error:"get all D1 msg fail."}`
	ErrVerifySHARE1Fail           = `{Code:37,Error:"verify SHARE1 fail."}`
	ErrGetAllC1Fail               = `{Code:38,Error:"get all C1 msg fail."}`
	ErrKeyGenVerifyCommitFail     = `{Code:39,Error:"verify commit in keygenerate fail."}`
	ErrGetZKFACTPROOFTimeout      = `{Code:40,Error:""get ZKFACTPROOF timeout."}`
	ErrGetZKUPROOFTimeout         = `{Code:41,Error:""get ZKUPROOF timeout."}`
	ErrGetAllZKFACTPROOFFail      = `{Code:42,Error:"get all ZKFACTPROOF msg fail."}`
	ErrVerifyZKFACTPROOFFail      = `{Code:43,Error:"verify ZKFACTPROOF fail."}`
	ErrGetAllZKUPROOFFail         = `{Code:44,Error:"get all ZKUPROOF msg fail."}`
	ErrVerifyZKUPROOFFail         = `{Code:45,Error:"verify ZKUPROOF fail."}`
	ErrGetC11Timeout              = `{Code:46,Error:"get C11 timeout."}`
	ErrGetMTAZK1PROOFTimeout      = `{Code:47,Error:"get MTAZK1PROOF timeout."}`
	ErrGetKCTimeout               = `{Code:48,Error:"get KC timeout."}`
	ErrGetAllKCFail               = `{Code:49,Error:"get all KC msg fail."}`
	ErrGetAllMTAZK1PROOFFail      = `{Code:50,Error:"get all MTAZK1PROOF msg fail."}`
	ErrVerifyMTAZK1PROOFFail      = `{Code:51,Error:"verify MTAZK1PROOF fail.""}`
	ErrGetMKGTimeout              = `{Code:52,Error:"get MKG timeout."}`
	ErrGetAllMKGFail              = `{Code:53,Error:"get all MKG msg fail."}`
	ErrGetMKWTimeout              = `{Code:54,Error:"get MKW timeout."}`
	ErrGetAllMKWFail              = `{Code:55,Error:"get all MKW msg fail."}`
	ErrVerifyMKGFail              = `{Code:56,Error:"verify MKG fail.""}`
	ErrVerifyMKWFail              = `{Code:57,Error:"verify MKW fail.""}`
	ErrGetPaillierPrivKeyFail     = `{Code:58,Error:"get paillier privkey fail.""}`
	ErrGetDELTA1Timeout           = `{Code:59,Error:"get DELTA1 timeout."}`
	ErrGetAllDELTA1Fail           = `{Code:60,Error:"get all DELTA1 msg fail."}`
	ErrGetD11Timeout              = `{Code:61,Error:"get D11 timeout."}`
	ErrGetAllD11Fail              = `{Code:62,Error:"get all D11 msg fail."}`
	ErrGetAllC11Fail              = `{Code:63,Error:"get all C11 msg fail."}`
	ErrSignVerifyCommitFail       = `{Code:64,Error:"verify commit in dcrm sign fail."}`
	ErrREqualZero                 = `{Code:65,Error:"sign error: r equal zero."}`
	ErrGetS1Timeout               = `{Code:66,Error:"get S1 timeout."}`
	ErrGetAllS1Fail               = `{Code:67,Error:"get all S1 msg fail."}`
	ErrVerifySAllFail             = `{Code:68,Error:"verify SAll != m*G + r*PK in dcrm sign ec2."}`
	ErrGetSS1Timeout              = `{Code:69,Error:"get SS1 timeout."}`
	ErrGetAllSS1Fail              = `{Code:70,Error:"get all SS1 msg fail."}`
	ErrSEqualZero                 = `{Code:71,Error:"sign error: s equal zero."}`
	ErrDcrmSignVerifyFail         = `{Code:72,Error:"dcrm sign verify fail."}`
	ErrInvalidCoinbase            = `{Code:73,Error:"Invalid Coinbase."}`
	ErrStateDBError               = `{Code:74,Error:"StateDB Error."}`
	ErrEosAccountNameError        = `{Code:75,Error:"eos account name must be 12 character long, lowercase letters or 1-5."}`
	ErrReqEosPubkeyError          = `{Code:76,Error:"Request eos pubkey error."}`

	ErrAlreadyKnownLOTx         = `{Code:101,Error:"already known lockout transaction with same nonce."}`
	ErrOrderAlreadySend         = `{Code:102,Error:"the miner has send order already."}`
	ErrTxDataError              = `{Code:103,Error:"tx input data error."}`
	ErrInvalidDcrmPubkey        = `{Code:104,Error:"invalid dcrm pubkey."}`
	ErrDcrmAddrAlreadyConfirmed = `{Code:105,Error:"the account has confirmed dcrm address."}`
	ErrDcrmAddrNotConfirmed     = `{Code:106,Error:"the account has not confirmed dcrm address before."}`
	ErrDcrmAddrAlreadyLockIn    = `{Code:107,Error:"the dcrmaddr has lockin alread."}`
	ErrNotRealLockIn            = `{Code:108,Error:"it is not the real lockin,it is BTC change."}`
	ErrInsufficientDcrmFunds    = `{Code:109,Error:"Insufficient Dcrm Funds For Value + Fee."}`
	ErrInvalidAddrToLO          = `{Code:110,Error:"Lock Out To Invalid Address."}`
	ErrLOToSelf                 = `{Code:111,Error:"can not lockout to yourself."}`
	ErrInvalidTx                = `{Code:112,Error:"tx data invalid."}`
	ErrHashKeyMiss              = `{Code:113,Error:"hash key and real dcrm from is miss."}`

	//TODO
	ErrGetTradeUnitFail = `{Code:114,Error:"get trade unit fail."}`
	ErrCalcOrderBalance = `{Code:115,Error:"calc balance error."}`

	ErrFromNotFusionAccount    = `{Code:116,Error:"From Must Be Fusion Account In LockOut Tx."}`
	ErrReqAddrInsufficient     = `{Code:117,Error:"Insufficient for req addr,need least 5 fsn."}`
	ErrAddNewTradeInsufficient = `{Code:118,Error:"Insufficient for add new trade,need least 5 fsn."}`
)

dcrm erros

View Source
var (
	FSN Backend

	NodeCnt           = 3
	ThresHold         = 3
	PaillierKeyLength = 2048

	CHAIN_ID = 4 //ethereum mainnet=1 rinkeby testnet=4  //TODO :get user define chainid.

	//rpc-req //dcrm node
	RpcMaxWorker = 100
	RpcMaxQueue  = 100
	RpcReqQueue  chan RpcReq

	RpcMaxNonDcrmWorker = 100
	RpcMaxNonDcrmQueue  = 100
	RpcReqNonDcrmQueue  chan RpcReq

	ETH_SERVER = "http://54.183.185.30:8018"

	BTC_BLOCK_CONFIRMS int64
	BTC_DEFAULT_FEE    float64
	ETH_DEFAULT_FEE    *big.Int

	//
	BLOCK_FORK_0 = "0" //"18000" //fork for dcrmsendtransaction.not to self.
	BLOCK_FORK_1 = "0" //"280000" //fork for lockin,txhash store into block.
	BLOCK_FORK_2 = "0" //"100000" //fork for lockout choose real dcrm from.

	TryTimes          = 100
	TryTimesForLockin = 10

	OrderTest string

	ReorgNum uint64          //test net:10  main net:1000
	UT       = "10000000000" ////add for exchange decimal--->big.Int
)
View Source
var (
	DC *list.List
)

Functions

func AccountManager

func AccountManager() *accounts.Manager

func Base58Decode

func Base58Decode(bitcoin_net int, input []byte) []byte

func Btc_createTransaction

func Btc_createTransaction(msgprex string, dcrmaddr string, toAddr string, changeAddress string, value float64, requiredConfirmations uint32, feeRateBtc float64, ch chan interface{}) string

构建和发送一笔比特币交易 dcrmaddr: dcrm地址, toAddr: 接收转账的地址 changeAddress: 找零地址 requiredConfirmations 需要的确认区块数, 默认是6 feeRateBtc: 费用率, 单位是比特币

func CanDoMatch

func CanDoMatch() bool

func ChainDb

func ChainDb() ethdb.Database

func CheckRealEosAccount

func CheckRealEosAccount(accountName, ownerkey, activekey string) (ok bool)

func ChooseDcrmAddrForLockoutByValue

func ChooseDcrmAddrForLockoutByValue(dcrmaddr string, lockoutto string, value float64) bool

func ChooseRealFusionAccountForLockout

func ChooseRealFusionAccountForLockout(amount string, lockoutto string, cointype string) (string, string, error)

func Coinbase

func Coinbase() (eb common.Address, err error)

func Compress

func Compress(c []byte) (string, error)

//compress

func CreateRealEosAccount

func CreateRealEosAccount(accountName string, ownerkey string, activekey string) error

func Dcrm_LiLoReqAddress

func Dcrm_LiLoReqAddress(wr WorkReq) (string, error)

============================================================

func Dcrm_Sign

func Dcrm_Sign(wr WorkReq) (string, error)

func Decode

func Decode(s string) (interface{}, error)

func DecryptSplitPrivKey

func DecryptSplitPrivKey(cDPrivKey string, enodeID string) (dPrivKey *big.Int, err error)

func DefaultDataDir

func DefaultDataDir() string

func DisMsg

func DisMsg(msg string)

msg: hash-enode:C1:X1:X2

func DispenseSplitPrivKey

func DispenseSplitPrivKey(enode interface{})

func DoCurlRequest

func DoCurlRequest(url, api, data string) string

func DoubleHash

func DoubleHash(id string) *big.Int

func Encode

func Encode(obj interface{}) (string, error)

/////

func EncryptSplitPrivKey

func EncryptSplitPrivKey(dPrivKey *big.Int, pub *ecies.PublicKey) (cDPrivKey string, err error)

func Erc20_newUnsignedTransaction

func Erc20_newUnsignedTransaction(client *ethclient.Client, dcrmAddress string, toAddressHex string, amount *big.Int, gasPrice *big.Int, gasLimit uint64, tokenType string) (*types.Transaction, *common.Hash, error)

func Erc20_sendTx

func Erc20_sendTx(client *ethclient.Client, signedTx *types.Transaction) (string, error)

func EstimateSerializeSize

func EstimateSerializeSize(inputCount int, txOuts []*wire.TxOut, addChangeOutput bool) int

EstimateSerializeSize returns a worst case serialize size estimate for a signed transaction that spends inputCount number of compressed P2PKH outputs and contains each transaction output from txOuts. The estimated size is incremented for an additional P2PKH change output if addChangeOutput is true.

func EstimateVirtualSize

func EstimateVirtualSize(numP2PKHIns, numP2WPKHIns, numNestedP2WPKHIns int,
	txOuts []*wire.TxOut, addChangeOutput bool) int

EstimateVirtualSize returns a worst case virtual size estimate for a signed transaction that spends the given number of P2PKH, P2WPKH and (nested) P2SH-P2WPKH outputs, and contains each transaction output from txOuts. The estimate is incremented for an additional P2PKH change output if addChangeOutput is true.

func GenerateBTC

func GenerateBTC() (string, string, error)

func GenerateBTCTest

func GenerateBTCTest(pubkey []byte) (string, string, error)

func GetAllMatchRes

func GetAllMatchRes(res string) ([]string, error)

func GetBTCTxFee

func GetBTCTxFee(lockoutto string, value float64) (*big.Int, error)

func GetChannelValue

func GetChannelValue(t int, obj interface{}) (string, error)

func GetDbDir

func GetDbDir() string

func GetDbDirForLockoutInfo

func GetDbDirForLockoutInfo() string

lockout info save path

func GetDbDirForLockoutRealFee

func GetDbDirForLockoutRealFee() string

lockout real fee path

func GetDbDirForLockoutStatus

func GetDbDirForLockoutStatus() string

all lockout tx status

func GetDbDirForWriteDcrmAddr

func GetDbDirForWriteDcrmAddr() string

dcrmaddr save path

func GetDcrmAddr

func GetDcrmAddr(dcrmaddr string, cointype string, coin string) string

func GetDcrmAddrBalanceForLockout

func GetDcrmAddrBalanceForLockout(dcrmaddr string, lockoutto string, value float64) (*big.Int, bool)

func GetDcrmAddrOutSideBalance

func GetDcrmAddrOutSideBalance(dcrmaddr string, cointype string) *big.Int

func GetEnodePrivKey

func GetEnodePrivKey(enodeID string) (prv *ecies.PrivateKey, err error)

func GetEnodesByUid

func GetEnodesByUid(uid *big.Int) string

func GetEnodesInfo

func GetEnodesInfo()

func GetEosAccount

func GetEosAccount() (acct, owner, active string)

func GetEosDbDir

func GetEosDbDir() string

eos_init---> eos account key: crypto.Keccak256Hash([]byte("eossettings")) value: pubkey+eos account

func GetIds

func GetIds() sortableIDSSlice

func GetLockoutConfirmations

func GetLockoutConfirmations(txhash string) (bool, error)

func GetLockoutInfoFromLocalDB

func GetLockoutInfoFromLocalDB(hash string) (string, error)

key: lockout tx hash value: lockout_txhash + sep10 + realfusionfrom + sep10 + realdcrmfrom

func GetLockoutRealFeeFromLocalDB

func GetLockoutRealFeeFromLocalDB(hash string) (string, error)

key: lockout tx hash value: real fee

func GetLockoutTxStatusFromLocalDB

func GetLockoutTxStatusFromLocalDB(hash string) (string, error)

key: lockout tx hash value: {Txid:xxx,Status:xxxxx,error:xxxxx,BlockHeight:xxxxx,RealFusionAccount:xxxxx,RealDcrmAccount:xxxxx,Cointype:xxxxx,OutSideTxHash:xxxxxx,TimeStamp:xxxxxx}

func GetPaillierPk

func GetPaillierPk(save string, index int) *paillier.PublicKey

func GetPaillierSk

func GetPaillierSk(save string, index int) *paillier.PrivateKey

func GetRawTransactionHash

func GetRawTransactionHash(decode string) string

func GetRetErr

func GetRetErr(err string) error

func GetRetErrJsonStr

func GetRetErrJsonStr(code int, err string) string

func GetSignString

func GetSignString(r *big.Int, s *big.Int, v int32, i int) string

func GetTxOutsAmount

func GetTxOutsAmount(lockoutto string, value float64) *big.Int

func GetTxStatus

func GetTxStatus(hash string) string

func GetUTXO_BlockChainInfo

func GetUTXO_BlockChainInfo(addr string) string

func GetZkFactProof

func GetZkFactProof(save string, index int) *paillier.ZkFactProof

func HashPubKey

func HashPubKey(pubKey []byte) []byte

HashPubKey hashes public key

func ImportAddrToWallet

func ImportAddrToWallet(dcrmaddr string, ch chan bool)

func Init

func Init(tmp string, c string, nodecnt int)

func InitChan

func InitChan()

workers,RpcMaxWorker,RpcReqWorker,RpcReqQueue,RpcMaxQueue,ReqDispatcher

func InitNonDcrmChan

func InitNonDcrmChan()

func InsToOB

func InsToOB(msg string)

func IsCurNode

func IsCurNode(enodes string, cur string) bool

func IsFusionAccountExsitDcrmAddr

func IsFusionAccountExsitDcrmAddr(fusion string, cointype string, dcrmaddr string) (bool, string, error)

func IsInGroup

func IsInGroup() bool

func IsInXvcGroup

func IsInXvcGroup() bool

func IsOrderBalanceOk

func IsOrderBalanceOk(from string, trade string, side string, price decimal.Decimal, quantity decimal.Decimal, fusion decimal.Decimal, A decimal.Decimal, B decimal.Decimal) (bool, error)

func IsValidDcrmAddr

func IsValidDcrmAddr(s string, cointype string) bool

func IsValidFusionAddr

func IsValidFusionAddr(s string) bool

func KeyGenerate_ec2

func KeyGenerate_ec2(msgprex string, ch chan interface{}, id int) bool

ec2 msgprex = hash

func LockoutIsConfirmed

func LockoutIsConfirmed(addr string, txhash string) (bool, error)

func MakeSignedTransaction

func MakeSignedTransaction(client *ethclient.Client, tx *types.Transaction, rsv string) (*types.Transaction, error)

func MergeDcrmBalance

func MergeDcrmBalance(account string, from string, to string, value *big.Int, cointype string)

func MergeDcrmBalance2

func MergeDcrmBalance2(account string, from string, to string, value *big.Int, cointype string, res chan bool)

func NewClient

func NewClient(host string, port int, user, passwd string, useSSL bool) (c *rpcClient, err error)

连接配置

func ReadDcrmAddrFromLocalDBByIndex

func ReadDcrmAddrFromLocalDBByIndex(fusion string, cointype string, index int) (string, error)

key: kec256(fusionaddr:cointype) value: dcrmaddr1:dcrmaddr2:dcrmaddr3............

func RegisterCheckOrderBalanceCB

func RegisterCheckOrderBalanceCB(recvObFunc func(string, string, string, decimal.Decimal, decimal.Decimal, decimal.Decimal, decimal.Decimal, decimal.Decimal, chan interface{}))

func RegisterGetDcrmAddrCallback

func RegisterGetDcrmAddrCallback(recvObFunc func(string, string, string) string)

func RegisterGetMatchResCallback

func RegisterGetMatchResCallback(recvObFunc func(string, chan interface{}))

func RegisterObCallback

func RegisterObCallback(recvObFunc func(string, chan interface{}))

func RegisterObCallback2

func RegisterObCallback2(recvObFunc func(string))

func RegisterTXCallback

func RegisterTXCallback(recvObFunc func(string, string) *big.Int)

func SendMsgToDcrmGroup

func SendMsgToDcrmGroup(msg string)

msg = hash-enode:C1:X1:X2...... send msg = hash-enode-C1|1|2|hash-enode:C1: send msg = hash-enode-C1|2|2|X1:X2......

func SendMsgToPeer

func SendMsgToPeer(enodes string, msg string)

msg = hash-enode:C1:X1:X2...... send msg = hash-enode-C1|1|2|hash-enode:C1: send msg = hash-enode-C1|2|2|X1:X2......

func SendReqToGroup

func SendReqToGroup(msg string, rpctype string) (string, error)

func SetBackend

func SetBackend(e Backend)

func SetDatadir

func SetDatadir(data string)

func SetTxStatus

func SetTxStatus(hash string, status string)

func SetUpMsgList

func SetUpMsgList(msg string)

==================node in group callback=================================

func Sign_ec2

func Sign_ec2(msgprex string, save string, message string, tokenType string, pkx *big.Int, pky *big.Int, ch chan interface{}, id int) string

msgprex = hash return value is the backup for the dcrm sig

func SumOutputSerializeSizes

func SumOutputSerializeSizes(outputs []*wire.TxOut) (serializeSize int)

SumOutputSerializeSizes sums up the serialized size of the supplied outputs.

func SumOutputValues

func SumOutputValues(outputs []*wire.TxOut) (totalOutput btcutil.Amount)

SumOutputValues sums up the list of TxOuts and returns an Amount.

func ToWIF

func ToWIF(priv []byte) (wif string)

ToWIF converts a Bitcoin private key to a Wallet Import Format string.

func Tool_DecimalByteSlice2HexString

func Tool_DecimalByteSlice2HexString(DecimalSlice []byte) string

func UnCompress

func UnCompress(s string) (string, error)

//uncompress

func ValidateAddress

func ValidateAddress(bitcoin_net int, address string) bool

func Validate_Txhash

func Validate_Txhash(wr WorkReq) (string, error)

func Verify

func Verify(r *big.Int, s *big.Int, v int32, message string, pkx *big.Int, pky *big.Int) bool

func Verify2

func Verify2(r *big.Int, s *big.Int, v int32, message string, pkx *big.Int, pky *big.Int) bool

func WriteDcrmAddrToLocalDB

func WriteDcrmAddrToLocalDB(fusion string, cointype string, dcrmaddr string) (bool, error)

func WriteLockoutInfoToLocalDB

func WriteLockoutInfoToLocalDB(hash string, value string) (bool, error)

func WriteLockoutRealFeeToLocalDB

func WriteLockoutRealFeeToLocalDB(hash string, value string) (bool, error)

func WriteLockoutTxStatusToLocalDB

func WriteLockoutTxStatusToLocalDB(hash string, value string) (bool, error)

Types

type AccountInfo

type AccountInfo struct {
	AccountName string                 `json:"account_name"`
	RamQuato    uint32                 `json:"ram_quato"`
	NetWeight   uint32                 `json:"net_weight"`
	CpuWeight   uint32                 `json:"cpu_weight"`
	NetLimit    Limit                  `json:"net_limit"`
	CpuLimit    Limit                  `json:"cpu_limit"`
	RamUsage    uint32                 `json:"ram_usage"`
	Perms       Permissions            `json:"permissions"`
	Error       map[string]interface{} `json:"error"`
}

type AccountListInfo

type AccountListInfo struct {
	COINTYPE    string
	DCRMADDRESS string
	DCRMPUBKEY  string
}

type AccountListJson

type AccountListJson struct {
	ACCOUNTLIST []AccountListInfo
}

type AddrApiResult

type AddrApiResult struct {
	Address             string
	Total_received      float64
	Balance             float64
	Unconfirmed_balance uint64
	Final_balance       float64
	N_tx                int64
	Unconfirmed_n_tx    int64
	Final_n_tx          int64
	Txrefs              []Txref
	Tx_url              string
}

type Auth

type Auth struct {
	Threshold int   `json:"threshold"`
	Keys      []Key `json:"keys"`
}

type AuthoredTx

type AuthoredTx struct {
	Tx              *wire.MsgTx
	PrevScripts     [][]byte
	PrevInputValues []btcutil.Amount
	TotalInput      btcutil.Amount
	ChangeIndex     int // negative if no change
}

type Backend

type Backend interface {
	//BlockChain() *core.BlockChain
	//TxPool() *core.TxPool
	Etherbase() (eb common.Address, err error)
	ChainDb() ethdb.Database
	AccountManager() *accounts.Manager
}

type BtcTxResInfo

type BtcTxResInfo struct {
	Result GetTransactionResult
	Error  error
	Id     int
}

for btc main chain noinputs

type BtcTxResInfoNoInputs

type BtcTxResInfoNoInputs struct {
	Result GetTransactionResultNoInputs
	Error  error
	Id     int
}

for btc main chain noinputs

type ConfirmAddrSendMsgToDcrm

type ConfirmAddrSendMsgToDcrm struct {
	Txhash     string
	Tx         string
	FusionAddr string
	DcrmAddr   string
	Hashkey    string
	Cointype   string
}

func (*ConfirmAddrSendMsgToDcrm) Run

func (self *ConfirmAddrSendMsgToDcrm) Run(workid int, ch chan interface{}) bool

type DcrmAddrInfo

type DcrmAddrInfo struct {
	DcrmAddr      string
	FusionAccount string
	CoinType      string
	Balance       *big.Int
}

type DcrmAddrInfoWrapper

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

func (DcrmAddrInfoWrapper) Len

func (dw DcrmAddrInfoWrapper) Len() int

func (DcrmAddrInfoWrapper) Less

func (dw DcrmAddrInfoWrapper) Less(i, j int) bool

func (DcrmAddrInfoWrapper) Swap

func (dw DcrmAddrInfoWrapper) Swap(i, j int)

type DcrmAddrRes

type DcrmAddrRes struct {
	FusionAccount string
	DcrmAddr      string
	//Txhash string
	Type string
}

type DcrmChain

type DcrmChain struct {
	//key: lockout tx hash
	//value: lockout_txhash + sep10 + realfusionfrom + sep10 + realdcrmfrom
	Lo_info *KVData

	//key:  kec256(fusionaddr:cointype)
	//value: dcrmaddr1:dcrmaddr2:dcrmaddr3............
	Da *KVData

	//key:  dcrmaddr or pubkey
	//value:  fusionaddr + sep + xxx + sep + ys + sep + save + sep + kec256(fusionaddr:cointype)
	Dc_info *KVData

	Status string

	Txhash string
}

func NewDcrmChain

func NewDcrmChain() (*DcrmChain, error)

type DcrmPubkeyRes

type DcrmPubkeyRes struct {
	FusionAccount string
	DcrmPubkey    string
	//Type string
	//Status string //0:default   1:req  2:confirmed
	Addresses map[string]string
}

type ECDSASignature

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

func (*ECDSASignature) GetR

func (this *ECDSASignature) GetR() *big.Int

func (*ECDSASignature) GetRecoveryParam

func (this *ECDSASignature) GetRecoveryParam() int32

func (*ECDSASignature) GetRoudFiveAborted

func (this *ECDSASignature) GetRoudFiveAborted() bool

func (*ECDSASignature) GetS

func (this *ECDSASignature) GetS() *big.Int

func (*ECDSASignature) New

func (this *ECDSASignature) New()

func (*ECDSASignature) New2

func (this *ECDSASignature) New2(r *big.Int, s *big.Int)

func (*ECDSASignature) New3

func (this *ECDSASignature) New3(r *big.Int, s *big.Int, recoveryParam int32)

func (*ECDSASignature) SetR

func (this *ECDSASignature) SetR(r *big.Int)

func (*ECDSASignature) SetRecoveryParam

func (this *ECDSASignature) SetRecoveryParam(recoveryParam int32)

func (*ECDSASignature) SetRoudFiveAborted

func (this *ECDSASignature) SetRoudFiveAborted(roudFiveAborted bool)

func (*ECDSASignature) SetS

func (this *ECDSASignature) SetS(s *big.Int)

type Err

type Err struct {
	Info string
}

error type 1

func (Err) Error

func (e Err) Error() string

type ErrorRet

type ErrorRet struct {
	Code  int
	Error string
}

type GetAllMatchResSendMsgToXvc

type GetAllMatchResSendMsgToXvc struct {
	Msg string
}

get all matchres

func (*GetAllMatchResSendMsgToXvc) Run

func (self *GetAllMatchResSendMsgToXvc) Run(workid int, ch chan interface{}) bool

type GetDcrmGroupCountSendMsgToXvc

type GetDcrmGroupCountSendMsgToXvc struct {
	Msg string
}

func (*GetDcrmGroupCountSendMsgToXvc) Run

func (self *GetDcrmGroupCountSendMsgToXvc) Run(workid int, ch chan interface{}) bool

type GetMatchResSendMsgToXvc

type GetMatchResSendMsgToXvc struct {
	Msg string
}

func (*GetMatchResSendMsgToXvc) Run

func (self *GetMatchResSendMsgToXvc) Run(workid int, ch chan interface{}) bool

type GetTransactionResult

type GetTransactionResult struct {
	Txid          string
	Hash          string
	Version       int64
	Size          int64
	Vsize         int64
	Weight        int64
	Locktime      int64
	Vin           []Vinparm
	Vout          []Voutparm
	Hex           string
	Blockhash     string
	Confirmations int64
	Time          int64
	BlockTime     int64
}

type GetTransactionResultNoInputs

type GetTransactionResultNoInputs struct {
	Txid          string
	Hash          string
	Version       int64
	Size          int64
	Vsize         int64
	Weight        int64
	Locktime      int64
	Vin           []VinparmNoInputs
	Vout          []Voutparm
	Hex           string
	Blockhash     string
	Confirmations int64
	Time          int64
	BlockTime     int64
}

type KVData

type KVData struct {
	Key   string
	Value string
}

type Key

type Key struct {
	Key    string `json:"key"`
	Weight int    `json:"weight"`
}

type Limit

type Limit struct {
	Used      int64 `used`
	Available int64 `available`
	Max       int64 `max`
}

type ListUTXO

type ListUTXO struct {
	TXID          string
	VOUT          uint32
	ADDRESS       string
	ACCOUNT       string
	SCRIPTPUBKEY  string
	AMOUNT        float64
	CONFIRMATIONS int64
	SPENDABLE     bool
	SOLVABLE      bool
	SAFE          bool
}

type ListUTXOs

type ListUTXOs struct {
	RESULT []ListUTXO
	ERROR  error
	ID     int
}

type LockInSendMsgToDcrm

type LockInSendMsgToDcrm struct {
	Txhash       string
	Tx           string
	Fusionaddr   string
	Hashkey      string
	Value        string
	Cointype     string
	LockinAddr   string
	RealDcrmFrom string
}

lockin

func (*LockInSendMsgToDcrm) Run

func (self *LockInSendMsgToDcrm) Run(workid int, ch chan interface{}) bool

type LockoutGetRealAccount

type LockoutGetRealAccount struct {
	Txhash         string
	Tx             string
	FusionFrom     string
	DcrmFrom       string
	RealFusionFrom string
	RealDcrmFrom   string
	Lockoutto      string
	Value          string
	Cointype       string
}

get real account

func (*LockoutGetRealAccount) Run

func (self *LockoutGetRealAccount) Run(workid int, ch chan interface{}) bool

type LockoutSendMsgToDcrm

type LockoutSendMsgToDcrm struct {
	Txhash         string
	Tx             string
	FusionFrom     string
	DcrmFrom       string
	RealFusionFrom string
	RealDcrmFrom   string
	Lockoutto      string
	Value          string
	Cointype       string
}

lockout

func (*LockoutSendMsgToDcrm) Run

func (self *LockoutSendMsgToDcrm) Run(workid int, ch chan interface{}) bool

type OrderCreateSendMsgToXvc

type OrderCreateSendMsgToXvc struct {
	//txhash:tx:fusionaddr:trade:ordertype:side:price:quanity:rule:time
	Msg string
}

order create

func (*OrderCreateSendMsgToXvc) Run

func (self *OrderCreateSendMsgToXvc) Run(workid int, ch chan interface{}) bool

type Output

type Output struct {
	Script    string
	Addresses []string
}

type Permission

type Permission struct {
	PermName     string `json:"perm_name"`
	Parent       string `json:"parent"`
	RequiredAuth Auth   `json:"required_auth"`
}

type Permissions

type Permissions []Permission

func (Permissions) Len

func (p Permissions) Len() int

func (Permissions) Less

func (p Permissions) Less(i, j int) bool

func (Permissions) Swap

func (p Permissions) Swap(i, j int)

type RPCTransaction

type RPCTransaction struct {
	BlockHash        common.Hash     `json:"blockHash"`
	BlockNumber      *hexutil.Big    `json:"blockNumber"`
	From             common.Address  `json:"from"`
	Gas              hexutil.Uint64  `json:"gas"`
	GasPrice         *hexutil.Big    `json:"gasPrice"`
	Hash             common.Hash     `json:"hash"`
	Input            hexutil.Bytes   `json:"input"`
	Nonce            hexutil.Uint64  `json:"nonce"`
	To               *common.Address `json:"to"`
	TransactionIndex hexutil.Uint    `json:"transactionIndex"`
	Value            *hexutil.Big    `json:"value"`
	V                *hexutil.Big    `json:"v"`
	R                *hexutil.Big    `json:"r"`
	S                *hexutil.Big    `json:"s"`
}

for eth

type RecvMsg

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

RecvMsg

func (*RecvMsg) Run

func (self *RecvMsg) Run(workid int, ch chan interface{}) bool

type ReqAddrSendMsgToDcrm

type ReqAddrSendMsgToDcrm struct {
	Fusionaddr string
	Pub        string
	Cointype   string
}

//////////////////////////////////////////

func (*ReqAddrSendMsgToDcrm) Run

func (self *ReqAddrSendMsgToDcrm) Run(workid int, ch chan interface{}) bool

type ReqDispatcher

type ReqDispatcher struct {
	// A pool of workers channels that are registered with the dispatcher
	WorkerPool chan chan RpcReq
}

rpc-req

func NewReqDispatcher

func NewReqDispatcher(maxWorkers int) *ReqDispatcher

func (*ReqDispatcher) Run

func (d *ReqDispatcher) Run()

type ReqNonDcrmDispatcher

type ReqNonDcrmDispatcher struct {
	// A pool of workers channels that are registered with the dispatcher
	WorkerPool chan chan RpcReq
}

func NewReqNonDcrmDispatcher

func NewReqNonDcrmDispatcher(maxWorkers int) *ReqNonDcrmDispatcher

func (*ReqNonDcrmDispatcher) Run

func (d *ReqNonDcrmDispatcher) Run()

type RpcDcrmRes

type RpcDcrmRes struct {
	Ret string
	Err error
}

func GetGroupRes

func GetGroupRes(wid int) RpcDcrmRes

type RpcReq

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

type RpcReqNonDcrmWorker

type RpcReqNonDcrmWorker struct {
	RpcReqWorkerPool chan chan RpcReq
	RpcReqChannel    chan RpcReq
	// contains filtered or unexported fields
}

func NewRpcReqNonDcrmWorker

func NewRpcReqNonDcrmWorker(workerPool chan chan RpcReq) *RpcReqNonDcrmWorker

func (*RpcReqNonDcrmWorker) Clear

func (w *RpcReqNonDcrmWorker) Clear()

func (*RpcReqNonDcrmWorker) Start

func (w *RpcReqNonDcrmWorker) Start()

func (*RpcReqNonDcrmWorker) Stop

func (w *RpcReqNonDcrmWorker) Stop()

type RpcReqWorker

type RpcReqWorker struct {
	RpcReqWorkerPool chan chan RpcReq
	RpcReqChannel    chan RpcReq
	// contains filtered or unexported fields
}

func FindWorker

func FindWorker(sid string) (*RpcReqWorker, error)

func NewRpcReqWorker

func NewRpcReqWorker(workerPool chan chan RpcReq) *RpcReqWorker

func (*RpcReqWorker) Clear

func (w *RpcReqWorker) Clear()

func (*RpcReqWorker) Clear2

func (w *RpcReqWorker) Clear2()

func (*RpcReqWorker) Start

func (w *RpcReqWorker) Start()

func (*RpcReqWorker) Stop

func (w *RpcReqWorker) Stop()

type SafeMap

type SafeMap struct {
	sync.RWMutex
	KeyMap map[string]string
}

type ScriptSigParam

type ScriptSigParam struct {
	Asm string
	Hex string
}

type Scriptparm

type Scriptparm struct {
	Asm       string
	Hex       string
	ReqSigs   int64
	Type      string
	Addresses []string
}

///////////////////for btc main chain

type SendMsg

type SendMsg struct {
	MsgType string
	Nonce   string
	WorkId  int
	Msg     string
}

get matchres

type SendRawTxRes

type SendRawTxRes struct {
	Hash common.Hash
	Err  error
}

type TxApiResult

type TxApiResult struct {
	TxHash  string
	Outputs []Output
}

type Txref

type Txref struct {
	Tx_hash       string
	Block_height  int64
	Tx_input_n    int32
	Tx_output_n   int32
	Value         float64
	Ref_balance   float64
	Spent         bool
	Confirmations int64
	Confirmed     string
	Double_spend  bool
}

Txref 表示一次交易中的第 Tx_input_n 个输入, 或第 Tx_output_n 个输出 如果是一个输入, Tx_input_n = -1 如果是一个输出, Tx_output_n = -1 如果表示交易输出,spent表示是否花出

type UtxoLsRes

type UtxoLsRes struct {
	Unspent_outputs []UtxoRes
}

type UtxoRes

type UtxoRes struct {
	Tx_hash_big_endian string
	Script             string
	Tx_output_n        uint32
	Value              float64
	Confirmations      int64
}

type Vinparm

type Vinparm struct {
	Txid      string
	Vout      int64
	ScriptSig ScriptSigParam
	Sequence  int64
}

type VinparmNoInputs

type VinparmNoInputs struct {
	Coinbase string
	Sequence int64
}

type Voutparm

type Voutparm struct {
	Value        float64
	N            int64
	ScriptPubKey Scriptparm
}

type Wallet

type Wallet struct {
	PrivateKey []byte
	PublicKey  []byte
}

Wallet stores private and public keys

func NewWallet

func NewWallet() *Wallet

NewWallet creates and returns a Wallet

func (Wallet) GetAddress

func (w Wallet) GetAddress(bitcoin_net int) (address string)

GetAddress returns wallet address

type WorkReq

type WorkReq interface {
	Run(workid int, ch chan interface{}) bool
}

Directories

Path Synopsis
bch
bnb
btc
Package helpers provides convenience functions to simplify wallet code.
Package helpers provides convenience functions to simplify wallet code.
config
提供api的节点地址
提供api的节点地址
eos
eth
eth/sha3
Package sha3 implements the SHA-3 fixed-output-length hash functions and the SHAKE variable-output-length hash functions defined by FIPS-202.
Package sha3 implements the SHA-3 fixed-output-length hash functions and the SHAKE variable-output-length hash functions defined by FIPS-202.
evt
trx
xrp
ec2
vss

Jump to

Keyboard shortcuts

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