adaptor

package module
v1.0.1 Latest Latest
Warning

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

Go to latest
Published: Dec 4, 2019 License: GPL-3.0 Imports: 7 Imported by: 9

README

adaptor

Abstract Blockchain Adaptor for PalletOne

Build Status Coverage Status

IUtility 通用操作接口

通用接口包含了最基本的钱包和区块链的操作。钱包操作就包括公私钥的生成和地址的生成,区块链的基本操作就包括对区块和交易的构建查询。 另外为了跨链时地址的映射,有一个特殊的接口:GetPalletOneMappingAddress,用于从链上取的链上地址与PTN地址的映射。

ICryptoCurrency Token操作接口

Token操作相关接口主要包含获取Token基本信息(小数精度),获取某个账户的余额,查询Token转账历史记录,构建转账交易,构建多签锁定地址等。

ISmartContract 智能合约操作接口

包括智能合约的安装、部署、调用和查询。除了查询不需要构造交易外,其他合约操作都是构造了未签名的交易,然后交给IUtility接口中进行签名和发送。

Token跨链的实现

BTC跨链
充币(BTC换PBTC)
  1. 用户使用比特币钱包,获得一个比特币公钥,并传入PalletOneBTC充币合约,获得一个多签地址。
  2. 用户使用PalletOne钱包,获得一个PalletOne地址。
  3. 用户用自己的ETH钱包账户调用多签合约的PTNAddress映射函数,将ETH地址和PTN地址映射,ABI
  4. 用户用自己的比特币钱包,转对应数量的BTC到多签地址。
  5. 用户到PalletOneBTC充币提币合约中,调用提取PBTC的方法,该方法逻辑如下:
    1. 根据当前调用者的PTN地址,调用Adaptor的GetPalletOneMappingAddress,获得对应的ETH地址
    2. 调用GetAddrTxHistory获得该地址往多签地址的转账记录
    3. 查询StateDB,如果是新的转账,则转对应PETH给用户
    4. 更新StateDB,标记该TxID为已处理
提币(PBTC换BTC)
  1. 用户使用BTC钱包,获得一个BTC钱包地址。
  2. 用户将PBTC转账到PalletOne BTC提币合约,并调用了申请提币函数,陪审团调用Adaptor的CreateTransferTokenTx,生成一个从多签地址转账到用户地址的交易,并记录到StateDB。
  3. 用户调用PalletOne BTC提币合约的提币函数,陪审团验证并处理提币请求,
    1. 查询StateDB,找到未签名的交易
    2. 调用SignTransaction,生成签名
    3. 收集陪审员的签名,并调用BindTxAndSignature,生成一个签名的交易
    4. 更新StateDB,将提币金额更新
    5. 陪审员调用SendTransaction,将签名后的Tx广播到比特币网络
ETH跨链
充币(ETH换PETH)
  1. 官方发布一个多签合约到以太坊,该合约提供了函数:ABI
  2. 用户使用PalletOne钱包,获得一个PalletOne地址。
  3. 用户用自己的ETH钱包账户调用多签合约的PTNAddress映射函数,将ETH地址和PTN地址映射,ABI
  4. 用户用自己的ETH钱包,转对应数量的ETH到多签地址。
  5. 用户到PalletOne充币提币ETH合约中,调用提取PETH的方法,该方法逻辑如下:
    1. 根据当前调用者的PTN地址,调用Adaptor的GetPalletOneMappingAddress,获得对应的ETH地址
    2. 调用GetAddrTxHistory获得该地址往多签地址的转账记录
    3. 查询StateDB,如果是新的转账,则转对应PETH给用户
    4. 更新StateDB,标记该TXID为已处理
提币(PETH换ETH)
  1. 复用充币对应的那个以太坊多签合约
  2. 用户将PETH转账到PalletOneETH提币合约,并调用了申请提币函数。
  3. 用户使用ETH钱包,获得一个ETH钱包地址,然后调用PalletOne ETH提币合约的提币函数,传入ETH地址
  4. 陪审团验证并处理提币请求,
    1. 调用Adaptor的CreateTransferTokenTx,生成一个交易,
    2. 调用SignTransaction,生成签名
    3. 收集陪审员的签名,并调用BindTxAndSignature,生成一个签名的交易
    4. 更新StateDB,将提币金额更新
    5. 由某个广播节点,将签名后的Tx广播到以太坊网络
  • 【注意】由于ETH的充提币地址是多用户共用的,所以不能像交易所充提币那样,由其他用户代充值,必须是自己以太坊钱包进行转账充值。

Documentation

Overview

Package adaptor is a generated GoMock package.

Package adaptor is a generated GoMock package.

Package adaptor is a generated GoMock package.

Index

Constants

This section is empty.

Variables

View Source
var ErrApiException = errors.New("api exception") //API端发生异常
View Source
var ErrNotFound = errors.New("not found") //未找到对应的结果

Functions

This section is empty.

Types

type AmountAsset added in v1.0.0

type AmountAsset struct {
	Amount *big.Int `json:"amount"` //金额,最小单位
	Asset  string   `json:"asset"`  //资产标识
}

AmountAsset Token的金额和资产标识

func NewAmountAsset added in v1.0.0

func NewAmountAsset(amount *big.Int, asset string) *AmountAsset

func NewAmountAssetString added in v1.0.0

func NewAmountAssetString(amount string, asset string) *AmountAsset

func NewAmountAssetUint64 added in v1.0.0

func NewAmountAssetUint64(amount uint64, asset string) *AmountAsset

func (*AmountAsset) String added in v1.0.0

func (aa *AmountAsset) String() string

type BindTxAndSignatureInput added in v1.0.0

type BindTxAndSignatureInput struct {
	//未签名的交易
	Transaction []byte `json:"transaction"`
	//多个签名
	Signatures [][]byte `json:"signatures"`
	SignedTxs  [][]byte `json:"signed_txs"`
	//BTC:如果是单签地址付出,那么Extra是公钥,如果是多签地址付出,那么Extra是RedeemScript
	//ETH: 暂时用不到
	Extra []byte `json:"extra"`
}

type BindTxAndSignatureOutput added in v1.0.0

type BindTxAndSignatureOutput struct {
	SignedTx []byte `json:"signed_tx"`
	Extra    []byte `json:"extra"`
}

