Golang implemented sidechain for Bytom
Revision | c2d610da0dd5cea754e66f8f2b2a3d02125bc97b (tree) |
---|---|
Time | 2019-05-23 00:58:52 |
Author | Chengcheng Zhang <943420582@qq.c...> |
Commiter | Chengcheng Zhang |
update
@@ -122,6 +122,32 @@ type Manager struct { | ||
122 | 122 | accountMu sync.Mutex |
123 | 123 | } |
124 | 124 | |
125 | +type EdSigner struct { | |
126 | + Type string `json:"type"` | |
127 | + XPubs []edchainkd.XPub `json:"xpubs"` | |
128 | + Quorum int `json:"quorum"` | |
129 | + KeyIndex uint64 `json:"key_index"` | |
130 | + DeriveRule uint8 `json:"derive_rule"` | |
131 | +} | |
132 | + | |
133 | +type EdAccount struct { | |
134 | + *EdSigner | |
135 | + ID string `json:"id"` | |
136 | + Alias string `json:"alias"` | |
137 | +} | |
138 | + | |
139 | +// func (account *Account) UnmarshalJSON(b []byte) error { | |
140 | +// edAccount := new(EdAccount) | |
141 | +// if err := json.Unmarshal(b, edAccount); err != nil { | |
142 | +// return err | |
143 | +// } | |
144 | + | |
145 | +// account.Type = edAccount.Type | |
146 | +// switch xpubs := acc | |
147 | +// account.XPubs{edAccount.XPubs} | |
148 | +// return nil | |
149 | +// } | |
150 | + | |
125 | 151 | // NewManager creates a new account manager |
126 | 152 | func NewManager(walletDB dbm.DB, chain *protocol.Chain) *Manager { |
127 | 153 | return &Manager{ |
@@ -155,7 +181,7 @@ func CreateAccount(xpubs []crypto.XPubKeyer, quorum int, alias string, acctIndex | ||
155 | 181 | } |
156 | 182 | |
157 | 183 | func (m *Manager) saveAccount(account *Account, updateIndex bool) error { |
158 | - fmt.Println("account.XPubs is:", account.XPubs) | |
184 | + fmt.Println("saveAccount account.XPubs is:", account) | |
159 | 185 | rawAccount, err := json.Marshal(account) |
160 | 186 | /////// |
161 | 187 | fmt.Println("rawaccount is:", rawAccount) |
@@ -60,3 +60,8 @@ func (xprv *XPrv) UnmarshalText(inp []byte) error { | ||
60 | 60 | func (xprv XPrv) String() string { |
61 | 61 | return hex.EncodeToString(xprv.Bytes()) |
62 | 62 | } |
63 | + | |
64 | +// func (xpub *XPub) UnmarshalJSON(b []byte) error { | |
65 | + | |
66 | +// return nil | |
67 | +// } |