From bb5c5f859f73f3052957f1797b173dafca33ebff Mon Sep 17 00:00:00 2001 From: studyzy Date: Tue, 26 Nov 2019 18:24:29 +0800 Subject: [PATCH] Upgrade adaptor interface --- ICryptoCurrency.go | 16 ++++++++++++++++ ISmartContract.go | 36 ++++++++++++++++++++++++------------ IUtility.go | 32 ++++++++++++++++++++++++++------ 3 files changed, 66 insertions(+), 18 deletions(-) diff --git a/ICryptoCurrency.go b/ICryptoCurrency.go index 6924f72..34c7bed 100644 --- a/ICryptoCurrency.go +++ b/ICryptoCurrency.go @@ -35,6 +35,8 @@ type ICryptoCurrency interface { GetTransferTx(input *GetTransferTxInput) (*GetTransferTxOutput, error) //创建一个多签地址,该地址必须要满足signCount个签名才能解锁 CreateMultiSigAddress(input *CreateMultiSigAddressInput) (*CreateMultiSigAddressOutput, error) + //构造一个从多签地址付出Token的交易 + CreateMultiSigPayoutTx(input *CreateMultiSigPayoutTxInput) (*CreateMultiSigPayoutTxOutput, error) } //查询余额时的输入参数 @@ -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"` +} diff --git a/ISmartContract.go b/ISmartContract.go index 5259f78..923496d 100644 --- a/ISmartContract.go +++ b/ISmartContract.go @@ -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"` diff --git a/IUtility.go b/IUtility.go index 723c3d2..6a6d5c3 100644 --- a/IUtility.go +++ b/IUtility.go @@ -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) //对签名进行验证 @@ -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"` @@ -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"` @@ -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"`