type BlockInfo added in v1.0.0

type BlockInfo struct {
	BlockID         []byte `json:"block_id"`         //交易被打包到了哪个区块ID
	BlockHeight     uint   `json:"block_height"`     //交易被打包到的区块的高度
	Timestamp       uint64 `json:"timestamp"`        //交易被打包的时间戳
	ParentBlockID   []byte `json:"parent_block_id"`  //父区块ID
	HeaderRawData   []byte `json:"header_raw_data"`  //区块头的原始信息
	TxsRoot         []byte `json:"txs_root"`         //默克尔根
	ProducerAddress string `json:"producer_address"` //生产者地址
	IsStable        bool   `json:"is_stable"`        //是否已经稳定不可逆
}

BlockInfo 区块的基本信息

func (*BlockInfo) MarshalJSON added in v1.0.0

func (block *BlockInfo) MarshalJSON() ([]byte, error)

func (*BlockInfo) String added in v1.0.0

func (block *BlockInfo) String() string

func (*BlockInfo) UnmarshalJSON added in v1.0.0

func (block *BlockInfo) UnmarshalJSON(input []byte) error

type CalcTxHashInput added in v1.0.0

type CalcTxHashInput struct {
	Transaction []byte `json:"transaction"`
	Extra       []byte `json:"extra"`
}

type CalcTxHashOutput added in v1.0.0

type CalcTxHashOutput struct {
	Hash  []byte `json:"hash"`
	Extra []byte `json:"extra"`
}

type CreateContractInitialTxInput added in v1.0.0

type CreateContractInitialTxInput struct {
	Address  string       `json:"address"`
	Fee      *AmountAsset `json:"fee"`
	Contract []byte       `json:"contract"`
	Args     [][]byte     `json:"args"`
	Extra    []byte       `json:"extra"`
}

type CreateContractInitialTxOutput added in v1.0.0

type CreateContractInitialTxOutput struct {
	RawTransaction []byte `json:"raw_transaction"`
	Extra          []byte `json:"extra"`
}

type CreateContractInstallTxInput added in v1.0.0

type CreateContractInstallTxInput struct {
	Address  string       `json:"address"`
	Fee      *AmountAsset `json:"fee"`
	Contract []byte       `json:"contract"`
	Extra    []byte       `json:"extra"`
}

type CreateContractInstallTxOutput added in v1.0.0

type CreateContractInstallTxOutput struct {
	RawTransaction []byte `json:"raw_transaction"`
	Extra          []byte `json:"extra"`
}

type CreateContractInvokeTxInput added in v1.0.0

type CreateContractInvokeTxInput struct {
	//合约调用的发起方地址
	Address string `json:"address"`
	//调用合约时转了多少Token给合约
	Amount *AmountAsset `json:"amount"`
	//调用合约时支付的手续费
	Fee *AmountAsset `json:"fee"`
	//被调用的合约地址
	ContractAddress string `json:"contract_address"`
	//调用合约的函数名
	Function string `json:"function"`
	//调用合约时传入的参数
	Args  [][]byte `json:"args"`
	Extra []byte   `json:"extra"`
}

type CreateContractInvokeTxOutput added in v1.0.0

type CreateContractInvokeTxOutput struct {
	RawTransaction []byte `json:"raw_transaction"`
	Extra          []byte `json:"extra"`
}

type CreateMultiSigAddressInput added in v1.0.0

type CreateMultiSigAddressInput struct {
	Keys      [][]byte `json:"keys"`
	SignCount int      `json:"sign_count"`
	Extra     []byte   `json:"extra"`
}

type CreateMultiSigAddressOutput added in v1.0.0

type CreateMultiSigAddressOutput struct {
	Address string `json:"address"`
	Extra   []byte `json:"extra"`
}

type CreateMultiSigPayoutTxInput added in v1.0.1

type CreateMultiSigPayoutTxInput struct {
	FromAddress string       `json:"from_address"`
	ToAddress   string       `json:"to_address"`
	Amount      *AmountAsset `json:"amount"`
	Fee         *AmountAsset `json:"fee"`
	//BTC: 可以指定要排除的UTXO
	Extra []byte `json:"extra"`
}

type CreateMultiSigPayoutTxOutput added in v1.0.1

type CreateMultiSigPayoutTxOutput struct {
	Transaction []byte `json:"transaction"`
	//本交易包含的UTXO
	Extra []byte `json:"extra"`
}

type CreateTransferTokenTxInput added in v1.0.0

type CreateTransferTokenTxInput struct {
	FromAddress string       `json:"from_address"`
	ToAddress   string       `json:"to_address"`
	Amount      *AmountAsset `json:"amount"`
	Fee         *AmountAsset `json:"fee"`
	Extra       []byte       `json:"extra"`
}

type CreateTransferTokenTxOutput added in v1.0.0

type CreateTransferTokenTxOutput struct {
	Transaction []byte `json:"transaction"`
	Extra       []byte `json:"extra"`
}

type GetAddrTxHistoryInput added in v1.0.0

type GetAddrTxHistoryInput struct {
	FromAddress       string `json:"from_address"`         //转账的付款方地址
	ToAddress         string `json:"to_address"`           //转账的收款方地址
	Asset             string `json:"asset"`                //资产标识
	PageSize          uint32 `json:"page_size"`            //分页大小,0表示不分页
	PageIndex         uint32 `json:"page_index"`           //分页后的第几页数据
	AddressLogicAndOr bool   `json:"address_logic_and_or"` //付款地址,收款地址是And=1关系还是Or=0关系
	Asc               bool   `json:"asc"`                  //按时间顺序从老到新
	Extra             []byte `json:"extra"`
}

type GetAddrTxHistoryOutput added in v1.0.0

type GetAddrTxHistoryOutput struct {
	Txs   []*SimpleTransferTokenTx `json:"transactions"` //返回的交易列表
	Count uint32                   `json:"count"`        //忽略分页,有多少条记录
	Extra []byte                   `json:"extra"`
}

type GetAddressInput added in v1.0.0

type GetAddressInput struct {
	Key   []byte `json:"key"`
	Extra []byte `json:"extra"`
}

type GetAddressOutput added in v1.0.0

type GetAddressOutput struct {
	Address string `json:"address"`
	Extra   []byte `json:"extra"`
}

type GetAssetDecimalInput added in v1.0.0

