Commit graph

925 commits

Author SHA1 Message Date
Josh Rickmar 61e96a69e4 Cleanup TransactionDetails RPC messages.
Remove the addresses field from TransactionDetails.Output.  It is
assumed that the caller is able to deserialize the transaction and
encode the output scripts to addresses, so this is unnecessary server
overhead and conflicts with the current API philosophy of not
duplicating data already included in another field.

Since there is no additional data included for outputs not controlled
by the wallet, remove the `mine` specifier from the Output message and
replace it with an output index.  Only include messages for controlled
outputs, rather than creating messages for both controlled and
uncontrolled outputs.  Rename the repeated field from `outputs` to
`credits` to be consistent with the `debits` field.

Bump major API version as this is a breaking change.

Closes #408.
2018-05-23 19:38:56 -07:00
Olaoluwa Osuntokun f13a081e31 wallet: add public method to expose the database 2018-05-23 19:38:56 -07:00
Olaoluwa Osuntokun 422c0d6c93 rpc: update address generation to new API 2018-05-23 19:38:56 -07:00
Olaoluwa Osuntokun 77b756c651 multi: point all imports towards roasbeef's forks 2018-05-23 19:38:56 -07:00
Olaoluwa Osuntokun 1b19a78b48 waddrmgr: properly convert imported addresses 2018-05-23 19:38:56 -07:00
Olaoluwa Osuntokun 6dfc793ad3 wallet: use intermediate hash cache during validateMsgTx 2018-05-23 19:38:56 -07:00
Olaoluwa Osuntokun 7cb1b47140 wtxmgr: when creating a TxRecord don't compute txid manually
This fixes a bug introduced by the new segwit behavior upstream in
btcd. Previously it was a nice optimization to skip the extra
serialization, and compute the txid manually from the serialized
transaction.

However, with segwit, doing that will generate an invalid txid, since
txid’s should ignore any witness data. Therefore, we now fallback to
using msgTx.TxSha() which serializes the transaction without witness
data before calculating the txid.
2018-05-23 19:38:56 -07:00
Olaoluwa Osuntokun d88739df8f wallet: add address type param to NewChangeAddress+NewAddress 2018-05-23 19:38:56 -07:00
Olaoluwa Osuntokun beb3231a03 wallet/txauthor: add ability to sign for nested+normal p2wkh
This commit enabled the wallet to properly spend nested and normal
p2wkh outputs under its control.

For regular p2wkh outputs, spending simply involves presenting the
original pub key, and signature as the witness data.

For nested p2wkh outputs, in addition to the above, the version zero
witness p2wkh witness program is placed in the sigScript in order to
allow clients who are aware of BIP 16 to validate the witness spend.
2018-05-23 19:38:56 -07:00
Olaoluwa Osuntokun 3d464a0bbc wallet: include input values during utxo selection and tx validation
When spending a segwit output, the wallet also needs the input value of
the previous output script. Therefore when selecting outputs the input
value is now returned. Additionally when validating newly signed
outputs the input value as also passed into `txscript.Engine`
2018-05-23 19:38:56 -07:00
Olaoluwa Osuntokun cb225e2add waddrmgr: add support for nested+regular witness key hash addresses
This commit introduces two new address types to the waddrmgr. The first
address type is the native p2wkh (pay-to-witness-key-hash) output type
introduced as part of BIP0141 and the segwit soft-fork. The second
address type is a p2wkh output nested *within* a regular p2sh output.
This second address allows older wallets which are not yet aware of the
new segwit output types to transparently pay to a wallet which does
support them. Additionally, using this nested p2wkh output the wallet
gains both the space+transaction fee savings, as well as the
malleability fixes.

Both address types have been implemented as special cases of the
ManagedPubKeyAddress since they share several traits, only
differentiating in the signing mechanism needed, and the concrete
implementation of btcutil.Address returned by the address.

