Commit graph

1426 commits

Author SHA1 Message Date
David Hill
d2d278a9ee fix typo 2014-01-15 08:51:20 -05:00
Josh Rickmar
3b9d84b1e2 Release reader lock before syncing to disk.
When disk syncing a wallet file, if the wallet is flagged dirty, the
disk syncer must grab the wallet writer lock to set dirty=false.  The
disk syncing code was being called in the end of
(*Account).RescanActiveAddresses with the reader lock held (unlocked
using a defer), which prevented the writer lock from being aquired.

This change removes the defered unlock to release the reader lock
before syncing to disk.
2014-01-14 20:24:12 -05:00
Josh Rickmar
d811f38309 Prepare for release 0.2.0. 2014-01-14 19:25:31 -05:00
Josh Rickmar
8f4add7032 Update sample configuration with all options. 2014-01-14 19:20:08 -05:00
Josh Rickmar
86cf8e7005 Write RPC cert and key to correct files. 2014-01-14 11:13:27 -05:00
Josh Rickmar
ba92c234b3 Add another TODO to the README. 2014-01-11 03:07:24 -05:00
Josh Rickmar
76f3657ad3 Update README with recent changes and additional details. 2014-01-11 03:02:37 -05:00
Josh Rickmar
ecc959677c Do not print help usage twice with -h. 2014-01-10 17:18:42 -05:00
Josh Rickmar
467d976f0a Switch to btcutil for certificate generation. 2014-01-10 15:51:54 -05:00
Josh Rickmar
eca8914254 Write dirty tx and utxo files when rescans finish. 2014-01-10 14:53:47 -05:00
Josh Rickmar
ebcaa95b35 Use smarter btcd cert path logic.
If ~/.btcwallet/btcd.cert does not exist and the CA file has not been
explicitly set using the config file or command line flags, it's
possible that the cert can be found in ~/.btcd.  If connecting to a
localhost btcd and the previous statements are true, the default CA
file config option is updated for the certificate in them btcd
homedir.

If ~/.btcwallet/btcd.cert does exist and the CA file has not been set,
it is used without checking for a cert in the btcd homedir.
2014-01-10 11:39:03 -05:00
Josh Rickmar
3e2f67fda7 Short circuit handshake if default account does not exist. 2014-01-09 19:25:51 -05:00
Josh Rickmar
a6e0f3bc2a Update copyright years on remaining files. 2014-01-09 14:13:26 -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
42055d5b7c Fix sample listen address in config. 2014-01-09 10:51:33 -05:00
Josh Rickmar
15c85b5c75 Fix same issue as before, but for getaccountaddress. 2014-01-06 16:39:32 -05:00
Josh Rickmar
bdf2198215 Reply to getnewaddress with the encoded address. 2014-01-06 16:33:07 -05:00
Josh Rickmar
40675d1bef Fix tx file serialization and tests. 2014-01-06 13:35:07 -05:00
Josh Rickmar
e8265eca41 Switch to new btcutil Address encoding/decoding API. 2014-01-06 12:24:29 -05:00
Josh Rickmar
ac79a59c90 Implement the getaccountaddress RPC command. 2013-12-31 14:39:27 -05:00
Josh Rickmar
fa699ef4a5 Add getaccount RPC command. 2013-12-30 16:31:33 -05:00
Josh Rickmar
920ff10155 Add getunconfirmedbalance websocket RPC extension. 2013-12-30 15:11:41 -05:00
Josh Rickmar
8be51e37cf Add handlers to unimplemented RPC requests.
Fixes #29.
2013-12-30 12:44:51 -05:00
Josh Rickmar
00dbc71bb8 Remove comment.
Fixes #26.
2013-12-30 11:46:18 -05:00
Josh Rickmar
5bf8f89e4b Add listaddresstransactions extension.
Fixes #27.
2013-12-30 11:10:06 -05:00
Josh Rickmar
614ed93a1d Support mempool transaction notifications. 2013-12-20 12:48:47 -05:00
Josh Rickmar
399f91bba2 Error if writing a wallet fails during privkey import. 2013-12-16 09:12:25 -05:00
Josh Rickmar
75d3a77106 Fix build for new btcws notifications. 2013-12-13 11:00:31 -05:00
Josh Rickmar
d4e756bc23 Add getaddressbalance websocket extension request. 2013-12-10 16:15:25 -05:00
Josh Rickmar
5f1fb8b874 Enable --mainnet flag.
This change enables the --mainnet flag to connect to a mainnet btcd
instance and open and create mainnet wallets.  Attempting to connect
to a testnet btcd, or opening a testnet wallet when running in mainnet
mode will result in an error printed to the logging output.