type GetAssetDecimalInput struct {
	Asset string `json:"asset"` //资产标识
	Extra []byte `json:"extra"`
}

获得某种资产小数位数时的输入

type GetAssetDecimalOutput added in v1.0.0

type GetAssetDecimalOutput struct {
	Decimal uint   `json:"decimal"`
	Extra   []byte `json:"extra"`
}

获得的资产的小数位数

type GetBalanceInput added in v1.0.0

type GetBalanceInput struct {
	Address string `json:"address"`
	Asset   string `json:"asset"`
	Extra   []byte `json:"extra"`
}

查询余额时的输入参数

type GetBalanceOutput added in v1.0.0

type GetBalanceOutput struct {
	Balance AmountAsset `json:"balance"`
	Extra   []byte      `json:"extra"`
}

查询余额的返回值

type GetBlockInfoInput added in v1.0.0

type GetBlockInfoInput struct {
	Latest  bool   `json:"latest"`   //true表示查询最新区块
	Height  uint64 `json:"height"`   //根据高度查询区块
	BlockID []byte `json:"block_id"` //根据Hash查询区块
	Extra   []byte `json:"extra"`
}

type GetBlockInfoOutput added in v1.0.0

type GetBlockInfoOutput struct {
	Block BlockInfo `json:"block"`
	Extra []byte    `json:"extra"`
}

type GetContractInitialTxInput added in v1.0.0

type GetContractInitialTxInput struct {
	TxID  []byte `json:"tx_id"`
	Extra []byte `json:"extra"`
}

type GetContractInitialTxOutput added in v1.0.0

type GetContractInitialTxOutput struct {
	TxBasicInfo
	ContractAddress string `json:"contract_address"`
	Extra           []byte `json:"extra"`
}

type GetContractInstallTxInput added in v1.0.0

type GetContractInstallTxInput struct {
	TxID  []byte `json:"tx_id"`
	Extra []byte `json:"extra"`
}

type GetContractInstallTxOutput added in v1.0.0

type GetContractInstallTxOutput struct {
	TxBasicInfo
	TemplateID []byte `json:"template_id"`
}

type GetContractInvokeTxInput added in v1.0.0

type GetContractInvokeTxInput struct {
	TxID  []byte `json:"tx_id"`
	Extra []byte `json:"extra"`
}

type GetContractInvokeTxOutput added in v1.0.0

type GetContractInvokeTxOutput struct {
	TxBasicInfo
	UpdateStateSuccess bool   `json:"update_state_success"` //读写集一致,成功更新StateDB
	InvokeResult       []byte `json:"invoke_result"`
	Extra              []byte `json:"extra"`
}

type GetPalletOneMappingAddressInput added in v1.0.0

type GetPalletOneMappingAddressInput struct {
	PalletOneAddress  string `json:"palletone_address"`
	ChainAddress      string `json:"chain_address"`
	MappingDataSource string `json:"mapping_data_source"` //映射地址数据查询的地方,以太坊就是一个合约地址
	Extra             []byte `json:"extra"`
}

type GetPalletOneMappingAddressOutput added in v1.0.0

type GetPalletOneMappingAddressOutput struct {
	PalletOneAddress string `json:"palletone_address"`
	ChainAddress     string `json:"chain_address"`
	Extra            []byte `json:"extra"`
}

type GetPublicKeyInput added in v1.0.0

type GetPublicKeyInput struct {
	PrivateKey []byte `json:"private_key"`
	Extra      []byte `json:"extra"`
}

type GetPublicKeyOutput added in v1.0.0

type GetPublicKeyOutput struct {
	PublicKey []byte `json:"public_key"`
	Extra     []byte `json:"extra"`
}

type GetTransferTxInput added in v1.0.0

type GetTransferTxInput struct {
	TxID  []byte `json:"tx_id"`
	Extra []byte `json:"extra"`
}

type GetTransferTxOutput added in v1.0.0

type GetTransferTxOutput struct {
	Tx    SimpleTransferTokenTx `json:"transaction"`
	Extra []byte                `json:"extra"`
}

type GetTxBasicInfoInput added in v1.0.0

type GetTxBasicInfoInput struct {
	TxID  []byte `json:"tx_id"`
	Extra []byte `json:"extra"`
}

type GetTxBasicInfoOutput added in v1.0.0

type GetTxBasicInfoOutput struct {
	Tx    TxBasicInfo `json:"transaction"`
	Extra []byte      `json:"extra"`
}

type HashMessageInput added in v1.0.1

type HashMessageInput struct {
	Message []byte `json:"message"`
	Extra   []byte `json:"extra"`
}

type HashMessageOutput added in v1.0.1

type HashMessageOutput struct {
	Hash  []byte `json:"hash"`
	Extra []byte `json:"extra"`
}

type ICryptoCurrency added in v1.0.0

type ICryptoCurrency interface {
	IUtility
	//获取某地址下持有某资产的数量,返回数量为该资产的最小单位
	GetBalance(input *GetBalanceInput) (*GetBalanceOutput, error)
	//获取某资产的小数点位数
	GetAssetDecimal(asset *GetAssetDecimalInput) (*GetAssetDecimalOutput, error)
	//创建一个转账交易,但是未签名
	CreateTransferTokenTx(input *CreateTransferTokenTxInput) (*CreateTransferTokenTxOutput, error)
	//获取某个地址对某种Token的交易历史,支持分页和升序降序排列
	GetAddrTxHistory(input *GetAddrTxHistoryInput) (*GetAddrTxHistoryOutput, error)
	//根据交易ID获得对应的转账交易
	GetTransferTx(input *GetTransferTxInput) (*GetTransferTxOutput, error)
	//创建一个多签地址,该地址必须要满足signCount个签名才能解锁
	CreateMultiSigAddress(input *CreateMultiSigAddressInput) (*CreateMultiSigAddressOutput, error)
	//构造一个从多签地址付出Token的交易
	CreateMultiSigPayoutTx(input *CreateMultiSigPayoutTxInput) (*CreateMultiSigPayoutTxOutput, error)
}

ICryptoCurrency 加密货币相关的API

type ISmartContract added in v1.0.0

