Commit graph

1501 commits

Author SHA1 Message Date
Josh Rickmar
3143ec328e Correctly serialize pubkeys for imported keys. 2013-11-20 10:47:44 -05:00
Josh Rickmar
455a376df8 Add hex string of pubkey to AddressInfo. 2013-11-20 10:17:49 -05:00
David Hill
89e3054bc5 socks5/tor proxy support 2013-11-19 20:54:48 -05:00
Josh Rickmar
1ff67707e4 Fix issues found by golint. 2013-11-19 20:46:16 -05:00
Josh Rickmar
7e0a24950a Disable dumpwallet RPC handler that snuck in.
We do not support this yet, and need to match bitcoin'd behavior
before the function is added back to the RPC handler map.
2013-11-19 20:44:37 -05:00
Josh Rickmar
00fe439670 Add private key import and export support.
This adds the necessary bits for handling importing addresses for the
wallet file format, as well as implementing the importprivkey and
dumpprivkey RPC requests.

Initial code by dhill.
2013-11-19 20:18:11 -05:00
Josh Rickmar
0bd877237f Add missing space for basic HTTP auth header. 2013-11-19 18:25:42 -05:00
Josh Rickmar
5dbf69d23e Enable TLS support for btcd websocket connections.
This adds an additional config option, -cafile, to specify the root
certificates checked when verifying a btcd TLC connection.  btcd will
now automatically generate certs in
~/.btcd/data/{main,test}net/rpc.cert, and this file should be copied
to ~/.btcwallet/cert.pem.

The -btcdport option is also gone now, and replaced with -connect (or
-c), to specify both the hostname/ip and port of the server running
btcd.
2013-11-19 12:21:54 -05:00
Josh Rickmar
474106a757 Sending and receving from chans on the same goroutine is a bad idea. 2013-11-18 16:37:28 -05:00
Josh Rickmar
28087af90b Add handling for standard bitcoind-style RPC.
With the exception of the createencryptedwallet extension (which is
required to make a wallet), all websocket-specific handlers are now
only available from a websocket connection, and standard RPC requests
are handled with a normal HTTP request and reply.

As an added bonus, listening on IPv6 now works.
2013-11-18 15:51:50 -05:00
David Hill
37109bfe0d update tests to use the new Account type and catch rand.Read errors 2013-11-15 12:03:52 -05:00
David Hill
fcc4871351 check rand.Read for errors 2013-11-15 11:59:37 -05:00
Josh Rickmar
ef49eca365 more wallet -> account renames 2013-11-15 11:44:24 -05:00
David Hill
9c827a824f Rename BtcWallet to Account and put it in its own file. 2013-11-14 12:15:16 -05:00
Josh Rickmar
c138a663e1 Return errors if rand.Read fails. 2013-11-13 17:25:50 -05:00
Josh Rickmar
56d732ff3e Link to btcdsuite on opensource.conformal.com. 2013-11-13 15:04:38 -05:00
Josh Rickmar
a6c8800fba Prepare for release 0.1.0. 2013-11-13 14:08:35 -05:00
Josh Rickmar
1ddd9c38dc Use btcutil.AppDataDir for data dir. 2013-11-12 15:25:56 -05:00
Josh Rickmar
503f591e88 Process tx notifications before new blocks.
This change modifies the order in which transaction to watched
addresses are processed and when frontend notifications occur.  Due to
btcd notifying all transactions before sending the blockconnected
notification, the UTXO and transaction stores can be modified without
sending any frontend notifications, and then a single frontend
notification is sent when the blockconnected notification arrives.

The order in which each file is synced to disk was also changed to
write out the UTXO and transaction stores before writing the wallet.
This is to prevent a race where wallet closes after writing the dirty
wallet, but before the dirty UTXO store is written.  In this
situation, newly added UTXOs will be missed and not found again on the
next wallet open during the rescan.  Writing the wallet (which holds
the synced-to-block information) last prevents this.

An issue where the unconfirmed change UTXO created from a new
transaction never being properly notified to frontends is fixed now as
well.
2013-11-12 14:53:38 -05:00
Josh Rickmar
b7aec7f7a1 Type assert GetNewAddressCmd correctly. 2013-11-12 12:40:20 -05:00
Josh Rickmar
e761884c53 Add missing word in README. 2013-11-12 12:11:29 -05:00
Josh Rickmar
437772fcb1 Fix tests. 2013-11-12 12:08:10 -05:00
Josh Rickmar
be26855266 Clean up replying to frontend commands.
This change moves the handlers to a map (instead of falling through a
switch statement), and updates each handler to use a btcjson.Cmd
instead of passing parameters in a btcjson.Message manually.

