Commit graph

710 commits

Author SHA1 Message Date
Josh Rickmar
76c6379a54 Update for btcutil.Address API change. 2014-02-26 15:22:48 -05:00
Josh Rickmar
acb4819ee1 Allocate and init transaction store for newly created accounts. 2014-02-26 13:56:44 -05:00
Josh Rickmar
6805d7a7a1 Kick off full rescan if tx file is missing. 2014-02-24 16:01:03 -05:00
Josh Rickmar
fc2e313a39 Introduce new transaction store.
This change replaces the old transaction store file format and
implementation.  The most important change is how the full backing
transactions for any received or sent transaction are now saved,
rather than simply saving parsed-out details of the tx (tx shas, block
height/hash, pkScripts, etc.).

To support the change, notifications for received transaction outputs
and txs spending watched outpoints have been updated to use the new
redeemingtx and recvtx notifications as these contain the full tx,
which is deserializead and inserted into the store.

The old transaction store serialization code is completely removed, as
updating to the new format automatically cannot be done.  Old wallets
first running past this change will error reading the file and start a
full rescan to rebuild the data.  Unlike previous rescan code,
transactions spending outpoint managed by wallet are also included.
This results in recovering not just received history, but history for
sent transactions as well.
2014-02-24 14:35:30 -05:00
Josh Rickmar
438f55a0a4 Set deadline on client websocket sends.
It appears that the websocket package will occasionally enter a
Codec's Send function and block forever, never erroring (presumably
due to a closed connection).  This change adds a deadline for the send
of two seconds.  If the send cannot complete before the deadline is
reached, the send is aborted and the connection is assumed to be lost.

A buffer should be added here as well, so even waiting max two seconds
for the send to error out won't cause wallet code to block.
2014-02-19 13:57:52 -05:00
Josh Rickmar
3a23fdaf64 Move duplicater chan send out of default case.
At any instant when a duplicated notification must be sent, either one
of two channel sends/recvs must occur.  The first possibility is that
the client is disconnected, in which case the disconnected channel
will be read, and then the context removed from the goroutine-managed
map.  The second possibility is that the disconnect channel has not
yet been closed, in which case it must block on an actual message
send.  This change moves the second case out of the default case of
the select statement to avoid a race where:

1) The client has not yet disconnected, and the disconnected chan is
   not ready for reads.
2) Control switches to the default case.
3) The client disconnects, the goroutine reading the send channel
   returns, closes the disconnected channel, and no more reads occur.
4) The notification duplicator blocks forever trying to send the
   message even when the disconnected notification channel has
   already been closed.
2014-02-18 21:11:33 -05:00
Josh Rickmar
2ff7f85b0c Notify connected ws clients of btcd connect state.
This shouldn't be nececssary (a TODO was added to remind me to make
clients explicitly ask for this info) but in the meantime this fixes
clients such as btcgui which otherwise wouldn't think btcwallet is
properly connected to btcd and will desensitise some widgets.
2014-02-18 15:51:06 -05:00
Josh Rickmar
e837ca5b64 Cleanly remove disconnected clients.
Also fixes a bug where responses for a single client would be sent to
every connected client.
2014-02-18 12:39:53 -05:00
Owain G. Ainsworth
3a6ae93a4b Implement validateaddress rpc command.
Closes #60
2014-02-14 14:35:59 +00:00
Owain G. Ainsworth
ed264697e7 Implement the listunspent command
closes #54
2014-02-14 14:35:58 +00:00
Owain G. Ainsworth
70eb389029 fmt. 2014-02-13 18:42:22 +00:00
Owain G. Ainsworth
5f52df997c Add support for signmessage and verifymessage
Closes #58
Closes #61
2014-02-12 15:41:47 +00:00
Josh Rickmar
f509173275 Prepare for release 0.3.0. 2014-02-10 12:13:15 -05:00
Josh Rickmar
7489fd5889 Remove erroneous comment. 2014-02-05 13:54:56 -05:00
Josh Rickmar
114bb581f7 Fix hang related to account file writes.
The disk syncer now maintains its own countdown timer, creating a new
timer only when necessary (when there is no timer running, and
something is scheduled to be written).  When the timer expires, the
select loop begins selecting on a grab of the account manager's binary
semaphore, and if read, performs the sync and nils the select channel
to prevent a future grab until a new timer has expired.