type ISmartContract interface {
	IUtility
	//创建一个安装合约的交易,未签名
	CreateContractInstallTx(input *CreateContractInstallTxInput) (*CreateContractInstallTxOutput, error)
	//查询合约安装的结果的交易
	GetContractInstallTx(input *GetContractInstallTxInput) (*GetContractInstallTxOutput, error)
	//初始化合约实例
	CreateContractInitialTx(input *CreateContractInitialTxInput) (*CreateContractInitialTxOutput, error)
	//查询初始化合约实例的交易
	GetContractInitialTx(input *GetContractInitialTxInput) (*GetContractInitialTxOutput, error)
	//调用合约方法
	CreateContractInvokeTx(input *CreateContractInvokeTxInput) (*CreateContractInvokeTxOutput, error)
	//查询调用合约方法的交易
	GetContractInvokeTx(input *GetContractInvokeTxInput) (*GetContractInvokeTxOutput, error)
	//调用合约的查询方法
	QueryContract(input *QueryContractInput) (*QueryContractOutput, error)
}

ISmartContract 智能合约的相关操作接口

type IUtility added in v1.0.0

type IUtility interface {
	//创建一个新的私钥
	NewPrivateKey(input *NewPrivateKeyInput) (*NewPrivateKeyOutput, error)
	//根据私钥创建公钥
	GetPublicKey(input *GetPublicKeyInput) (*GetPublicKeyOutput, error)
	//根据Key创建地址
	GetAddress(key *GetAddressInput) (*GetAddressOutput, error)
	//获得原链的地址和PalletOne的地址的映射
	GetPalletOneMappingAddress(addr *GetPalletOneMappingAddressInput) (*GetPalletOneMappingAddressOutput, error)
	//计算一条消息的Hash值
	HashMessage(input *HashMessageInput) (*HashMessageOutput, error)
	//对一条消息进行签名
	SignMessage(input *SignMessageInput) (*SignMessageOutput, error)
	//对签名进行验证
	VerifySignature(input *VerifySignatureInput) (*VerifySignatureOutput, error)
	//对一条交易进行签名,并返回签名结果
	SignTransaction(input *SignTransactionInput) (*SignTransactionOutput, error)
	//将未签名的原始交易与签名进行绑定,返回一个签名后的交易
	BindTxAndSignature(input *BindTxAndSignatureInput) (*BindTxAndSignatureOutput, error)
	//根据交易内容,计算交易Hash
	CalcTxHash(input *CalcTxHashInput) (*CalcTxHashOutput, error)
	//将签名后的交易广播到网络中,如果发送交易需要手续费,指定最多支付的手续费
	SendTransaction(input *SendTransactionInput) (*SendTransactionOutput, error)
	//根据交易ID获得交易的基本信息
	GetTxBasicInfo(input *GetTxBasicInfoInput) (*GetTxBasicInfoOutput, error)
	//查询获得一个区块的信息
	GetBlockInfo(input *GetBlockInfoInput) (*GetBlockInfoOutput, error)
}

IUtility 钱包相关的API接口,区块链相关API接口

type MockICryptoCurrency added in v1.0.0

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

MockICryptoCurrency is a mock of ICryptoCurrency interface

func NewMockICryptoCurrency added in v1.0.0

func NewMockICryptoCurrency(ctrl *gomock.Controller) *MockICryptoCurrency

NewMockICryptoCurrency creates a new mock instance

func (*MockICryptoCurrency) BindTxAndSignature added in v1.0.0

BindTxAndSignature mocks base method

func (*MockICryptoCurrency) CalcTxHash added in v1.0.0

func (m *MockICryptoCurrency) CalcTxHash(input *CalcTxHashInput) (*CalcTxHashOutput, error)

CalcTxHash mocks base method

func (*MockICryptoCurrency) CreateMultiSigAddress added in v1.0.0

CreateMultiSigAddress mocks base method

func (*MockICryptoCurrency) CreateTransferTokenTx added in v1.0.0

CreateTransferTokenTx mocks base method

func (*MockICryptoCurrency) EXPECT added in v1.0.0

EXPECT returns an object that allows the caller to indicate expected use

func (*MockICryptoCurrency) GetAddrTxHistory added in v1.0.0

GetAddrTxHistory mocks base method

func (*MockICryptoCurrency) GetAddress added in v1.0.0

GetAddress mocks base method

func (*MockICryptoCurrency) GetAssetDecimal added in v1.0.0

GetAssetDecimal mocks base method

func (*MockICryptoCurrency) GetBalance added in v1.0.0

func (m *MockICryptoCurrency) GetBalance(input *GetBalanceInput) (*GetBalanceOutput, error)

GetBalance mocks base method

func (*MockICryptoCurrency) GetBlockInfo added in v1.0.0

func (m *MockICryptoCurrency) GetBlockInfo(input *GetBlockInfoInput) (*GetBlockInfoOutput, error)

GetBlockInfo mocks base method

func (*MockICryptoCurrency) GetPalletOneMappingAddress added in v1.0.0

GetPalletOneMappingAddress mocks base method

func (*MockICryptoCurrency) GetPublicKey added in v1.0.0

func (m *MockICryptoCurrency) GetPublicKey(input *GetPublicKeyInput) (*GetPublicKeyOutput, error)

GetPublicKey mocks base method

func (*MockICryptoCurrency) GetTransferTx added in v1.0.0

func (m *MockICryptoCurrency) GetTransferTx(input *GetTransferTxInput) (*GetTransferTxOutput, error)

GetTransferTx mocks base method

func (*MockICryptoCurrency) GetTxBasicInfo added in v1.0.0

func (m *MockICryptoCurrency) GetTxBasicInfo(input *GetTxBasicInfoInput) (*GetTxBasicInfoOutput, error)

GetTxBasicInfo mocks base method

func (*MockICryptoCurrency) NewPrivateKey added in v1.0.0

func (m *MockICryptoCurrency) NewPrivateKey(input *NewPrivateKeyInput) (*NewPrivateKeyOutput, error)

NewPrivateKey mocks base method

func (*MockICryptoCurrency) SendTransaction added in v1.0.0

SendTransaction mocks base method

func (*MockICryptoCurrency) SignMessage added in v1.0.0

func (m *MockICryptoCurrency) SignMessage(input *SignMessageInput) (*SignMessageOutput, error)

SignMessage mocks base method

func (*MockICryptoCurrency) SignTransaction added in v1.0.0

