func (a *CallerAPI) AddAccount(
	name string,
	judge []byte,
	pubkey []byte,
	privkey []byte,
) error {
	return a.DB.Update(func(tx *bolt.Tx) error {
		jd, err := access.GetJudge(tx, judge)
		if err != nil {
			return err
		}

		acct := &core.Account{
			Name:    name,
			Judge:   jd,
			Pubkey:  pubkey,
			Privkey: privkey,
		}

		err = access.SetAccount(tx, acct)
		if err != nil {
			return err
		}

		return nil
	})
}
func (a *CallerAPI) AddCounterparty(
	name string,
	judge []byte,
	pubkey []byte,
	address string,
) error {
	return a.DB.Update(func(tx *bolt.Tx) error {
		jd, err := access.GetJudge(tx, judge)
		if err != nil {
			return err
		}

		cpt := &core.Counterparty{
			Name:    name,
			Judge:   jd,
			Pubkey:  pubkey,
			Address: address,
		}

		err = access.SetCounterparty(tx, cpt)
		if err != nil {
			return err
		}

		return nil
	})
}
func (a *CallerAPI) NewAccount(
	name string,
	judge []byte,
) (*core.Account, error) {
	var err error
	acct := &core.Account{}
	err = a.DB.Update(func(tx *bolt.Tx) error {
		jd, err := access.GetJudge(tx, judge)
		if err != nil {
			return err
		}

		acct, err = core.NewAccount(name, jd)
		if err != nil {
			return err
		}
		err = access.SetAccount(tx, acct)
		if err != nil {
			return err
		}

		return nil
	})
	if err != nil {
		return nil, err
	}

	return acct, nil
}