Tested with a race-enabled build on Windows.  No lockups or races
related to the disk syncing experienced with constant client requests
and incoming btcd notifications, and scheduled writes run as expected
once the countdown timer expires, locking out all server request and
notifiation handling.
2014-02-05 12:47:33 -05:00
Josh Rickmar
db576ba636 Close account files before renaming, instead of deferring.
Fixes file locking issues on Windows.
2014-02-05 11:39:37 -05:00
Owain G. Ainsworth
e685d0279f Implement SendToAddress.
Closes #56
2014-02-05 00:04:18 +00:00
Josh Rickmar
243acf5491 Fix issue calculating eligible inputs.
Use the new confirmed function to test whether unspent transaction
outputs are confirmed enough to be used as a possible transaction
inputs instead of the old check (which was incorrect and required an
extra confirmation).

Modified the test to require one confirmation instead of none so the
confirmed enough check actually occurs.
2014-02-04 11:52:38 -05:00
Owain G. Ainsworth
b978c7e059 Impelment the gettransaction rpc command.
Closes #44.
2014-02-04 16:29:33 +00:00
Josh Rickmar
9aa27517eb Buffer the disk syncer flush channel. 2014-02-04 11:01:21 -05:00
Josh Rickmar
5edd01e8a5 Unmark addresses as requiring private keys next unlock.
The flag marking chained addresses as needing private keys be
generated on the next wallet unlock was not being correctly unset
after creating and encrypting the private key.  After
serializing/deserializing the wallet, on next unlock, recreating
missing private keys would begin too early in the chain and fail due
to trying to encrypt an already encrypted address.

This change correctly unsets the flag and bumps the version so a
special case can be created for ignoring duplicate encryption attempts
when reading an old wallet file.  Tests have also been added to the
chained pubkey test to test for this error case.
2014-02-04 10:37:28 -05:00
Josh Rickmar
8dac5080ac Change AccountManager to not wait for disk flushes.
Should fix hang found by dhill.
2014-02-03 18:15:36 -05:00
Josh Rickmar
03ffa0ccd8 Do not serialize/deserialize armory unique ID.
Closes #70.
2014-02-03 15:11:17 -05:00
Josh Rickmar
a0e94501cf Add 'stop' to the RPC handlers map.
Sending a stop request to wallet should stop the wallet, not pass the
unhandled request to btcd.  Instead, catch it with the Unimplemented
handler.
2014-02-03 15:01:25 -05:00
Josh Rickmar
d7a4e5e816 Implement getreceivedbyaccount.
Closes #42.
2014-02-03 14:53:27 -05:00
Josh Rickmar
72d7dda583 Remove unused function. 2014-02-03 13:01:17 -05:00
Josh Rickmar
45e0a3fcb9 Move websocket endpoint to /ws. 2014-02-03 11:50:11 -05:00
Josh Rickmar
b90e7aae82 Implement getrawchangeaddress.
Closes #41.
2014-02-03 10:52:02 -05:00
Josh Rickmar
b3bb0481b0 Add wallet func to return a change address.
Previous to this commit, all change addresses were indistinguishable
from manually requested addresses.  This adds a new function to return
the new address, setting a new change flag to true, and return the
change status with the AddressInfo.

This is needed as part of resolving #41 (getrawchangeaddress).
2014-02-03 10:21:47 -05:00
Josh Rickmar
6a08c7de07 Redo account locking and RPC request processing.
This change removes the three separate mutexes which used to lock an
account's wallet, tx store, and utxo store.  Accounts no longer
contain any locking mechanism and rely on go's other synchronization
constructs (goroutines and channels) for correct access.