SignTransaction mocks base method

func (*MockICryptoCurrency) VerifySignature added in v1.0.0

VerifySignature mocks base method

type MockICryptoCurrencyMockRecorder added in v1.0.0

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

MockICryptoCurrencyMockRecorder is the mock recorder for MockICryptoCurrency

func (*MockICryptoCurrencyMockRecorder) BindTxAndSignature added in v1.0.0

func (mr *MockICryptoCurrencyMockRecorder) BindTxAndSignature(input interface{}) *gomock.Call

BindTxAndSignature indicates an expected call of BindTxAndSignature

func (*MockICryptoCurrencyMockRecorder) CalcTxHash added in v1.0.0

func (mr *MockICryptoCurrencyMockRecorder) CalcTxHash(input interface{}) *gomock.Call

CalcTxHash indicates an expected call of CalcTxHash

func (*MockICryptoCurrencyMockRecorder) CreateMultiSigAddress added in v1.0.0

func (mr *MockICryptoCurrencyMockRecorder) CreateMultiSigAddress(input interface{}) *gomock.Call

CreateMultiSigAddress indicates an expected call of CreateMultiSigAddress

func (*MockICryptoCurrencyMockRecorder) CreateTransferTokenTx added in v1.0.0

func (mr *MockICryptoCurrencyMockRecorder) CreateTransferTokenTx(input interface{}) *gomock.Call

CreateTransferTokenTx indicates an expected call of CreateTransferTokenTx

func (*MockICryptoCurrencyMockRecorder) GetAddrTxHistory added in v1.0.0

func (mr *MockICryptoCurrencyMockRecorder) GetAddrTxHistory(input interface{}) *gomock.Call

GetAddrTxHistory indicates an expected call of GetAddrTxHistory

func (*MockICryptoCurrencyMockRecorder) GetAddress added in v1.0.0

func (mr *MockICryptoCurrencyMockRecorder) GetAddress(key interface{}) *gomock.Call

GetAddress indicates an expected call of GetAddress

func (*MockICryptoCurrencyMockRecorder) GetAssetDecimal added in v1.0.0

func (mr *MockICryptoCurrencyMockRecorder) GetAssetDecimal(asset interface{}) *gomock.Call

GetAssetDecimal indicates an expected call of GetAssetDecimal

func (*MockICryptoCurrencyMockRecorder) GetBalance added in v1.0.0

func (mr *MockICryptoCurrencyMockRecorder) GetBalance(input interface{}) *gomock.Call

GetBalance indicates an expected call of GetBalance

func (*MockICryptoCurrencyMockRecorder) GetBlockInfo added in v1.0.0

func (mr *MockICryptoCurrencyMockRecorder) GetBlockInfo(input interface{}) *gomock.Call

GetBlockInfo indicates an expected call of GetBlockInfo

func (*MockICryptoCurrencyMockRecorder) GetPalletOneMappingAddress added in v1.0.0

func (mr *MockICryptoCurrencyMockRecorder) GetPalletOneMappingAddress(addr interface{}) *gomock.Call

GetPalletOneMappingAddress indicates an expected call of GetPalletOneMappingAddress

func (*MockICryptoCurrencyMockRecorder) GetPublicKey added in v1.0.0

func (mr *MockICryptoCurrencyMockRecorder) GetPublicKey(input interface{}) *gomock.Call

GetPublicKey indicates an expected call of GetPublicKey

func (*MockICryptoCurrencyMockRecorder) GetTransferTx added in v1.0.0

func (mr *MockICryptoCurrencyMockRecorder) GetTransferTx(input interface{}) *gomock.Call

GetTransferTx indicates an expected call of GetTransferTx

func (*MockICryptoCurrencyMockRecorder) GetTxBasicInfo added in v1.0.0

func (mr *MockICryptoCurrencyMockRecorder) GetTxBasicInfo(input interface{}) *gomock.Call

GetTxBasicInfo indicates an expected call of GetTxBasicInfo

func (*MockICryptoCurrencyMockRecorder) NewPrivateKey added in v1.0.0

func (mr *MockICryptoCurrencyMockRecorder) NewPrivateKey(input interface{}) *gomock.Call

NewPrivateKey indicates an expected call of NewPrivateKey

func (*MockICryptoCurrencyMockRecorder) SendTransaction added in v1.0.0

func (mr *MockICryptoCurrencyMockRecorder) SendTransaction(input interface{}) *gomock.Call

SendTransaction indicates an expected call of SendTransaction

func (*MockICryptoCurrencyMockRecorder) SignMessage added in v1.0.0

func (mr *MockICryptoCurrencyMockRecorder) SignMessage(input interface{}) *gomock.Call

SignMessage indicates an expected call of SignMessage

func (*MockICryptoCurrencyMockRecorder) SignTransaction added in v1.0.0

func (mr *MockICryptoCurrencyMockRecorder) SignTransaction(input interface{}) *gomock.Call

SignTransaction indicates an expected call of SignTransaction

func (*MockICryptoCurrencyMockRecorder) VerifySignature added in v1.0.0

func (mr *MockICryptoCurrencyMockRecorder) VerifySignature(input interface{}) *gomock.Call

VerifySignature indicates an expected call of VerifySignature

type MockISmartContract added in v1.0.0

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

MockISmartContract is a mock of ISmartContract interface

func NewMockISmartContract added in v1.0.0

func NewMockISmartContract(ctrl *gomock.Controller) *MockISmartContract

NewMockISmartContract creates a new mock instance

func (*MockISmartContract) BindTxAndSignature added in v1.0.0

BindTxAndSignature mocks base method

func (*MockISmartContract) CalcTxHash added in v1.0.0

func (m *MockISmartContract) CalcTxHash(input *CalcTxHashInput) (*CalcTxHashOutput, error)

CalcTxHash mocks base method

func (*MockISmartContract) CreateContractInitialTx added in v1.0.0

CreateContractInitialTx mocks base method

func (*MockISmartContract) CreateContractInstallTx added in v1.0.0

CreateContractInstallTx mocks base method

func (*MockISmartContract) CreateContractInvokeTx added in v1.0.0

CreateContractInvokeTx mocks base method

func (*MockISmartContract) EXPECT added in v1.0.0

EXPECT returns an object that allows the caller to indicate expected use

func (*MockISmartContract) GetAddress added in v1.0.0

