From dcf64e2957cb569cb90a7a88c85aae6512668430 Mon Sep 17 00:00:00 2001 From: Josh Rickmar Date: Thu, 19 Feb 2015 15:04:14 -0500 Subject: [PATCH] Use rescan for initial tx notification registrations. Requires btcsuite/btcd#310. --- rescan.go | 1 - wallet.go | 45 --------------------------------------------- 2 files changed, 46 deletions(-) diff --git a/rescan.go b/rescan.go index 49bba99..05e1321 100644 --- a/rescan.go +++ b/rescan.go @@ -209,7 +209,6 @@ out: addrs := msg.Addresses noun := pickNoun(len(addrs), "address", "addresses") if msg.WasInitialSync { - w.Track() w.ResendUnminedTxs() bs := keystore.BlockStamp{ diff --git a/wallet.go b/wallet.go index 87825fa..3be92df 100644 --- a/wallet.go +++ b/wallet.go @@ -1160,34 +1160,6 @@ func (w *Wallet) LockedOutpoints() []btcjson.TransactionInput { return locked } -// Track requests btcd to send notifications of new transactions for -// each address stored in a wallet. -func (w *Wallet) Track() { - // Request notifications for transactions sending to all wallet - // addresses. - // - // TODO: return as slice? (doesn't have to be ordered, or - // SortedActiveAddresses would be fine.) - addrMap := w.KeyStore.ActiveAddresses() - addrs := make([]btcutil.Address, len(addrMap)) - i := 0 - for addr := range addrMap { - addrs[i] = addr - i++ - } - - if err := w.chainSvr.NotifyReceived(addrs); err != nil { - log.Error("Unable to request transaction updates for address.") - } - - unspent, err := w.TxStore.UnspentOutputs() - if err != nil { - log.Errorf("Unable to access unspent outputs: %v", err) - return - } - w.ReqSpentUtxoNtfns(unspent) -} - // ResendUnminedTxs iterates through all transactions that spend from wallet // credits that are not known to have been mined into a block, and attempts // to send each to the chain server for relay. @@ -1318,23 +1290,6 @@ func (w *Wallet) RecoverAddresses(n int) error { return nil } -// ReqSpentUtxoNtfns sends a message to btcd to request updates for when -// a stored UTXO has been spent. -func (w *Wallet) ReqSpentUtxoNtfns(credits []txstore.Credit) { - ops := make([]*wire.OutPoint, len(credits)) - for i, c := range credits { - op := c.OutPoint() - log.Debugf("Requesting spent UTXO notifications for Outpoint "+ - "hash %s index %d", op.Hash, op.Index) - ops[i] = op - } - - if err := w.chainSvr.NotifySpent(ops); err != nil { - log.Errorf("Cannot request notifications for spent outputs: %v", - err) - } -} - // TotalReceived iterates through a wallet's transaction history, returning the // total amount of bitcoins received for any wallet address. Amounts received // through multisig transactions are ignored.