diff --git a/pkg/wallet/account.go b/pkg/wallet/account.go index 9b87c2e8f..a503d4906 100644 --- a/pkg/wallet/account.go +++ b/pkg/wallet/account.go @@ -4,9 +4,11 @@ import ( "encoding/hex" "encoding/json" "errors" + "fmt" "github.com/CityOfZion/neo-go/pkg/crypto/hash" "github.com/CityOfZion/neo-go/pkg/crypto/keys" + "github.com/CityOfZion/neo-go/pkg/smartcontract" "github.com/CityOfZion/neo-go/pkg/util" ) @@ -50,7 +52,7 @@ type Contract struct { Script []byte `json:"script"` // A list of parameters used deploying this contract. - Parameters []interface{} `json:"parameters"` + Parameters []contractParam `json:"parameters"` // Indicates whether the contract has been deployed to the blockchain. Deployed bool `json:"deployed"` @@ -62,12 +64,17 @@ type contract struct { Script string `json:"script"` // A list of parameters used deploying this contract. - Parameters []interface{} `json:"parameters"` + Parameters []contractParam `json:"parameters"` // Indicates whether the contract has been deployed to the blockchain. Deployed bool `json:"deployed"` } +type contractParam struct { + Name string `json:"name"` + Type smartcontract.ParamType `json:"type"` +} + // ScriptHash returns the hash of contract's script. func (c Contract) ScriptHash() util.Uint160 { return hash.Hash160(c.Script) @@ -181,7 +188,21 @@ func newAccountFromPrivateKey(p *keys.PrivateKey) *Account { privateKey: p, Address: pubAddr, wif: wif, + Contract: &Contract{ + Script: pubKey.GetVerificationScript(), + Parameters: getContractParams(1), + }, } return a } + +func getContractParams(n int) []contractParam { + params := make([]contractParam, n) + for i := range params { + params[i].Name = fmt.Sprintf("parameter%d", i) + params[i].Type = smartcontract.SignatureType + } + + return params +} diff --git a/pkg/wallet/account_test.go b/pkg/wallet/account_test.go index 93847b991..f5e7db583 100644 --- a/pkg/wallet/account_test.go +++ b/pkg/wallet/account_test.go @@ -65,7 +65,7 @@ func TestNewAccountFromEncryptedWIF(t *testing.T) { func TestContract_MarshalJSON(t *testing.T) { var c Contract - data := []byte(`{"script":"0102","parameters":[1],"deployed":false}`) + data := []byte(`{"script":"0102","parameters":[{"name":"name0", "type":"Signature"}],"deployed":false}`) require.NoError(t, json.Unmarshal(data, &c)) require.Equal(t, []byte{1, 2}, c.Script)