func (m *MockISmartContract) GetAddress(key *GetAddressInput) (*GetAddressOutput, error)

GetAddress mocks base method

func (*MockISmartContract) GetBlockInfo added in v1.0.0

func (m *MockISmartContract) GetBlockInfo(input *GetBlockInfoInput) (*GetBlockInfoOutput, error)

GetBlockInfo mocks base method

func (*MockISmartContract) GetContractInitialTx added in v1.0.0

GetContractInitialTx mocks base method

func (*MockISmartContract) GetContractInstallTx added in v1.0.0

GetContractInstallTx mocks base method

func (*MockISmartContract) GetContractInvokeTx added in v1.0.0

GetContractInvokeTx mocks base method

func (*MockISmartContract) GetPalletOneMappingAddress added in v1.0.0

GetPalletOneMappingAddress mocks base method

func (*MockISmartContract) GetPublicKey added in v1.0.0

func (m *MockISmartContract) GetPublicKey(input *GetPublicKeyInput) (*GetPublicKeyOutput, error)

GetPublicKey mocks base method

func (*MockISmartContract) GetTxBasicInfo added in v1.0.0

func (m *MockISmartContract) GetTxBasicInfo(input *GetTxBasicInfoInput) (*GetTxBasicInfoOutput, error)

GetTxBasicInfo mocks base method

func (*MockISmartContract) NewPrivateKey added in v1.0.0

func (m *MockISmartContract) NewPrivateKey(input *NewPrivateKeyInput) (*NewPrivateKeyOutput, error)

NewPrivateKey mocks base method

func (*MockISmartContract) QueryContract added in v1.0.0

func (m *MockISmartContract) QueryContract(input *QueryContractInput) (*QueryContractOutput, error)

QueryContract mocks base method

func (*MockISmartContract) SendTransaction added in v1.0.0

func (m *MockISmartContract) SendTransaction(input *SendTransactionInput) (*SendTransactionOutput, error)

SendTransaction mocks base method

func (*MockISmartContract) SignMessage added in v1.0.0

func (m *MockISmartContract) SignMessage(input *SignMessageInput) (*SignMessageOutput, error)

SignMessage mocks base method

func (*MockISmartContract) SignTransaction added in v1.0.0

func (m *MockISmartContract) SignTransaction(input *SignTransactionInput) (*SignTransactionOutput, error)

SignTransaction mocks base method

func (*MockISmartContract) VerifySignature added in v1.0.0

func (m *MockISmartContract) VerifySignature(input *VerifySignatureInput) (*VerifySignatureOutput, error)

VerifySignature mocks base method

type MockISmartContractMockRecorder added in v1.0.0

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

MockISmartContractMockRecorder is the mock recorder for MockISmartContract

func (*MockISmartContractMockRecorder) BindTxAndSignature added in v1.0.0

func (mr *MockISmartContractMockRecorder) BindTxAndSignature(input interface{}) *gomock.Call

BindTxAndSignature indicates an expected call of BindTxAndSignature

func (*MockISmartContractMockRecorder) CalcTxHash added in v1.0.0

func (mr *MockISmartContractMockRecorder) CalcTxHash(input interface{}) *gomock.Call

CalcTxHash indicates an expected call of CalcTxHash

func (*MockISmartContractMockRecorder) CreateContractInitialTx added in v1.0.0

func (mr *MockISmartContractMockRecorder) CreateContractInitialTx(input interface{}) *gomock.Call

CreateContractInitialTx indicates an expected call of CreateContractInitialTx

func (*MockISmartContractMockRecorder) CreateContractInstallTx added in v1.0.0

func (mr *MockISmartContractMockRecorder) CreateContractInstallTx(input interface{}) *gomock.Call

CreateContractInstallTx indicates an expected call of CreateContractInstallTx

func (*MockISmartContractMockRecorder) CreateContractInvokeTx added in v1.0.0

func (mr *MockISmartContractMockRecorder) CreateContractInvokeTx(input interface{}) *gomock.Call

CreateContractInvokeTx indicates an expected call of CreateContractInvokeTx

func (*MockISmartContractMockRecorder) GetAddress added in v1.0.0

func (mr *MockISmartContractMockRecorder) GetAddress(key interface{}) *gomock.Call

GetAddress indicates an expected call of GetAddress

func (*MockISmartContractMockRecorder) GetBlockInfo added in v1.0.0

func (mr *MockISmartContractMockRecorder) GetBlockInfo(input interface{}) *gomock.Call

GetBlockInfo indicates an expected call of GetBlockInfo

func (*MockISmartContractMockRecorder) GetContractInitialTx added in v1.0.0

func (mr *MockISmartContractMockRecorder) GetContractInitialTx(input interface{}) *gomock.Call

GetContractInitialTx indicates an expected call of GetContractInitialTx

func (*MockISmartContractMockRecorder) GetContractInstallTx added in v1.0.0

func (mr *MockISmartContractMockRecorder) GetContractInstallTx(input interface{}) *gomock.Call

GetContractInstallTx indicates an expected call of GetContractInstallTx

func (*MockISmartContractMockRecorder) GetContractInvokeTx added in v1.0.0

func (mr *MockISmartContractMockRecorder) GetContractInvokeTx(input interface{}) *gomock.Call

GetContractInvokeTx indicates an expected call of GetContractInvokeTx

func (*MockISmartContractMockRecorder) GetPalletOneMappingAddress added in v1.0.0

func (mr *MockISmartContractMockRecorder) GetPalletOneMappingAddress(addr interface{}) *gomock.Call

GetPalletOneMappingAddress indicates an expected call of GetPalletOneMappingAddress

func (*MockISmartContractMockRecorder) GetPublicKey added in v1.0.0

func (mr *MockISmartContractMockRecorder) GetPublicKey(input interface{}) *gomock.Call

GetPublicKey indicates an expected call of GetPublicKey

func (*MockISmartContractMockRecorder) GetTxBasicInfo added in v1.0.0

func (mr *MockISmartContractMockRecorder) GetTxBasicInfo(input interface{}) *gomock.Call

GetTxBasicInfo indicates an expected call of GetTxBasicInfo

func (*MockISmartContractMockRecorder) NewPrivateKey added in v1.0.0

func (mr *MockISmartContractMockRecorder) NewPrivateKey(input interface{}) *gomock.Call