Plenty of comments were also added, which should also make the code
much more understandable.
2013-11-12 12:01:32 -05:00
Josh Rickmar
e9b7fd2fcf Huge cleanup for decreased eye bleeding. 2013-11-11 15:30:50 -05:00
Josh Rickmar
5bd82577a2 Remove old TODO comment. 2013-11-11 15:17:27 -05:00
Josh Rickmar
30db3490c0 Use btcws for parsing btcd notifications. 2013-11-08 12:45:18 -05:00
Josh Rickmar
cdd9bea5db Log sent tx ids to debug.
While here, add createdTx to unmined pool for 'sendfrom' commands as
well, instead of just 'sendmany'.
2013-11-07 15:29:17 -05:00
Josh Rickmar
3cd9a96dc7 Unlock mutex before function return. 2013-11-06 14:12:52 -05:00
Josh Rickmar
85219a70d3 Update for new btcd notifications.
This removes the enforced check for the spent field for tx-to-me
notifications, as this is no longer sent, and should be calculated by
wallet (not done yet).  Additionally, the full CreatedTx information
is saved with the unmined tx map, so when a tx is mined, information
about which inputs and ouputs it creates that are relevant to the
wallet can be used.
2013-11-06 14:05:14 -05:00
Josh Rickmar
f809638c72 Write dirty wallet to disk if a change address is added. 2013-11-06 12:52:01 -05:00
Josh Rickmar
e65206f752 Begin using btcws.
This change begins using the btcws package for marshaling custom
commands used for websocket connections to btcd.
2013-11-06 11:23:30 -05:00
Josh Rickmar
f3408bad91 Add support for compressed pubkeys (used by default).
Wallets that include compressed pubkeys are no longer compatible with
armory, however, imported wallets from armory (using uncompressed
pubkeys) are still valid.
2013-11-05 11:08:02 -05:00
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
David Hill
de76220c6b Just exit if we cannot start the listener 2013-10-29 23:53:20 -04:00
Josh Rickmar
9094bcde02 Remove unused const. 2013-10-29 11:02:30 -04:00
Josh Rickmar
91b4a5711c Fix logger formatting.
This change copies the behavior of btcd for using seelog for logging,
including making timestamps human readable, and setting the default
logging level to info.

Fixes #8.
2013-10-29 10:38:51 -04:00
Josh Rickmar
68cbb4192c Notify all frontends of new accounts.
When a new account (wallet) is created with the createencryptedwallet
JSON method, all frontends, including the one requesting the wallet,
must be notified of this new account and its balance (probably zero).

This removes the need for frontends to poll and check for any new
accounts.
2013-10-29 09:35:19 -04:00
Josh Rickmar
b2263ba6f5 Notify connecting frontends of btcd connect state.
This change automatically sends the btcdconnected notification for all
frontends as they connect to btcwallet.  The old btcdconnected command
has been removed, as it is no longer needed for clients to explicitly
request this information any longer.
2013-10-29 09:19:11 -04:00
Josh Rickmar
0e26aa7452 Update Windows Getting Started instructions.
To start btcd and btcwallet with all the right settings for testnet,
the Btcd Suite batch file should be run from the start menu rather
than btcd and btcwallet individually.  Update the README to reflect
that.
2013-10-29 09:03:10 -04:00
Josh Rickmar
540cbb0930 Greatly simplify design.
This change removes a lot of unnecessary and complicated locking (if
serializing requests is needed in the future, a goroutine will be used
instead) and also shifts the heavy lifting from frontends to btcwallet
itself to handle any notifications when they can be properly handled.
Although it's still legal to, frontends no longer need to explicitly
request account balances as these are calculated and sent as an async
notification on frontend connect, and these notifications will only
occur if btcd is currently connected.  Likewise, when btcd connects,
all frontends are immediately notified of all notifications that
require btcd information, such as the current block height for
calculating account balances.
2013-10-29 02:43:03 -04:00
Josh Rickmar
f6af03bf98 Set a default fee of 0.0001 BTC. 2013-10-29 02:17:49 -04:00
Josh Rickmar
bff2c850d5 stupid markdown parser is stupid. 2013-10-28 20:29:53 -04:00
Josh Rickmar
be95e8a050 Fix formatting issues. 2013-10-28 20:16:50 -04:00
Josh Rickmar
5ac395714a Modify README.md to reflect recent changes. 2013-10-28 20:05:31 -04:00
Josh Rickmar
aad61db6d0 Fix some remaining issues with reported balances.
CalculateBalance now works correctly: if confirmations is 0, all UTXOs
will be used for the balance.  Otherwise, unconfirmed UTXOs will be
exclused.  1 confirmation will allow the UTXO height and current block
height to be equal.  Even though the difference is zero, the
transaction including the UTXO has been mined into one block.

This change also remove extraneous account balance notifications for
connected and disconnected blocks.
2013-10-28 17:42:19 -04:00
Josh Rickmar
b34563bbd9 Request updates for new change addresses.
When sending a new transaction, the change address must receive the
same updates as explicitly-generated addresses.  Without this
notification, the unconfirmed UTXO will never become confirmed as the
notification will never be received.

This fixes the issue where change UTXOs never move from "Unconfirmed"
to "Balance" in btcgui.
2013-10-28 14:13:20 -04:00
Josh Rickmar
dea80bae9b Use bitcoin-qt balance/unconfirmed nomenclature.
bitcoin-qt uses "Balance" to mean all spendable outputs that have been
mined into a block, while "Unconfirmed" only refers to outputs that
have not yet been mined into a block.  This change copies that
behavior, instead of the previous required 6 blocks to be confirmed.
2013-10-28 14:10:37 -04:00
Josh Rickmar
851a9d6e41 Simplify txToPairs function signature.
This moves the non-error return values for txToPairs into a new
struct, createdTx, and adds an additional value for the payment
address string.
2013-10-28 11:24:50 -04:00
Josh Rickmar
3c390364d7 Switch some integers from unsigned to signed.
This change switches the time fields (firstSeen/lastSeen) of an
address from uint64 to int64, to be compatible with (time.Time).Unix,
as well as changing the block height fields (firstBlock/lastBlock)
from uint32 to int32, since block height is normally represented
signed.
2013-10-28 09:15:26 -04:00
Josh Rickmar
cafd4666d9 Don't attempt tx resend if unmined in a new block.
Any and all resending should be handled directly by btcd, and btcd
ignores any duplicate transactions when adding to mempool anyways.  A
set of unmined txs is still kept and send to btcd in case of btcd
restarting and losing wallet transactions from its mempool.
2013-10-25 18:59:21 -04:00