All accounts are now managed as a collection through the new
AccountManager, rather than the old AccountStore.  AccountManager runs
as its own goroutine to provide access to accounts.

RPC requests are now queued for handling, being denied if the queue
buffer is exhausted.  Notifications are also queued (instead of being
sent from their own goroutine after being received, in which order is
undefined), however, notifications are never dropped and will
potentially grow a queue of infinite size if unhandled.
2014-02-01 13:18:34 -05:00
Josh Rickmar
20e8201125 Remove some printf debugging that slipped in. 2014-01-29 17:57:14 -05:00
Josh Rickmar
430db140ee Synchronize all account file writes.
Fixes several hangs cased by incorrect locking, by removing the
locking.  Instead, a single goroutine manages all file writes.

The old account 'dirty' boolean flags have been removed.  Instead,
anytime an account structure is modified, the portion that was
modified (wallet, tx store, or utxo store) must be scheduled to be
written.
2014-01-29 17:50:58 -05:00
Owain G. Ainsworth
0b371b09e8 Implement getinfo command
Closes #63
2014-01-29 17:14:48 +00:00
Josh Rickmar
d0b942d414 Smarter locking for recording mined txs. 2014-01-28 16:52:47 -05:00
Josh Rickmar
3ab33bafd7 Fix typo. 2014-01-28 16:21:53 -05:00
Josh Rickmar
47906dc46c Don't use extra goroutine to rollback account data. 2014-01-28 16:11:59 -05:00
Josh Rickmar
c1c40975ab Mutex fixes for writing an exported wallet. 2014-01-28 15:03:07 -05:00
Josh Rickmar
f4c5cc1b7e Additional mutex fixes. 2014-01-28 14:43:55 -05:00
Josh Rickmar
dd3d7467c3 Fixes for writeDirtyToDisk.
This commit fixes two issues in the writeDirtyToDisk function:

First, closing the temporary files is now done using a defer, so they
are always closed.

Second, the various account mutexs are no longer unlocked using a
defer, preventing more than one from being held at once and causing a
deadlock caused by incorrect locking order.
2014-01-28 14:09:19 -05:00
Josh Rickmar
0d903a5a29 Invert allowfree option.
Boolean options cannot be unset from a default true value on the
command line, so invert the allowfree option, renaming it
disallowfree, so attaching fees may always be forced by specifying
disallowfree = true in the configuration file, or --disallowfree on
the command line.
2014-01-28 12:55:42 -05:00
Owain G. Ainsworth
df51a478f4 fix merge conflict, remove duplicate map entry 2014-01-27 23:29:49 +00:00
Owain G. Ainsworth
34b683b4aa Implement listsinceblock command
Closes #52
2014-01-27 23:17:32 +00:00
Josh Rickmar
845d54da55 Add allowfree configuration option.
It may be desirable to never allow free transactions, even if the
calculated priority is high enough that a fee would not be required,
so this change adds a global configuration option to remove this check
and always attach a fee.
2014-01-27 16:58:49 -05:00
Josh Rickmar
57df957687 Set sendfrom txid from sendrawtransaction result.
Fixes #64 and a bunch of broken notification handlers after sending a
transaction using sendfrom.
2014-01-27 16:26:58 -05: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
e2bf9a03da Add getinfo to unhandled RPC handler map. 2014-01-27 15:05:31 -05:00
Josh Rickmar
6ad3f8786e Implement walletpassphrasechange RPC call.
Closes #62.
2014-01-27 14:14:54 -05:00
Josh Rickmar
3f6133e44b Add func to return passphrase of an unlocked wallet.
This function will be used to create new encrypted wallets with the
same passhprase as existing account wallets.
2014-01-24 12:31:08 -05:00
Josh Rickmar
3778ddd024 Update for btcws API change. 2014-01-24 11:17:19 -05:00
Josh Rickmar
13d310f8d4 Fix tests for previous TxStore change. 2014-01-24 09:03:25 -05:00