NewPrivateKey indicates an expected call of NewPrivateKey

func (*MockISmartContractMockRecorder) QueryContract added in v1.0.0

func (mr *MockISmartContractMockRecorder) QueryContract(input interface{}) *gomock.Call

QueryContract indicates an expected call of QueryContract

func (*MockISmartContractMockRecorder) SendTransaction added in v1.0.0

func (mr *MockISmartContractMockRecorder) SendTransaction(input interface{}) *gomock.Call

SendTransaction indicates an expected call of SendTransaction

func (*MockISmartContractMockRecorder) SignMessage added in v1.0.0

func (mr *MockISmartContractMockRecorder) SignMessage(input interface{}) *gomock.Call

SignMessage indicates an expected call of SignMessage

func (*MockISmartContractMockRecorder) SignTransaction added in v1.0.0

func (mr *MockISmartContractMockRecorder) SignTransaction(input interface{}) *gomock.Call

SignTransaction indicates an expected call of SignTransaction

func (*MockISmartContractMockRecorder) VerifySignature added in v1.0.0

func (mr *MockISmartContractMockRecorder) VerifySignature(input interface{}) *gomock.Call

VerifySignature indicates an expected call of VerifySignature

type MockIUtility added in v1.0.0

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

MockIUtility is a mock of IUtility interface

func NewMockIUtility added in v1.0.0

func NewMockIUtility(ctrl *gomock.Controller) *MockIUtility

NewMockIUtility creates a new mock instance

func (*MockIUtility) BindTxAndSignature added in v1.0.0

func (m *MockIUtility) BindTxAndSignature(input *BindTxAndSignatureInput) (*BindTxAndSignatureOutput, error)

BindTxAndSignature mocks base method

func (*MockIUtility) CalcTxHash added in v1.0.0

func (m *MockIUtility) CalcTxHash(input *CalcTxHashInput) (*CalcTxHashOutput, error)

CalcTxHash mocks base method

func (*MockIUtility) EXPECT added in v1.0.0

EXPECT returns an object that allows the caller to indicate expected use

func (*MockIUtility) GetAddress added in v1.0.0

func (m *MockIUtility) GetAddress(key *GetAddressInput) (*GetAddressOutput, error)

GetAddress mocks base method

func (*MockIUtility) GetBlockInfo added in v1.0.0

func (m *MockIUtility) GetBlockInfo(input *GetBlockInfoInput) (*GetBlockInfoOutput, error)

GetBlockInfo mocks base method

func (*MockIUtility) GetPalletOneMappingAddress added in v1.0.0

GetPalletOneMappingAddress mocks base method

func (*MockIUtility) GetPublicKey added in v1.0.0

func (m *MockIUtility) GetPublicKey(input *GetPublicKeyInput) (*GetPublicKeyOutput, error)

GetPublicKey mocks base method

func (*MockIUtility) GetTxBasicInfo added in v1.0.0

func (m *MockIUtility) GetTxBasicInfo(input *GetTxBasicInfoInput) (*GetTxBasicInfoOutput, error)

GetTxBasicInfo mocks base method

func (*MockIUtility) NewPrivateKey added in v1.0.0

func (m *MockIUtility) NewPrivateKey(input *NewPrivateKeyInput) (*NewPrivateKeyOutput, error)

NewPrivateKey mocks base method

func (*MockIUtility) SendTransaction added in v1.0.0

func (m *MockIUtility) SendTransaction(input *SendTransactionInput) (*SendTransactionOutput, error)

SendTransaction mocks base method

func (*MockIUtility) SignMessage added in v1.0.0

func (m *MockIUtility) SignMessage(input *SignMessageInput) (*SignMessageOutput, error)

SignMessage mocks base method

func (*MockIUtility) SignTransaction added in v1.0.0

func (m *MockIUtility) SignTransaction(input *SignTransactionInput) (*SignTransactionOutput, error)

SignTransaction mocks base method

func (*MockIUtility) VerifySignature added in v1.0.0

func (m *MockIUtility) VerifySignature(input *VerifySignatureInput) (*VerifySignatureOutput, error)

VerifySignature mocks base method

type MockIUtilityMockRecorder added in v1.0.0

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

MockIUtilityMockRecorder is the mock recorder for MockIUtility

func (*MockIUtilityMockRecorder) BindTxAndSignature added in v1.0.0

func (mr *MockIUtilityMockRecorder) BindTxAndSignature(input interface{}) *gomock.Call

BindTxAndSignature indicates an expected call of BindTxAndSignature

func (*MockIUtilityMockRecorder) CalcTxHash added in v1.0.0

func (mr *MockIUtilityMockRecorder) CalcTxHash(input interface{}) *gomock.Call

CalcTxHash indicates an expected call of CalcTxHash

func (*MockIUtilityMockRecorder) GetAddress added in v1.0.0

func (mr *MockIUtilityMockRecorder) GetAddress(key interface{}) *gomock.Call

GetAddress indicates an expected call of GetAddress

func (*MockIUtilityMockRecorder) GetBlockInfo added in v1.0.0

func (mr *MockIUtilityMockRecorder) GetBlockInfo(input interface{}) *gomock.Call

GetBlockInfo indicates an expected call of GetBlockInfo

func (*MockIUtilityMockRecorder) GetPalletOneMappingAddress added in v1.0.0

func (mr *MockIUtilityMockRecorder) GetPalletOneMappingAddress(addr interface{}) *gomock.Call

GetPalletOneMappingAddress indicates an expected call of GetPalletOneMappingAddress

func (*MockIUtilityMockRecorder) GetPublicKey added in v1.0.0

func (mr *MockIUtilityMockRecorder) GetPublicKey(input interface{}) *gomock.Call

GetPublicKey indicates an expected call of GetPublicKey

func (*MockIUtilityMockRecorder) GetTxBasicInfo added in v1.0.0

func (mr *MockIUtilityMockRecorder) GetTxBasicInfo(input interface{}) *gomock.Call

GetTxBasicInfo indicates an expected call of GetTxBasicInfo

func (*MockIUtilityMockRecorder) NewPrivateKey added in v1.0.0

func (mr *MockIUtilityMockRecorder) NewPrivateKey(input interface{}) *gomock.Call

NewPrivateKey indicates an expected call of NewPrivateKey

