func SetTicketAgendaPreference(dbtx walletdb.ReadWriteTx, txHash *chainhash.Hash, version uint32, agendaID, choiceID string) error {
	err := agendaPreferences.setTicketPreference(dbtx, txHash, version, agendaID, choiceID)
	if err != nil {
		return errors.E(errors.IO, err)
	}
	return nil
}
SetTicketAgendaPreference saves a ticket-specific agenda choice ID for an
agenda ID and deployment version.
package udb
import (
	"decred.org/dcrwallet/v2/errors"
	"decred.org/dcrwallet/v2/wallet/walletdb"
	"github.com/decred/dcrd/chaincfg/chainhash"
)
type agendaPreferencesTy struct {
}
var agendaPreferences agendaPreferencesTy
var (
	defaultAgendaPrefsBucketKey = []byte("agendaprefs")
	ticketsAgendaPrefsBucketKey = []byte("ticketsagendaprefs")
)
func (agendaPreferencesTy) key(version uint32, agendaID string) []byte {
	k := make([]byte, 4+len(agendaID))
	byteOrder.PutUint32(k, version)
	copy(k[4:], agendaID)
	return k
}
func (agendaPreferencesTy) defaultBucketKey() []byte { return defaultAgendaPrefsBucketKey }
func (agendaPreferencesTy) ticketsBucketKey() []byte { return ticketsAgendaPrefsBucketKey }
func (t agendaPreferencesTy) setDefaultPreference(tx walletdb.ReadWriteTx, version uint32, agendaID, choiceID string) error {
	b := tx.ReadWriteBucket(t.defaultBucketKey())
	return b.Put(t.key(version, agendaID), []byte(choiceID))
}
func (t agendaPreferencesTy) setTicketPreference(tx walletdb.ReadWriteTx, txHash *chainhash.Hash, version uint32, agendaID, choiceID string) error {
	b, err := tx.ReadWriteBucket(t.ticketsBucketKey()).CreateBucketIfNotExists(txHash[:])
	if err != nil {
		return err
	}
	return b.Put(t.key(version, agendaID), []byte(choiceID))
}
func (t agendaPreferencesTy) defaultPreference(dbtx walletdb.ReadTx, version uint32, agendaID string) (choiceID string) {
	b := dbtx.ReadBucket(t.defaultBucketKey())
	v := b.Get(t.key(version, agendaID))
	return string(v)
}
func (t agendaPreferencesTy) ticketPreference(dbtx walletdb.ReadTx, ticketHash *chainhash.Hash, version uint32, agendaID string) (choiceID string) {
	ticketBucket := dbtx.ReadBucket(t.ticketsBucketKey()).NestedReadBucket(ticketHash[:])
	if ticketBucket == nil {
		return ""
	}
	v := ticketBucket.Get(t.key(version, agendaID))
	return string(v)
}
func SetDefaultAgendaPreference(dbtx walletdb.ReadWriteTx, version uint32, agendaID, choiceID string) error {
	err := agendaPreferences.setDefaultPreference(dbtx, version, agendaID, choiceID)
	if err != nil {
		return errors.E(errors.IO, err)
	}
	return nil
}