Commit graph

11 commits

Author SHA1 Message Date
Josh Rickmar
18fb993d0b Implement address rescanning.
When a wallet is opened, a rescan request will be sent to btcd with
all active addresses from the wallet, to rescan from the last synced
block (now saved to the wallet file) and the current best block.

As multi-account support is further explored, rescan requests should
be batched together to send a single request for all addresses from
all wallets.

This change introduces several changes to the wallet, tx, and utxo
files.  Wallet files are still compatible, however, a rescan will try
to start at the genesis block since no correct "last synced to" or
"created at block X" was saved.  The tx and utxo files, however, are
not compatible and should be deleted (or an error will occur on read).
If any errors occur opening the utxo file, a rescan will start
beginning at the creation block saved in the wallet.
2013-11-01 10:06:38 -04:00
Josh Rickmar
b1c246c01b Perform smarter UTXO tracking.
This change fixes many issues with the tracking of unspent transaction
outputs.  First, notifications for when UTXOs arse spent are now
requested from btcd, and when spent, will be removed from the
UtxoStore.

Second, when transactions are created, the unconfirmed (not yet in a
block) Utxo (with block height -1 and zeroed block hash) is added to
the wallet's UtxoStore.  Notifications for when this UTXO is spent are
also requested from btcd.  After the tx appears in a block, because
the UTXO has a pkScript to be spent by another owned wallet address, a
notification with the UTXO will be sent to btcwallet.  We already
store the unconfirmed UTXO, so at this point the actual block height
and hash are filled in.

Finally, when calculating the balance, if confirmations is zero,
unconfirmed UTXOs (block height -1) will be included in the balance.
Otherwise, they are ignored.
2013-10-22 09:55:53 -04:00
Josh Rickmar
51cb34e50a Add func to remove utxos from a UtxoStore. 2013-10-15 10:05:51 -04:00
Josh Rickmar
50073b32c1 Save correct addresses for new utxos 2013-10-10 18:44:44 -04:00
Josh Rickmar
63686347c6 Create transactions using saved utxo data.
This is a big change that also many general fixes to problems found
when creating transactions.  In particular the Utxo and Tx formats and
serialization functions were updated with additional information that
would be necessary for rolling back old utxo and tx data data after
btcd chain switches.  This change also implements the json methods
'sendfrom' and 'sendmany' to create a new transaction based on a
frontend request.

Transactions are currently not sent to btcd since the tx relay code is
not finished yet, so a temporary error is returned back to frontends
who try to send new transactions.
2013-10-01 14:26:27 -04:00
Josh Rickmar
fa85e586fc Save the pkScript for each Utxo. This is needed to create transactions. 2013-09-09 13:31:37 -04:00
Josh Rickmar
a6ad4cf48c Save index as well as tx hash for outputs. 2013-09-04 16:16:20 -04:00
Josh Rickmar
0928361f22 Save address with Utxo.
We want only one utxo file per wallet, so each serialized Utxo needs
to also contain the receiving address.
2013-09-04 09:32:14 -04:00
Josh Rickmar
ab623ec9e0 Read and write tx fee from SendTxs 2013-08-27 12:39:45 -04:00
Josh Rickmar
7716ad7e38 Tests for RecvTx, SendTx, and TxStore 2013-08-26 13:34:18 -04:00
Josh Rickmar
e80d089a15 Implement io.ReaderFrom and io.WriterTo tx/utxo types.
These are currently untested.
2013-08-23 14:28:07 -04:00