Commit graph

887 commits

Author SHA1 Message Date
Josh Rickmar
8ce25ce518 Do not remove txs from extra block on reorgs. 2015-05-04 09:28:19 -04:00
Dave Collins
c820c8a015 Relicense to the btcsuite developers. 2015-05-01 12:20:05 -05:00
Josh Rickmar
0ae57f2564 Fix waddrmgr version 4 upgrade path.
If the account number to name index mapped the default account name to
an alias, the upgrade would not succeed and the upgrade would be
aborted (and rolled back).

This became a problem for upgrading old (pre-v3) wallets since the v3
upgrade did not rename the previous "" account to "default", but
instead just created an alias.

Fix tested by @dajohi, who ran into this issue with a wallet upgrade
from an older keystore version.
2015-05-01 12:24:22 -04:00
Dave Collins
0a13274d5b Update btcjson path import paths to new location. 2015-05-01 00:59:14 -05:00
Josh Rickmar
ec6034e2d9 Modify default account naming policy.
Rather than disallowing the default account to be renamed as was
proposed in #245 (and implemented in #246), the default account name
is no longer considered a reserved name by the address manager.
Instead, it is simply the initial name used for the first initial
account.

A database upgrade removes any additional aliases for the default
account in the database.  This prevents a lookup for some name which
is not an account name from mapping to the default account
unexpectedly (potentially preventing incorrect account usage from the
RPC server due to bad iteraction with default parameters).

All unset account names in a JSON-RPC request are expected to be set
nil by btcjson.  This behavior depends on btcsuite/btcd#399.

Additionally, the manager no longer considers the wildcard * to be a
reserved account name.  Due to poor API decisions, the RPC server
overloads the meaning of account fields to optionally allow referring
to all accounts at a time, or a single account.  This is not a address
manager responsibility, though, as a future cleaner API should not use
multiple differet meanings for the same field across multiple
requests.  Therefore, don't burden down future APIs with this quirk
and prevent incorrect wildcard usage from the RPC server.

Closes #245.
2015-05-01 01:30:20 -04:00
Josh Rickmar
43aef7db3c Convert RPC server to btcjson v2.
Closes #227.
2015-05-01 00:55:12 -04:00
Guilherme Salgado
d050a32cb2 votingpool: API to store withdrawal txs in the txstore 2015-04-29 07:55:32 -03:00
Josh Rickmar
09c391cc38 Remove legacy txstore. 2015-04-28 17:30:18 -04:00
Josh Rickmar
c012cdbd50 Add guide for forced rescans. 2015-04-28 17:30:17 -04:00
Josh Rickmar
f60b8207d2 Add utility to drop wtxmgr namespace.
This is intended to be used to force a full rescan.
2015-04-28 17:30:17 -04:00
Guilherme Salgado
847c7d8df9 Migrate votingpool tests to use wtxmgr 2015-04-28 17:30:17 -04:00
Josh Rickmar
56039deb94 Integrate wtxmgr package. 2015-04-28 17:30:17 -04:00
Javed Khan
ee72c81a73 Added additional test cases for account tests 2015-04-27 22:53:58 +05:30
Josh Rickmar
0087d38710 Add wtxmgr package. 2015-04-25 00:42:28 -04:00
Javed Khan
48a3b413b4 Move txstore package to legacy directory 2015-04-20 18:20:19 -04:00
Javed Khan
814d5c8771 Move rename to legacy 2015-04-20 18:20:19 -04:00
Josh Rickmar
437c7b3e59 Add cursor functionality to walletdb. 2015-04-20 18:20:19 -04:00
Josh Rickmar
dcef172f6b Rollback txstore on disconnected blocks.
Seems that this code got lost over time, and the only place where
reorgs were handled were those that happened while wallet was
disconnected.
2015-04-20 17:24:53 -04:00
Josh Rickmar
b74a6f78a6 Update for txscript.Script -> txscript.Engine. 2015-04-20 17:21:19 -04:00
Josh Rickmar
0d7b8af543 Updates for txscript.NewScript API change. 2015-04-20 16:52:26 -04:00
Dave Collins
ab8a155841 Update for recent wire API hash error changes. 2015-04-17 01:41:25 -05:00
Javed Khan
74208f90c1 CurrentAddress: subsequently return new address 2015-04-16 06:34:25 +05:30
Josh Rickmar
948609f064 Add licenses to files in package zero. 2015-04-14 11:34:25 -04:00
Javed Khan
84675ec9b8 Creating account requires unlocked manager - err 2015-04-13 21:12:07 +05:30
Josh Rickmar
fbe92830c1 Use btcjson v2 types with the updated btcrpcclient.
btcrpcclient commit 9ca93b30ad11ec34348d2d788c58019571bf9524 switched
the client to btcjson v2 and broke the wallet build.  This change is
the minimum amount of work to make wallet work again.

