Documentation ¶
Index ¶
- Constants
- Variables
- func Balance(ctx context.Context, configuration *config.Config) (int64, error)
- func BalanceHelper(ctx context.Context, configuration *config.Config, offsign bool, ...) (int64, error)
- func ConfirmDeposit(ctx context.Context, logId int64) (*exPb.ConfirmDepositResponse, error)
- func ConfirmDepositProcess(ctx context.Context, n *core.IpfsNode, ...) error
- func DecryptWithAES(key, message string) (string, error)
- func Deposit(ctx context.Context, n *core.IpfsNode, ledgerAddr []byte, amount int64, ...) (*exPb.PrepareDepositResponse, error)
- func DepositRequest(ctx context.Context, prepareResponse *exPb.PrepareDepositResponse, ...) (*exPb.DepositResponse, error)
- func DiscoverySpeedKey(password string) (string, error)
- func EncryptWithAES(key, message string) (string, error)
- func GetBalance(ctx context.Context, configuration *config.Config) (int64, int64, error)
- func GetBalanceByWalletAddress(ctx context.Context, solidityUrl string, walletAddress string) (tokenMap map[string]int64, err error)
- func GetStatus(ctx context.Context, url string, txId string) (string, error)
- func GetTokenBalance(ctx context.Context, addr []byte, tokenId string) (int64, error)
- func GetTransactions(d ds.Datastore, peerId string) ([]*walletpb.TransactionV1, error)
- func Init(ctx context.Context, configuration *config.Config) error
- func PKCS5Padding(ciphertext []byte, blockSize int) ([]byte, error)
- func PKCS5Unpadding(encrypt []byte) ([]byte, error)
- func PersistTx(d ds.Datastore, peerId string, txId string, amount int64, from string, ...) error
- func PersistTxWithTime(d ds.Datastore, peerId string, txId string, amount int64, from string, ...) error
- func PrepareDeposit(ctx context.Context, ledgerAddr []byte, amount int64) (*exPb.PrepareDepositResponse, error)
- func PrepareTx(ctx context.Context, cfg *config.Config, from string, to string, amount int64, ...) (*tronPb.TransactionExtention, error)
- func PrepareWithdraw(ctx context.Context, ledgerAddr, externalAddr []byte, amount, outTxId int64) (*exPb.PrepareWithdrawResponse, error)
- func SendRawTransaction(ctx context.Context, url string, raw []byte, sig []byte) error
- func SetKeys(n *core.IpfsNode, privKey string, mnemonic string) (err error)
- func Sign(in interface{}, key *ecdsa.PrivateKey) ([]byte, error)
- func SignChannel(raw []byte, key *ecdsa.PrivateKey) ([]byte, error)
- func SignTron(rawData []byte, key *ecdsa.PrivateKey) ([]byte, error)
- func UpdatePendingTransactions(ctx context.Context, d ds.Datastore, cfg *config.Config, peerId string) (int, int, error)
- func UpdateStatus(d ds.Datastore, peerId string, txId string, status string) error
- func WalletDeposit(ctx context.Context, configuration *config.Config, n *core.IpfsNode, ...) error
- func WalletWithdraw(ctx context.Context, configuration *config.Config, n *core.IpfsNode, ...) error
- func Withdraw(ctx context.Context, n *core.IpfsNode, ledgerAddr, externalAddr []byte, ...) (int64, int64, error)
- func WithdrawRequest(ctx context.Context, channelId *ledgerPb.ChannelID, ledgerAddr []byte, ...) (*exPb.WithdrawResponse, error)
- type EcdsaSignature
- type TronRet
- type TxData
- type TxSlice
- type Wallet
Constants ¶
const ( InAppWallet = "BTFS Wallet" BttWallet = "BTT Wallet" StatusPending = "Pending" StatusSuccess = "Success" StatusFailed = "Failed" )
Variables ¶
var ( ErrTransactionParam = errors.New("transaction is nil") ErrChannelStateParam = errors.New("channelState is nil") ErrChannelCommitParam = errors.New("channelCommit is nil") ErrTypeParam = errors.New("wrong type") )
var ( ErrInsufficientExchangeBalanceOnTron = errors.New("exchange balance on Tron network is not sufficient") ErrInsufficientUserBalanceOnTron = errors.New(fmt.Sprint("User balance on tron network is not sufficient.")) ErrInsufficientUserBalanceOnLedger = errors.New("rpc error: code = ResourceExhausted desc = NSF") ErrInsufficientExchangeBalanceOnLedger = errors.New("exchange balance on Private Ledger is not sufficient") )
var ( WithdrawMinAmount int64 = 1 WithdrawMaxAmount int64 = 1000000000000 DepositMinAmount int64 = 1 DepositMaxAmount int64 = 1000000000000 TokenId = "1002000" TokenIdDev = "1000252" )
Functions ¶
func BalanceHelper ¶
func ConfirmDeposit ¶
Call exchange's ConfirmDeposit API.
func ConfirmDepositProcess ¶
func ConfirmDepositProcess(ctx context.Context, n *core.IpfsNode, prepareResponse *exPb.PrepareDepositResponse, privateKey *ecdsa.PrivateKey) error
Continuous call ConfirmDeposit until it responses a FAILED or SUCCESS.
func DecryptWithAES ¶
func Deposit ¶
func Deposit(ctx context.Context, n *core.IpfsNode, ledgerAddr []byte, amount int64, privateKey *ecdsa.PrivateKey, runDaemon bool, async bool) (*exPb.PrepareDepositResponse, error)
Do the deposit action, integrate exchange's PrepareDeposit and Deposit API.
func DepositRequest ¶
func DepositRequest(ctx context.Context, prepareResponse *exPb.PrepareDepositResponse, privateKey *ecdsa.PrivateKey) (*exPb.DepositResponse, error)
Call exchange's Deposit API
func DiscoverySpeedKey ¶
return speed key in base64
func EncryptWithAES ¶
func GetBalance ¶
GetBalance both on ledger and Tron.
func GetTokenBalance ¶
Get the token balance on tron blockchain
func GetTransactions ¶
func PKCS5Unpadding ¶
func PersistTxWithTime ¶
func PrepareDeposit ¶
func PrepareDeposit(ctx context.Context, ledgerAddr []byte, amount int64) (*exPb.PrepareDepositResponse, error)
Call exchange's PrepareDeposit API.
func PrepareWithdraw ¶
func PrepareWithdraw(ctx context.Context, ledgerAddr, externalAddr []byte, amount, outTxId int64) ( *exPb.PrepareWithdrawResponse, error)
Call exchange's Withdraw API
func SendRawTransaction ¶
func Sign ¶
func Sign(in interface{}, key *ecdsa.PrivateKey) ([]byte, error)
Sign a Transaction, ChannelState, ChannelCommit in exchange proto or tron proto or ledger proto. parameter 'in' can be Transaction, ChannelState, ChannelCommit, return signature.
func SignChannel ¶
func SignChannel(raw []byte, key *ecdsa.PrivateKey) ([]byte, error)
Channel' sign function, return signature and error.
func SignTron ¶
func SignTron(rawData []byte, key *ecdsa.PrivateKey) ([]byte, error)
Tron' Sign function, return signature and error.
func UpdateStatus ¶
func WalletDeposit ¶
func WalletWithdraw ¶
func WalletWithdraw(ctx context.Context, configuration *config.Config, n *core.IpfsNode, amount int64) error
withdraw from ledger to tron
func Withdraw ¶
func Withdraw(ctx context.Context, n *core.IpfsNode, ledgerAddr, externalAddr []byte, amount int64, privateKey *ecdsa.PrivateKey) (int64, int64, error)
Do the withdraw action, integrate exchange's PrepareWithdraw and Withdraw API, return channel id and error. If Withdraw succeed, with return channel id and logInfo id, error is nil; otherwise will return error, channel id and logInfo id is 0.
func WithdrawRequest ¶
func WithdrawRequest(ctx context.Context, channelId *ledgerPb.ChannelID, ledgerAddr []byte, amount int64, prepareResponse *exPb.PrepareWithdrawResponse, privateKey *ecdsa.PrivateKey) (*exPb.WithdrawResponse, error)
Call exchange's PrepareWithdraw API
Types ¶
type EcdsaSignature ¶
type TronRet ¶
func TransferBTT ¶
type TxSlice ¶
type TxSlice []*walletpb.TransactionV1