Two new `addressType` constants have been added to waddrmgr’s db in
order to properly serialize and deserialize the new address types.
2018-05-23 19:38:56 -07:00
Olaoluwa Osuntokun a2ff118b25 wallet: fix compile errors under WIP segwit branch 2018-05-23 19:38:56 -07:00
Josh Rickmar 8e723ea454 Update deps to pull in latest gRPC release.
While here, pull in latest btcsuite and logrotate changes.  Update for
logrotate API changes.
2017-07-19 11:39:25 -04:00
Josh Rickmar 4222c0464a Update project dependencies.
One change of note is that this pulls in the new btclog-based logger
and removes the seelog dependency.
2017-06-20 09:34:45 -04:00
David Hill 15635025c4 Drop fastsha256 in favor of crypto/sha256 (#468) 2017-01-12 09:47:46 -05:00
Josh Rickmar 3e598f0f7b Fix reported spendable balances from coinbase outputs. (#467)
Previously, this would not increment the spendable balance for matured
coinbase outputs and would only increment the immature balance if the
output was still immature.
2017-01-10 13:02:03 -05:00
Vincenzo Di Somma 426c2e9f64 Minor fixes to Manager.Close (#464) 2016-12-13 11:02:23 -05:00
Josh Rickmar 3a7608a747 Remove -v from go test on travis. (#462)
This just clutters the logs and makes it more difficult to determine
what the actual failing test was. For tests that do fail, all logs
from the test are already outputted.
2016-12-07 10:41:06 -05:00
Dave Collins cc240cafc5 Update for wire.NewMsgTx API change. (#458)
Also, bump glide.lock to ensure the appropriate deps are pulled in.
2016-10-27 16:39:23 -04:00
Josh Rickmar 1cb3b8b29a Update project dependencies. (#456)
This updates both btcsuite and external dependencies to their latest
versions.  In particular, gRPC was updated to version 1.0.3 and bolt
to 1.3.0.

The walletrpc package needed to be regenerated for the gRPC update.

While here, update the Travis-CI script so this can be tested there.
2016-10-27 12:27:58 -04:00
DanielKrawisz 5e39e68778 Fix typo. (#453) 2016-08-15 11:27:32 -04:00
Dave Collins d76627e6d5 Update for recent chaincfg API changes. (#451)
Since the coinbase maturity is now allowed to be defined per chain and
the old blockchain.CoinbaseMaturity constant has been removed, this
updates the code accordingly.

Also, update glide.lock to use the required version of btcd.
2016-08-12 19:27:51 -05:00
Waldir Pimenta 33a6c2d8b6 add license title (#452)
background: https://github.com/btcsuite/btcd/pull/717
2016-08-11 20:46:09 -05:00
Dave Collins e92f94dcd1 Update for recent chainhash-related API changes. (#450)
This updates all code to make use of the new chainhash package since the
old wire.ShaHash type and related functions have been removed in favor
of the abstracted package.

Also, while here, rename all variables that included sha in their name
to include hash instead.

Finally, update glide.lock to use the required version of btcd, btcutil,
and btcrpcclient.
2016-08-08 14:49:09 -05:00
Josh Rickmar 959ef467da Set GO15VENDOREXPERIMENT=1 earlier in travis script. 2016-06-16 17:15:46 -04:00
Alex Yocom-Piatt 127246fb22 Fix logic for CreateTemp needing either appdata or datadir 2016-06-16 16:03:28 -05:00
Josh Rickmar f3df6c8bc9 Handle flags explicitly set to defaults.
This prevents treating a flag that was explicitly set to the default
as unchanged, since the explicit set is recorded in the new
*cfgutil.ExplicitString flag type.
2016-05-25 09:37:23 -04:00
Josh Rickmar 39fd9bd0f3 Switch from forked to upstream bolt package. 2016-05-06 14:42:00 -04:00
Josh Rickmar 7704a6d5c3 Switch from forked to upstream flags package.
In https://github.com/btcsuite/btcwallet/pull/419#issuecomment-212482492
I mentioned that btcwallet should wait until btcd also switches back
to upstream package paths so that duplicate packages are not included
in and bloat the btcwallet binary.  Even while btcd has not yet
switched to the upstream flags package, this change can still be made
now since it is only used by btcd's main package, which is not
included in btcwallet.
2016-05-06 12:41:42 -04:00
Josh Rickmar 00deaece98 Don't use go install $(glide novendor) in examples.
This will build all (non-vendored) packages recursively, even if they
are not used in any of the binaries (e.g. votingpool).  Additionally,
since a subshell is no longer used, the example commands can be run in
a Windows command prompt.  I don't encourage the use cmd.exe over
alternatives such as PowerShell, but there's no reason this command
could not be run there.
2016-05-06 10:10:13 -04:00
Josh Rickmar 250818957e Update to latest Go in Travis config. 2016-05-06 10:02:43 -04:00
Josh Rickmar 877947d6af Enable vendor experiment for Go 1.5 on Travis-CI.
Previously, the GO15VENDOREXPERIMENT environment variable was unset,
leaving travis to only use the vendored packages during builds for Go
1.6 which enabled the experiment by default.  Export the variable so
it also correctly tests under Go 1.5.
2016-05-06 09:55:41 -04:00
Josh Rickmar 268c466d69 Fix description for recommended install instructions.
The description had previously said that non-vendored packages were
not installed to $GOPATH/bin, but this is incorrect.  Remove this part
of the description so it includes all packages.
2016-05-05 17:41:59 -04:00
David Hill c292c68cba btcwallet: handle signal SIGTERM
When an OS reboots or shuts down, it sends all processes SIGTERM before
sending SIGKILL.  This allows btcwallet to do a proper shutdown which
most importantly closes the databases.
2016-05-05 16:50:03 -04:00
Josh Rickmar ce3bd39238 Unexport private methods from legacyrpc package.
This unexports every RPC handler function, as well as the
Server.PostClientRPC method which was only called by this package.

Fixes #435.
2016-05-05 11:28:18 -04:00
Josh Rickmar 4d51f8358f Use -b for deprecated --datadir short option.
When 29f31725ee deprecated the datadir
option, replacing it with --appdata/-A, the short --datadir option was
unintentinally changed from -b to -D.  It was previously changed to -b
in fda2e14b99 for consistency with
btcd's --datadir short option.

This change reverts the unintentional switch back to -D.
2016-05-04 17:45:52 -04:00
Josh Rickmar 146e92edc1 Fix credit slice indexing for transaction notifications.
Previously, this would always check a transaction output index against
the 0th credit's index.
2016-05-04 15:13:28 -04:00
Josh Rickmar fb06a6bd04 Cleanup TransactionDetails RPC messages.
Remove the addresses field from TransactionDetails.Output.  It is
assumed that the caller is able to deserialize the transaction and
encode the output scripts to addresses, so this is unnecessary server
overhead and conflicts with the current API philosophy of not
duplicating data already included in another field.

Since there is no additional data included for outputs not controlled
by the wallet, remove the `mine` specifier from the Output message and
replace it with an output index.  Only include messages for controlled
outputs, rather than creating messages for both controlled and
uncontrolled outputs.  Rename the repeated field from `outputs` to
`credits` to be consistent with the `debits` field.

Bump major API version as this is a breaking change.

Closes #408.
2016-04-28 11:53:03 -04:00
Josh Rickmar 5e3613775d Make default config relative to appdata directory.
This modifies the default configuration file to be relative to the
application data directory (configuratble with --appdata).  If there
is no configuration file in this directory, then no additional
configuration options are applied (it does not fallback to
~/.btcwallet/btcwallet.conf).

Fixes #421.
2016-04-28 11:21:44 -04:00
Josh Rickmar 178717341e Expand several more config options.
This adds home directory and OS environment variable expansion for the
following configuration options: configfile, appdatadir, rpccert,
rpckey.
2016-04-28 11:16:17 -04:00
Josh Rickmar f91303f507 Lookup actual home directory when expanding ~.
This fixes home directory expansion on Windows and OS X.  Previously
on these platforms, a leading ~ would expand to %LOCALAPPDATA% on
Windows or ~/Library/Application Support/ on OS X.

While here, add support for ~otheruser expansion to expand to
otheruser's home directory.
2016-04-28 11:16:17 -04:00
Josh Rickmar 42593c7dfd Remove code intended for Go 1.4 and older.
This change only removes optimizations for older Go releases that we
no longer support in the internal/zero package.  This package should
still continue to build on older releases.
2016-04-28 09:50:20 -04:00
Josh Rickmar b97d824975 Document need for GO15VENDOREXPERIMENT=1.
Fixes #425.
2016-04-28 09:38:40 -04:00
Josh Rickmar 1e8c735294 Fix example node.js client after breaking API change.
Fixes #426.
2016-04-28 09:36:58 -04:00
Josh Rickmar 2009ee0230 Set gRPC cipher suites sooner in node.js example.
While here, also rename OpenSSL to BoringSSL since gRPC Core has
switched to that.

Fixes #429.
2016-04-27 16:36:05 -04:00
Josh Rickmar 91093362f2 Convert project to glide.
Fixes #399.
2016-04-26 13:28:20 -04:00
Josh Rickmar a549b6908a Avoid calling getrawtransaction from signrawtransaction.
Replace all calls to getrawtransaction with gettxout.

As btcd no longer enables the transaction index by default,
getrawtransaction can no longer be depended on.  gettxout is safe to
use since it queries the utxo set.  This also means that it will
continue to work even when pruning is enabled.

This should be further improved in the future to not look up previous
output scripts over btcd rpc when they are already saved by the
wallet.

Fixes #410.
2016-04-22 12:00:48 -04:00
Josh Rickmar c82b8bae20 Ignore config in current directory by default.
Fixes #415.
2016-04-20 11:08:14 -04:00
Josh Rickmar 7b2e1ac282 Do not include zero value change outputs.
Due to the way dust is calculated, if the transaction relay fee is
zero, then a zero output amount is not considered dust.  As the
transaction authoring code used this dust check to determine whether a
change output can be included or not, it could create unnecessary
change outputs which return no value back to the wallet.  Prevent this
by including an explicit check for zero values.
2016-04-20 10:46:12 -04:00
Josh Rickmar f827743934 Modify goclean.sh to run go vet recursively.
Fix remaining issues discovered by vet.
2016-04-19 17:02:51 -04:00