}
// annotateTxs adds account data to transactions
-func annotateTxsAccount(txs []*query.AnnotatedTx, store WalletStore) {
+func (w *Wallet) annotateTxsAccount(txs []*query.AnnotatedTx) {
for i, tx := range txs {
for j, input := range tx.Inputs {
//issue asset tx input SpentOutputID is nil
if input.SpentOutputID == nil {
continue
}
- localAccount, err := getAccountFromACP(input.ControlProgram, store)
+ localAccount, err := w.getAccountFromACP(input.ControlProgram)
if localAccount == nil || err != nil {
continue
}
txs[i].Inputs[j].AccountID = localAccount.ID
}
for j, output := range tx.Outputs {
- localAccount, err := getAccountFromACP(output.ControlProgram, store)
+ localAccount, err := w.getAccountFromACP(output.ControlProgram)
if localAccount == nil || err != nil {
continue
}
}
}
-func getAccountFromACP(program []byte, store WalletStore) (*account.Account, error) {
+func (w *Wallet) getAccountFromACP(program []byte) (*account.Account, error) {
var hash [32]byte
sha3pool.Sum256(hash[:], program)
- accountCP, err := store.GetControlProgram(bc.NewHash(hash))
+ accountCP, err := w.store.GetControlProgram(bc.NewHash(hash))
if err != nil {
return nil, err
}
- account, err := store.GetAccount(accountCP.AccountID)
+ account, err := w.AccountMgr.FindByID(accountCP.AccountID)
if err != nil {
return nil, err
}
+
return account, nil
}
annotatedTx := w.buildAnnotatedUnconfirmedTx(tx)
annotatedTxs := []*query.AnnotatedTx{}
annotatedTxs = append(annotatedTxs, annotatedTx)
- annotateTxsAccount(annotatedTxs, w.store)
+ w.annotateTxsAccount(annotatedTxs)
if err := w.store.SetUnconfirmedTransaction(tx.ID.String(), annotatedTxs[0]); err != nil {
return err
if err := saveExternalAssetDefinition(block, w.store); err != nil {
return err
}
- annotateTxsAccount(annotatedTxs, w.store)
+ w.annotateTxsAccount(annotatedTxs)
if err := w.store.InitBatch(); err != nil {
return err