Skip to content

Commit

Permalink
Upgrade adaptor interface
Browse files Browse the repository at this point in the history
  • Loading branch information
studyzy committed Nov 26, 2019
1 parent a034d9c commit bb5c5f8
Show file tree
Hide file tree
Showing 3 changed files with 66 additions and 18 deletions.
16 changes: 16 additions & 0 deletions ICryptoCurrency.go
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,8 @@ type ICryptoCurrency interface {
GetTransferTx(input *GetTransferTxInput) (*GetTransferTxOutput, error)
//创建一个多签地址,该地址必须要满足signCount个签名才能解锁
CreateMultiSigAddress(input *CreateMultiSigAddressInput) (*CreateMultiSigAddressOutput, error)
//构造一个从多签地址付出Token的交易
CreateMultiSigPayoutTx(input *CreateMultiSigPayoutTxInput) (*CreateMultiSigPayoutTxOutput, error)
}

//查询余额时的输入参数
Expand Down Expand Up @@ -104,3 +106,17 @@ type GetTransferTxOutput struct {
Tx SimpleTransferTokenTx `json:"transaction"`
Extra []byte `json:"extra"`
}
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 struct {
Transaction []byte `json:"transaction"`
//本交易包含的UTXO
Extra []byte `json:"extra"`
}
36 changes: 24 additions & 12 deletions ISmartContract.go
Original file line number Diff line number Diff line change
Expand Up @@ -63,24 +63,36 @@ type CreateContractInitialTxOutput struct {
Extra []byte `json:"extra"`
}
type CreateContractInvokeTxInput 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"`
//合约调用的发起方地址
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 struct {
RawTransaction []byte `json:"raw_transaction"`
Extra []byte `json:"extra"`
}
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"`
//合约查询的发起方
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 struct {
QueryResult []byte `json:"query_result"`
Expand Down
32 changes: 26 additions & 6 deletions IUtility.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,8 @@ type IUtility interface {
GetAddress(key *GetAddressInput) (*GetAddressOutput, error)
//获得原链的地址和PalletOne的地址的映射
GetPalletOneMappingAddress(addr *GetPalletOneMappingAddressInput) (*GetPalletOneMappingAddressOutput, error)
//计算一条消息的Hash值
HashMessage(input *HashMessageInput) (*HashMessageOutput, error)
//对一条消息进行签名
SignMessage(input *SignMessageInput) (*SignMessageOutput, error)
//对签名进行验证
Expand All @@ -48,7 +50,9 @@ type IUtility interface {
GetBlockInfo(input *GetBlockInfoInput) (*GetBlockInfoOutput, error)
}
type NewPrivateKeyInput struct {
Extra []byte `json:"extra"`
//随机数的种子,如果不指定,则使用默认实现
RandomSeed []byte `json:"random_seed"`
Extra []byte `json:"extra"`
}
type NewPrivateKeyOutput struct {
PrivateKey []byte `json:"private_key"`
Expand Down Expand Up @@ -81,6 +85,14 @@ type GetPalletOneMappingAddressOutput struct {
ChainAddress string `json:"chain_address"`
Extra []byte `json:"extra"`
}
type HashMessageInput struct {
Message []byte `json:"message"`
Extra []byte `json:"extra"`
}
type HashMessageOutput struct {
Hash []byte `json:"hash"`
Extra []byte `json:"extra"`
}
type SignMessageInput struct {
PrivateKey []byte `json:"private_key"`
Message []byte `json:"message"`
Expand All @@ -103,16 +115,24 @@ type VerifySignatureOutput struct {
type SignTransactionInput struct {
PrivateKey []byte `json:"private_key"`
Transaction []byte `json:"transaction"`
Extra []byte `json:"extra"`
//BTC: 如果Input只有1个,那么可以为空,如果是多个,那么必须使用Extra指定InputIndex
Extra []byte `json:"extra"`
}
type SignTransactionOutput struct {
Signature []byte `json:"signature"`
Extra []byte `json:"extra"`
SignedTx []byte `json:"signed_tx"`
//BTC: 与Input的Extra相同
Extra []byte `json:"extra"`
}
type BindTxAndSignatureInput struct {
Transaction []byte `json:"transaction"`
Signs [][]byte `json:"signs"`
Extra []byte `json:"extra"`
//未签名的交易
Transaction []byte `json:"transaction"`
//多个签名
Signatures [][]byte `json:"signatures"`
SignedTxs [][]byte `json:"signed_txs"`
//BTC:如果是单签地址付出,那么Extra是公钥,如果是多签地址付出,那么Extra是RedeemScript
//ETH: 暂时用不到
Extra []byte `json:"extra"`
}
type BindTxAndSignatureOutput struct {
SignedTx []byte `json:"signed_tx"`
Expand Down

0 comments on commit bb5c5f8

Please sign in to comment.