Testnet (version 3) remains the default network for now.  btcwallet
will continue to receive fixes and new features, but at the moment we
believe that early adopters familar with using btcwallet on testnet
can safely use it for mainnet now as well.

Reminder: when dealing with mainnet coins, it is always a good idea to
keep backups of your wallet.  btcwallet uses a deterministic wallet,
and any later addresses for an account can be recreated with just the
account's original wallet file (this does *not* include imported
addresses).  Might we recommend Cyphertite for a backup solution?
2013-12-09 17:44:19 -05:00
Josh Rickmar
7a91209a4c Add wallet API to set better earliest block height. 2013-12-09 17:03:51 -05:00
Josh Rickmar
35a991e503 Remove circular dependancy on wallet creation. 2013-12-09 16:51:07 -05:00
Josh Rickmar
9be84e3489 Set connect option based on active net params. 2013-12-09 16:46:38 -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
David Hill
e48d115900 TravisCI support 2013-12-08 22:15:16 -05:00
Josh Rickmar
b6601b1b6b Remove some TODOs that have been finished. 2013-12-06 09:19:00 -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
52525dd302 Fix formatting. 2013-12-05 14:12:56 -05:00
Josh Rickmar
e7826dae00 Add atomic rename functions for Windows and Plan 9.
This code is based off leveldb (https://github.com/syndtr/goleveldb),
and the leveldb copyright notice (a 2-clause BSD license) has been
included where used.
2013-12-05 14:06:51 -05:00
Josh Rickmar
311276eae5 Make authentication check time-constant. 2013-12-05 13:01:26 -05:00
Josh Rickmar
a9cc0d4465 Remove extra newline in logging output. 2013-12-05 10:10:31 -05:00
Josh Rickmar
4bdb88f4bc Log authentication failures to info debug level. 2013-12-05 10:04:35 -05:00
Josh Rickmar
ae4bf50f7a Move some funcs for better file organization. 2013-12-04 20:55:56 -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
48a685e85e Calculate the minimum tx fee when creating transactions. 2013-12-04 12:13:40 -05:00
Josh Rickmar
378af40329 Remove some fmt.Printf debugging. 2013-12-03 12:45:27 -05:00
Josh Rickmar
c54af23849 Perform signature verifiction when generating addresses.
This change adds an additional check when creating a new wallet or
extending the keypool.  All public and private keypairs are parsed
from their serialized forms, and an ecdsa signature is created and
verified using the keypairs.  If the verifiction fails at any point,
the wallet creation or keypool extension is aborted to prevent any
errors where an address is returned to a user, but any funds send to
that address are unspendable due to a mismatched keypair.
2013-12-03 12:37:18 -05:00
Josh Rickmar
eeb72db8b5 Change default CA file location.
This changes the default CA filename from 'cert.pem' to 'btcd.cert' to
reflect the fact that this cert is used for securely connecting to
btcd.  With the introduction of autogenerated btcwallet certs (saved
to rpc.cert and rpc.key) this change was made to better differentiate
the two cert files.

To upgrade across this change, simply move the btcd cert.  On unix,
use the command:

$ mv ~/.btcwallet/cert.pem ~/.btcwallet/btcd.cert
2013-12-03 11:00:26 -05:00
Josh Rickmar
3b04e3a4bc Use TLS+auth for frontend connections.
This change is mostly a copy paste job from the TLS listeners and
autogenerated cert code from btcd.
2013-12-03 10:52:09 -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