+// GetAccountIndex get account index by account xpubs
+func (store *MockAccountStore) GetAccountIndex(xpubs []chainkd.XPub) uint64 {
+ currentIndex := uint64(0)
+ if rawIndexBytes := store.db.Get(accountIndexKey(xpubs)); rawIndexBytes != nil {
+ currentIndex = common.BytesToUnit64(rawIndexBytes)
+ }
+ return currentIndex
+}
+
+// GetBip44ContractIndex get bip44 contract index
+func (store *MockAccountStore) GetBip44ContractIndex(accountID string, change bool) uint64 {
+ index := uint64(0)
+ if rawIndexBytes := store.db.Get(Bip44ContractIndexKey(accountID, change)); rawIndexBytes != nil {
+ index = common.BytesToUnit64(rawIndexBytes)
+ }
+ return index
+}
+
+// GetCoinbaseArbitrary get coinbase arbitrary
+func (store *MockAccountStore) GetCoinbaseArbitrary() []byte {
+ return store.db.Get([]byte(CoinbaseAbKey))
+}
+
+// GetContractIndex get contract index
+func (store *MockAccountStore) GetContractIndex(accountID string) uint64 {
+ index := uint64(0)
+ if rawIndexBytes := store.db.Get(contractIndexKey(accountID)); rawIndexBytes != nil {
+ index = common.BytesToUnit64(rawIndexBytes)
+ }
+ return index
+}
+
+// GetControlProgram get control program
+func (store *MockAccountStore) GetControlProgram(hash bc.Hash) (*acc.CtrlProgram, error) {
+ rawProgram := store.db.Get(ContractKey(hash))
+ if rawProgram == nil {
+ return nil, acc.ErrFindCtrlProgram
+ }
+ cp := new(acc.CtrlProgram)
+ if err := json.Unmarshal(rawProgram, cp); err != nil {
+ return nil, err
+ }
+ return cp, nil
+}
+
+// GetMiningAddress get mining address
+func (store *MockAccountStore) GetMiningAddress() (*acc.CtrlProgram, error) {
+ rawCP := store.db.Get([]byte(MiningAddressKey))
+ if rawCP == nil {
+ return nil, acc.ErrFindMiningAddress
+ }
+ cp := new(acc.CtrlProgram)
+ if err := json.Unmarshal(rawCP, cp); err != nil {
+ return nil, err
+ }
+ return cp, nil
+}
+
+// GetUTXO get standard utxo by id
+func (store *MockAccountStore) GetUTXO(outid bc.Hash) (*acc.UTXO, error) {
+ u := new(acc.UTXO)
+ if data := store.db.Get(StandardUTXOKey(outid)); data != nil {
+ return u, json.Unmarshal(data, u)
+ }
+ if data := store.db.Get(ContractUTXOKey(outid)); data != nil {
+ return u, json.Unmarshal(data, u)
+ }
+ return nil, acc.ErrMatchUTXO
+}
+
+// ListAccounts get all accounts which name prfix is id.
+func (store *MockAccountStore) ListAccounts(id string) ([]*acc.Account, error) {
+ accounts := []*acc.Account{}
+ accountIter := store.db.IteratorPrefix(AccountIDKey(strings.TrimSpace(id)))
+ defer accountIter.Release()
+
+ for accountIter.Next() {
+ account := new(acc.Account)
+ if err := json.Unmarshal(accountIter.Value(), &account); err != nil {
+ return nil, err