Commit graph

16 commits

Author SHA1 Message Date
Owain G. Ainsworth
34b683b4aa Implement listsinceblock command
Closes #52
2014-01-27 23:17:32 +00:00
Josh Rickmar
b09e4f5200 Lock/unlock all account wallets.
Now that it has been decided that all account wallets will share the
same passphrase, the walletlock and walletpassphrase RPC handlers now
go through the accountstore to lock or unlock all account wallets,
rather than only changing the default account.
2014-01-27 15:48:12 -05:00
Josh Rickmar
6ad3f8786e Implement walletpassphrasechange RPC call.
Closes #62.
2014-01-27 14:14:54 -05:00
Josh Rickmar
b4373dc070 Open all account files at startup.
This change checks for all wallet files in the account directory, and
then attempts to open each of the available accounts for those
wallets.  Before, only the default account would ever be opened.
2014-01-23 17:12:55 -05:00
Josh Rickmar
830829a79f Add dirty wallets to disc sync schedule.
There were several places where various account files (wallet, tx, or
utxo stores) were being marked as dirty, and then not being either
immediately synced to disk or marked as a dirty account so they would
be scheduled to be synced to disk.  This change adds Account functions
to mark as dirty and add the account to the map of scheduled accounts
so they won't be missed by the disk syncer goroutine.
2014-01-23 12:38:39 -05:00
Josh Rickmar
8b65e651cd Mark new wallet addresses as belonging to account.
This adds some missing bookkeeping which broke rescans for the root
addresses of newly created wallets (not wallets read from disk) by
marking all active addresses (which would be just the root address) as
belonging to the account with a some particular name.

While here, return an error to the caller rather than just logging the
error if the newly-created wallet cannot be immediatelly written to
disk.
2014-01-23 09:51:31 -05:00
Josh Rickmar
f0c649b7ac Make maximum keypool size a config option. 2014-01-15 17:29:01 -05:00
Josh Rickmar
80606d7344 Mark new wallet tx/utxo stores as dirty.
This change makes the disk syncer write all three files (wallet, tx,
and utxo) instead of just the wallet, which will result in warnings at
startup if the tx/utxo files cannot be found.

Fixes #30.
2014-01-15 14:25:37 -05:00
Josh Rickmar
15ffc674a9 Rework the btcd RPC connection.
This change greatly cleans up the RPC connection between btcwallet and
btcd.  Proper (JSON-RPC spec-following) notifications are now expected
rather than Responses with a non-empty IDs.

A new RPCConn interface type has also been introduced with a
BtcdRPCConn concrete type for btcd RPC connections.  Non-btcd-specific
code handles the RPCConn, while the btcd details have been abstracted
away to a handful of functions.  This will make it easier to write
tests by creating a new fake RPC connection with hardcoded expected
replies.
2014-01-09 14:07:17 -05:00
Josh Rickmar
e8265eca41 Switch to new btcutil Address encoding/decoding API. 2014-01-06 12:24:29 -05:00
Josh Rickmar
d4e756bc23 Add getaddressbalance websocket extension request. 2013-12-10 16:15:25 -05:00
Josh Rickmar
c97e0d5fc6 Detect reorgs after btcd disconnect/reconnect.
This change saves (at most) the last 20 block hashes to disk.  Upon
btcd connect, in the handshake, btcwallet checks whether btcd's best
chain still contains these blocks, starting from the most recently
added block and continuing until the earliest saved.  If any blocks
are missing, Tx history and UTXOs from any blocks no longer in the
chain are removed, and a rescan is started from after the best block
still in the main chain.

If all previous block hashes are exhausted (either due to a large
reorg, or because not enough blocks have been seen), a full rescan is
triggered (full meaning from the earliest block that matters to this
wallet) since the last synced up to point is no longer available.

The previous 20 seen block hashes are saved to the wallet file, which
required bumping the file version.  Older wallets written with lesser
versions will use the previous reading function, making this change
backwards compatible.
2013-12-09 15:19:20 -05:00
Josh Rickmar
8669129917 Copy btcd RPC listening behavior.
This change copies the listening behavior of btcd by replacing the
--serverport option with --listen.  By default, btcwallet will only
listen for localhost connections, but with this change it will be
possible to add listeners for remote connections.

This was added due to finding a bug with updateConfigWithActiveParams.
After consulting the btcd source code, the bug was fixed by replacing
the function (as it was no longer needed) when the new listening code
was introduced.

While here, mask out the password flag from being shown in the help
message.
2013-12-05 17:25:36 -05:00
Josh Rickmar
ce23523ed7 Introduce new account file structure.
This changes the locations that account files (wallet.bin, utxo.bin,
and tx.bin) are searched for when opening or disk syncing accounts.
Previously, files were saved in the following layout:

  ~/.btcwallet/
    - btcwallet/
      - wallet.bin
      - tx.bin
      - utxo.bin
    - btcwallet-AccountA/
      - wallet.bin
      - tx.bin
      - utxo.bin

This format had two issues.  First, each account would require its own
directory, causing a scalability issue on unix (and perhaps other)
platforms.  Second, there was no distinction between testnet and
mainnet wallets, and if mainnet support was enabled, btcwallet would
attempt to open accounts with testnet wallets.

Instead, the following file structure is now used:

  ~/.btcwallet/
    - testnet/
      - wallet.bin
      - tx.bin
      - utxo.bin
      - AccountA-wallet.bin
      - AccountA-tx.bin
      - AccountA-utxo.bin

This solves both of the previously-mentioned issues by requiring only
two subdirectories (one each for the testnet and mainnet bitcoin
networks), and by separating the locations to open and save testnet
and mainnet account files.

At startup, a check for the old account file structure is performed.
If found, files are moved to the new locations, and the old account
directories are removed.  Account files are moved to the testnet
directory, as only testnet support is currently enabled.

The version has been bumped to 0.1.1 to reflect this change.

Fixes #16.
2013-12-04 20:25:13 -05:00
Josh Rickmar
af1438eecd Add frontend support for displaying txs.
This change adds a new websocket extension command,
listalltransaction, which works just like listtransactions except it
does not take the count or from optional args, and will return an
array of all transaction details.  Notifications for newly-added
transactions are now sent to frontends as well, using the newtx
notification.

No support for updating tx details or removing failed txs is
implemented yet, and will be when cleanly failing a tx send is
implemented later.
2013-12-02 17:34:36 -05:00
Josh Rickmar
3c528f81ec New Account and AccountStore API.
This change better organizes account handling by creating a new
AccountStore type and accountstore global variable, with receiver
funcs for all operations that require all accounts.  More Account
funcs are also added to clean up account handling in the RPC code.

Intial work on this done by dhill.
2013-12-02 14:56:06 -05:00