*/
// FindByAlias retrieves an account's Signer record by its alias
-func (m *Manager) FindByAlias(/*ctx context.Context,*/ alias string) (*signers.Signer, error) {
+func (m *Manager) FindByAlias(ctx context.Context, alias string) (*signers.Signer, error) {
var accountID string
m.cacheMu.Lock()
}
// findByID returns an account's Signer record by its ID.
-func (m *Manager) findByID(/*ctx context.Context, */id string) (*signers.Signer, error) {
+func (m *Manager) findByID(ctx context.Context, id string) (*signers.Signer, error) {
m.cacheMu.Lock()
cached, ok := m.cache.Get(id)
m.cacheMu.Unlock()
if ok {
return cached.(*signers.Signer), nil
}
- account, err := signers.Find(/*ctx, */m.db, "account", id)
+ account, err := signers.Find(ctx, m.db, "account", id)
if err != nil {
return nil, err
}
expiresAt time.Time
}
-func (m *Manager) createControlProgram(/*ctx context.Context,*/ accountID string, change bool, expiresAt time.Time) (*controlProgram, error) {
- account, err := m.findByID(/*ctx,*/ accountID)
+func (m *Manager) createControlProgram(ctx context.Context, accountID string, change bool, expiresAt time.Time) (*controlProgram, error) {
+ account, err := m.findByID(ctx, accountID)
if err != nil {
return nil, err
}
- idx, err := m.nextIndex(/*ctx*/)
+ idx, err := m.nextIndex(ctx)
if err != nil {
return nil, err
}
// CreateControlProgram creates a control program
// that is tied to the Account and stores it in the database.
-func (m *Manager) CreateControlProgram(/*ctx context.Context,*/ accountID string, change bool, expiresAt time.Time) ([]byte, error) {
- cp, err := m.createControlProgram(/*ctx,*/ accountID, change, expiresAt)
+func (m *Manager) CreateControlProgram(ctx context.Context, accountID string, change bool, expiresAt time.Time) ([]byte, error) {
+ cp, err := m.createControlProgram(ctx, accountID, change, expiresAt)
if err != nil {
return nil, err
}
- err = m.insertAccountControlProgram(/*ctx,*/ cp)
+ /*err = m.insertAccountControlProgram(ctx, cp)
if err != nil {
return nil, err
- }
+ }*/
return cp.controlProgram, nil
}
}
*/
-func (m *Manager) nextIndex(/*ctx context.Context*/) (uint64, error) {
+func (m *Manager) nextIndex(ctx context.Context) (uint64, error) {
m.acpMu.Lock()
defer m.acpMu.Unlock()
import (
"context"
- "database/sql"
+// "database/sql"
"encoding/json"
// "github.com/lib/pq"
// Look up all of the spent and created outputs. If any of them are
// account UTXOs add the account annotations to the inputs and outputs.
- const q = `
+ /*const q = `
SELECT o.output_id, o.account_id, a.alias, a.tags, o.change
FROM account_utxos o
LEFT JOIN accounts a ON o.account_id = a.account_id
out.Purpose = "receive"
}
}
- })
- return errors.Wrap(err, "annotating with account data")
+ }) */
+ return errors.Wrap(nil, "annotating with account data")
}
if len(acps) == 0 {
return nil
}
- return m.insertAccountControlProgram(ctx, acps...)
+ // return m.insertAccountControlProgram(ctx, acps...)
})
}
}
func (m *Manager) ProcessBlocks(ctx context.Context) {
- if m.pinStore == nil {
+ /*if m.pinStore == nil {
return
}
go m.pinStore.ProcessBlocks(ctx, m.chain, ExpirePinName, func(ctx context.Context, b *legacy.Block) error {
return m.deleteSpentOutputs(ctx, b)
})
m.pinStore.ProcessBlocks(ctx, m.chain, PinName, m.indexAccountUTXOs)
+ */
}
+/*
func (m *Manager) expireControlPrograms(ctx context.Context, b *legacy.Block) error {
// Delete expired account control programs.
const deleteQ = `DELETE FROM account_control_programs WHERE expires_at IS NOT NULL AND expires_at < $1`
_, err := m.db.ExecContext(ctx, delQ, delOutputIDs)
return errors.Wrap(err, "deleting spent account utxos")
}
+*/
func (m *Manager) indexAccountUTXOs(ctx context.Context, b *legacy.Block) error {
// Upsert any UTXOs belonging to accounts managed by this Core.
return errors.Wrap(err, "upserting confirmed account utxos")
}
+/*
func prevoutDBKeys(txs ...*legacy.Tx) (outputIDs pq.ByteaArray) {
for _, tx := range txs {
for _, inpID := range tx.Tx.InputIDs {
}
return
}
+*/
// loadAccountInfo turns a set of output IDs into a set of
// outputs by adding account annotations. Outputs that can't be
outsByScript[scriptStr] = append(outsByScript[scriptStr], out)
}
- var scripts pq.ByteaArray
+ /*var scripts pq.ByteaArray
for s := range outsByScript {
scripts = append(scripts, []byte(s))
}
+ */
result := make([]*accountOutput, 0, len(outs))
+/*
const q = `
SELECT signer_id, key_index, control_program, change
FROM account_control_programs
if err != nil {
return nil, err
}
+ */
return result, nil
}
return &s, nil
}
+*/
// Find retrieves a Signer from the database
// using the type and id.
-func Find(ctx context.Context, db pg.DB, typ, id string) (*Signer, error) {
- const q = `
+func Find(ctx context.Context, db dbm.DB, typ, id string) (*Signer, error) {
+ /*const q = `
SELECT id, type, xpubs, quorum, key_index
FROM signers WHERE id=$1
`
+ */
var (
s Signer
xpubBytes [][]byte
)
+ /*
err := db.QueryRowContext(ctx, q, id).Scan(
&s.ID,
&s.Type,
if s.Type != typ {
return nil, errors.Wrap(ErrBadType)
- }
+ }*/
keys, err := ConvertKeys(xpubBytes)
if err != nil {
return &s, nil
}
+/*
// List returns a paginated set of Signers, limited to
// the provided type.
func List(ctx context.Context, db pg.DB, typ, prev string, limit int) ([]*Signer, string, error) {