The rpc server still uses btcjson v1, so there will be 2 versions of
btcjson linked in the resulting binary.  This is not optimal but not
compiling is worse.
2015-04-06 13:14:01 -04:00
Manan Patel
3940e853f8 golinted waddrmgr package 2015-04-02 15:43:32 -05:00
Manan Patel
dfe617e05d create wallet package
This a refactor of the btcwallet main package to create a new wallet
package.
The main feature of this package is the integration of all the other
wallet components (waddrmgr, txstore, and chain) and the Wallet type is
'runnable', so it will be continuously updating itself against changes
notified by the remote btcd instance.

It also includes several methods which provide access to information
necessary to run a wallet RPC server.
2015-04-02 11:17:45 -07:00
Guilherme Salgado
2181f4859d votingpool: implement Pool.StartWithdrawal()
<http://opentransactions.org/wiki/index.php/Voting_Pool_Withdrawal_Process>

Also includes some refactorings and other improvements, including better docs
and a new error type (votingpool.Error) used for all votingpool-specific
errors.
2015-04-01 15:55:42 +01:00
Javed Khan
68a9168d9e Updated waddrmgr to manage account names 2015-03-19 06:28:23 +05:30
Javed Khan
85fe722e99 Mark used addresses as such 2015-03-11 01:23:46 +05:30
Josh Rickmar
338c711574 Prepare for release 0.5.1. 2015-03-06 12:16:58 -05:00
cjepson
cec3dc3e83 Add new --createtemp flag to btcwallet.
The createtemp flag is used to create a temporary simnet wallet for
use with btcsim or other testing suites.

The flag only works if the datadir and network to use it on (simnet)
are specified.

After starting btcwallet with the flag, the wallet immediately opens
and is functional.
2015-03-05 23:03:10 -05:00
Josh Rickmar
4d9c43593d Consolidate and optimize zero functions.
This introduce a new internal package to deal with the explicit
clearing of data (such as private keys) in byte slices, byte arrays
(32 and 64-bytes long), and multi-precision "big" integers.

Benchmarks from a xeon e3 (Xor is the zeroing funcion which Bytes
replaces):

BenchmarkXor32  30000000                52.1 ns/op
BenchmarkXor64  20000000                91.5 ns/op
BenchmarkRange32        50000000                31.8 ns/op
BenchmarkRange64        30000000                49.5 ns/op
BenchmarkBytes32        200000000               10.1 ns/op
BenchmarkBytes64        100000000               15.4 ns/op
BenchmarkBytea32        1000000000               2.24 ns/op
BenchmarkBytea64        300000000                4.46 ns/op

Removes an XXX from the votingpool package.
2015-03-05 21:32:33 -05:00
Javed Khan
62c7167504 Remove early return on empty rescan 2015-03-05 11:39:15 -06:00
Dave Collins
c8bdd71074 waddrmgr: Make create/update logic more explicit.
This commit makes the creation and updating of the address manager more
explicit so it's easier to upgrade in the future.

In particular, rather than treating the initial creation as an upgrade by
relying on creating the initial buckets on the fly on each load, the code
now explicitly provides distinct create and upgrade paths that are invoked
from the Create and Open functions, respectively.