func (*MockIUtilityMockRecorder) SendTransaction added in v1.0.0

func (mr *MockIUtilityMockRecorder) SendTransaction(input interface{}) *gomock.Call

SendTransaction indicates an expected call of SendTransaction

func (*MockIUtilityMockRecorder) SignMessage added in v1.0.0

func (mr *MockIUtilityMockRecorder) SignMessage(input interface{}) *gomock.Call

SignMessage indicates an expected call of SignMessage

func (*MockIUtilityMockRecorder) SignTransaction added in v1.0.0

func (mr *MockIUtilityMockRecorder) SignTransaction(input interface{}) *gomock.Call

SignTransaction indicates an expected call of SignTransaction

func (*MockIUtilityMockRecorder) VerifySignature added in v1.0.0

func (mr *MockIUtilityMockRecorder) VerifySignature(input interface{}) *gomock.Call

VerifySignature indicates an expected call of VerifySignature

type NewPrivateKeyInput added in v1.0.0

type NewPrivateKeyInput struct {
	//随机数的种子,如果不指定,则使用默认实现
	RandomSeed []byte `json:"random_seed"`
	Extra      []byte `json:"extra"`
}

type NewPrivateKeyOutput added in v1.0.0

type NewPrivateKeyOutput struct {
	PrivateKey []byte `json:"private_key"`
	Extra      []byte `json:"extra"`
}

type QueryContractInput added in v1.0.0

type QueryContractInput struct {
	//合约查询的发起方
	Address string `json:"address"`
	////查询合约支付的手续费
	//Fee             *AmountAsset `json:"fee"`
	//查询的合约地址
	ContractAddress string `json:"contract_address"`
	//合约的查询函数
	Function string `json:"function"`
	//查询参数
	Args  [][]byte `json:"args"`
	Extra []byte   `json:"extra"`
}

type QueryContractOutput added in v1.0.0

type QueryContractOutput struct {
	QueryResult []byte `json:"query_result"`
	Extra       []byte `json:"extra"`
}

type SendTransactionInput added in v1.0.0

type SendTransactionInput struct {
	Transaction []byte       `json:"transaction"`
	Fee         *AmountAsset `json:"fee"`
	Extra       []byte       `json:"extra"`
}

type SendTransactionOutput added in v1.0.0

type SendTransactionOutput struct {
	TxID  []byte `json:"tx_id"`
	Extra []byte `json:"extra"`
}

type SignMessageInput added in v1.0.0

type SignMessageInput struct {
	PrivateKey []byte `json:"private_key"`
	Message    []byte `json:"message"`
	Extra      []byte `json:"extra"`
}

type SignMessageOutput added in v1.0.0

type SignMessageOutput struct {
	Signature []byte `json:"signature"`
	Extra     []byte `json:"extra"`
}

type SignTransactionInput added in v1.0.0

type SignTransactionInput struct {
	PrivateKey  []byte `json:"private_key"`
	Transaction []byte `json:"transaction"`
	//BTC: 如果Input只有1个,那么可以为空,如果是多个,那么必须使用Extra指定InputIndex
	Extra []byte `json:"extra"`
}

type SignTransactionOutput added in v1.0.0

type SignTransactionOutput struct {
	Signature []byte `json:"signature"`
	SignedTx  []byte `json:"signed_tx"`
	//BTC: 与Input的Extra相同
	Extra []byte `json:"extra"`
}

type SimpleTransferTokenTx added in v1.0.0

type SimpleTransferTokenTx struct {
	TxBasicInfo
	FromAddress string       `json:"from_address"` //转出地址
	ToAddress   string       `json:"to_address"`   //转入地址
	Amount      *AmountAsset `json:"amount"`       //转账金额
	Fee         *AmountAsset `json:"fee"`          //转账交易费
	AttachData  []byte       `json:"attach_data"`  //附加的数据(备注之类的)
}

SimpleTransferTokenTx 一个简单的Token转账交易

func (*SimpleTransferTokenTx) MarshalJSON added in v1.0.0

func (tx *SimpleTransferTokenTx) MarshalJSON() ([]byte, error)

func (*SimpleTransferTokenTx) String added in v1.0.0

func (tx *SimpleTransferTokenTx) String() string

func (*SimpleTransferTokenTx) UnmarshalJSON added in v1.0.0

func (tx *SimpleTransferTokenTx) UnmarshalJSON(input []byte) error

type TxBasicInfo added in v1.0.0

type TxBasicInfo struct {
	TxID           []byte `json:"tx_id"`           //交易的ID,Hash
	TxRawData      []byte `json:"tx_raw"`          //交易的二进制数据
	CreatorAddress string `json:"creator_address"` //交易的发起人
	TargetAddress  string `json:"target_address"`  //交易的目标地址(被调用的合约、收款人)
	IsInBlock      bool   `json:"is_in_block"`     //是否已经被打包到区块链中
	IsSuccess      bool   `json:"is_success"`      //是被标记为成功执行
	IsStable       bool   `json:"is_stable"`       //是否已经稳定不可逆
	BlockID        []byte `json:"block_id"`        //交易被打包到了哪个区块ID
	BlockHeight    uint   `json:"block_height"`    //交易被打包到的区块的高度
	TxIndex        uint   `json:"tx_index"`        //Tx在区块中的位置
	Timestamp      uint64 `json:"timestamp"`       //交易被打包的时间戳
}

TxBasicInfo 一个交易的基本信息

func (*TxBasicInfo) MarshalJSON added in v1.0.0

func (tx *TxBasicInfo) MarshalJSON() ([]byte, error)

func (*TxBasicInfo) String added in v1.0.0

func (tx *TxBasicInfo) String() string

func (*TxBasicInfo) UnmarshalJSON added in v1.0.0

func (tx *TxBasicInfo) UnmarshalJSON(input []byte) error

type VerifySignatureInput added in v1.0.0

type VerifySignatureInput struct {
	Message   []byte `json:"message"`
	Signature []byte `json:"signature"`
	PublicKey []byte `json:"public_key"`
	Extra     []byte `json:"extra"`
}

type VerifySignatureOutput added in v1.0.0

type VerifySignatureOutput struct {
	Pass  bool   `json:"pass"`
	Extra []byte `json:"extra"`
}

Jump to

Keyboard shortcuts

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