It also adds some commented out sample code to illustrate how upgrades
should be done and a check to ensure bumping the version number without
writing upgrade code results in a new error, ErrUpgrade, being returned.

Finally, a test has been added for the new functionality.
2015-03-04 14:12:47 -06:00
Dave Collins
c078ee72eb Update golang.org/x/crypto import paths to new location. 2015-03-03 21:13:05 -06:00
Josh Rickmar
955bd65349 Whitespace fix. 2015-03-03 12:43:37 -05:00
Josh Rickmar
ce89c84b18 Prepare for release 0.5.0. 2015-03-03 12:41:48 -05:00
Josh Rickmar
3c5d165261 Update README for recent changes. 2015-03-02 17:49:57 -05:00
Josh Rickmar
0a7b10d051 Rescan after btcd reconnect.
Otherwise, if the websocket connection to btcd is lost and
reestablished, there is no sync to the current best block, and btcd
will not notify wallet of new relevant transactions.
2015-03-02 16:04:26 -05:00
Josh Rickmar
5ad37374fb Use the correct synced block when calculating confs.
This was previously using the most recently notified (by the chain
package) block, but transaction processing from this block may not be
finished yet.  Using this block's height to calculate the number of
confirmations is therefore incorrect, and can result in every RPC
handler missing transactions or returning transactions from the wrong
block.
2015-03-02 13:30:42 -05:00
Josh Rickmar
c9d9b4b610 Implement several btcd RPCs in wallet as well.
Wallet should handle these so that wallet clients don't end up
creating requests to btcd about the latest processed block, which is
not the same as wallet's most recently processed block.

By providing wallet clients with this info, we avoid a race where the
client thinks wallet has processed N blocks, but in fact is still
synced to N-1 (and perhaps currently processing transactions from
block N).  This can cause unexpected results for many of the
bitcoind-compatible RPC APIs due to their reliance on number of
confirmations, rather than using absolute block heights.
2015-03-02 13:22:46 -05:00
Javed Khan
45a33353b0 Turn echo off when reading passwords 2015-03-02 11:56:45 -06:00
Dave Collins
b44f48882f Add conversion from legacy keystore if it exists. 2015-03-02 11:56:45 -06:00
Dave Collins
8f9f53a618 Switch to new waddrmgr package
This commit converts the wallet to use the new secure hierarchical
deterministic wallet address manager package as well as the walletdb
package.

The following is an overview of modified functionality:

- The wallet must now be created before starting the executable
- A new flag --create has been added to create the new wallet using wizard
  style question and answer prompts
- Starting the process without an existing wallet will instruct now
  display a message to run it with --create
- Providing the --create flag with an existing wallet will simply show an
  error and return

In addition the snacl package has been modified to return the memory after
performing scrypt operations to the OS.

Previously a runtime.GC was being invoked which forced it to release the
memory as far as the garbage collector is concerned, but the memory was
not released back to the OS immediatley.  This modification allows the
memory to be released immedately since it won't be needed again until the
next wallet unlock.
2015-03-02 11:55:42 -06:00
Dave Collins
130e44c761 Move keystore to legacy directory. 2015-03-02 12:21:44 -05:00
David Hill
f704c58114 Use txscript.StandardVerifyFlags
By using txscript.StandardVerifyFlags when creating and validating
transactions, we can ensure the transactions successfully created
won't be rejected due to script policy.
2015-02-26 18:41:59 -05:00
Josh Rickmar
dcf64e2957 Use rescan for initial tx notification registrations.
Requires btcsuite/btcd#310.
2015-02-23 23:52:31 -05:00
Josh Rickmar
d9e2443002 Fix build.
This fixes the build after btcsuite/btcd#302, which renamed the
txscript constant ScriptCanonicalSignatures constant to
ScriptVerifyDERSignatures.
2015-02-23 22:44:04 -05:00
Dave Collins
8b6c161cbc Update btcws path import paths to new location. 2015-02-19 13:09:16 -06:00