Commit graph

53 commits

Author SHA1 Message Date
Joost Jager b718296188
wallet: return full tx from SendOutputs 2018-11-06 10:40:37 +01:00
Olaoluwa Osuntokun b0b64d3bbd multi: update due to latest API changes 2018-05-23 19:38:56 -07:00
Olaoluwa Osuntokun 7770cac383 multi: switch import paths back to upstream 2018-05-23 19:38:56 -07:00
Olaoluwa Osuntokun 115d7d17f2 rpc: update rpc servers to default to waddrmgr.KeyScopeBIP0044 2018-05-23 19:38:56 -07:00
Olaoluwa Osuntokun aa42e17e2f rpc/legacyrpc: update method to use default fee rate 2018-05-23 19:38:56 -07:00
Olaoluwa Osuntokun a0abd3632c multi: update to new upstream btcsuite/btcd API's 2018-05-23 19:38:56 -07:00
Olaoluwa Osuntokun 3dc7a8529c multi: switch all imports to roasbeef's forks 2018-05-23 19:38:56 -07:00
Alex b5873a5b2c Finish integration of Neutrino; still untested. 2018-05-23 19:38:56 -07:00
Alex 32adc3c43f Make rescan a struct, add spending tx to GetUtxo, start integration. 2018-05-23 19:38:56 -07:00
Alex e273e178dd Repoint repo to btcsuite on btcwalletln, and a few rebase fixes. 2018-05-23 19:38:56 -07:00
Josh Rickmar 4656a00705 Improve wallet atomicity.
This changes the database access APIs and each of the "manager"
packages (waddrmgr/wstakemgr) so that transactions are opened (only)
by the wallet package and the namespace buckets that each manager
expects to operate on are passed in as parameters.

This helps improve the atomicity situation as it means that many
calls to these APIs can be grouped together into a single
database transaction.

This change does not attempt to completely fix the "half-processed"
block problem.  Mined transactions are still added to the wallet
database under their own database transaction as this is how they are
notified by the consensus JSON-RPC server (as loose transactions,
without the rest of the block that contains them). It will make
updating to a fixed notification model significantly easier, as the
same "manager" APIs can still be used, but grouped into a single
atomic transaction.
2018-05-23 19:38:56 -07:00
Olaoluwa Osuntokun 2fb155724f rpc/legacy: update to latest btcrpcclient API 2018-05-23 19:38:56 -07:00
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 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
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
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
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
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 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 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 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 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 86420c4890 Regenerate walletrpc package. (#418)
Fixes build when using newer versions of the grpc packages.
2016-04-19 09:12:17 -04:00
Josh Rickmar 3d7b8c6f40 Resurrect rpchelp_test.go
This file was accidentally removed when the gRPC server was introduced
and the legacy JSON-RPC server was moved to the legacyrpc package.
2016-04-13 10:44:43 -04:00
John C. Vernaleo c2ed8ffc2b Add goclean.sh script from btcd.
This commit corrects various things found by the static checkers
(comments, unkeyed fields, return after some if/else).

Add generated files and legacy files to the whitelist to be ignored.

Catch .travis.yml up with btcd so goclean can be run.
2016-03-31 11:43:54 -04:00
Josh Rickmar 5d6392b65d Fix race in TestThrottle test.
Closes #355.
2016-03-16 11:55:27 -04:00
Josh Rickmar 6cf22b7944 Remove legacy JSON-RPC notifications.
These notifications were added to support real time updates for
btcgui.  As the btcgui project is no longer being developed, there are
no more consumers of this API, and it makes sense to remove them given
their various issues (the largest being that notifiations are sent
unsubscribed to clients that may never be interrested in them).

A new notification server has already been added to the wallet package
to handle notifications in a RPC-server agnostic way.  This server is
the means by which the wallet notifies changes for gRPC clients.  If
per-client registered notifications are to be re-added for the
JSON-RPC server, they should be integrated with the new notification
server rather than using this legacy code.
2016-03-11 14:14:33 -05:00
Josh Rickmar 2b79aad79c Stop wallet and close wallet DB on interrupt.
This corrects and simplifies the shutdown logic for interrupts, the
walletrpc.WalletLoaderService/CloseWallet RPC, and the legacy stop RPC
by both stopping all wallet processes and closing the wallet database.
It appears that this behavior broke as part of the wallet package
refactor, causing occasional nil pointer panics and memory faults when
closing the wallet database with active transactions.

Fixes #282.

Fixes #283.
2016-03-10 23:10:18 -05:00
Josh Rickmar d09c2a84c1 Protect the relay fee field with a mutex.
This prevents races when setting a new relay fee through the legacy
RPC server (settxfee).

Fixes #379.
2016-03-09 14:54:09 -05:00
Janus Troelsen 397beadfd5 Fix spelling in legacy test and docs using aspell 2016-03-09 20:39:03 +01:00
Josh Rickmar f084802fec Refactor wallet transaction creation code.
This began as a change to improve the fee calculation code and evolved
into a much larger refactor which improves the readability and
modularity of all of the transaction creation code.

Transaction fee calculations have been switched from full increments
of the relay fee to a proportion based on the transaction size.  This
means that for a relay fee of 1e3 satoshis/kB, a 500 byte transaction
is only required to pay a 5e2 satoshi fee and a 1500 byte transaction
only need pay a 1.5e3 fee.  The previous code would end up estimating
these fees to be 1e3 and 2e3 respectively.

Because the previous code would add more fee than needed in almost
every case, the transaction size estimations were optimistic
(best/smallest case) and signing was done in a loop where the fee was
incremented by the relay fee again each time the actual size of the
signed transaction rendered the fee too low.  This has switched to
using worst case transaction size estimates rather than best case, and
signing is only performed once.

Transaction input signature creation has switched from using
txscript.SignatureScript to txscript.SignTxOutput.  The new API is
able to redeem outputs other than just P2PKH, so the previous
restrictions about P2SH outputs being unspendable (except through the
signrawtransaction RPC) no longer hold.

Several new public packages have been added:

wallet/txauthor - transaction authoring and signing
wallet/txfees - fee estimations and change output inclusion
wallet/txrules - simple consensus and mempool policy rule checks

Along with some internal packages:

wallet/internal/txsizes - transaction size estimation
internal/helpers - context free convenience functions

The txsizes package is internal as the estimations it provides are
specific for the algorithms used by these new packages.
2016-03-08 17:42:27 -05:00
John C. Vernaleo 82e743754f Rename some rpc commands to something more generic.
StartBtcdRpc becomes StartConsensusRpc.

This is useful for forks such as decred or if someone were to write
another compatible server.

Bump up the api version as this is a change.
2016-03-03 14:22:14 -05:00
Josh Rickmar 5140086f6e Use LICENSE file and short license headers. 2016-02-28 22:22:34 -05:00
Josh Rickmar 620a3c649e Add VersionService to gRPC server to query server versions.
Fixes #375.
2016-02-24 00:22:37 -05:00
Josh Rickmar f03556b2f9 Document changes to the NextAddress RPC. 2016-02-23 19:39:53 -05:00
Josh Rickmar 8455454ed5 Add Kind enum to NextAddress request.
Fixes #371.
2016-02-23 18:03:39 -05:00
Josh Rickmar b286d697c9 Regenerate gRPC files from descriptor. 2016-02-23 17:16:34 -05:00
Josh Rickmar 0a9645326d Follow specification for FundTransaction RPC.
The specification states that even when the target output amount
cannot be reached, all available outputs should still be included in
the response and it is up to the caller to check that the target can
be satisified or not.  Follow this behavior by not erroring when the
target was not met.
2016-02-23 12:55:13 -05:00
Josh Rickmar d2e93f9427 Make walletpassphrase with timeout=0 never lock the wallet.
This broke when the Unlock API changed to replace the timeout in
seconds with a time.Time channel.
2016-02-15 11:35:28 -05:00
Josh Rickmar 4171638553 Fix several typos in documentation and comments. 2016-02-12 11:58:38 -05:00
Josh Rickmar da145968c4 Create results for each wallet.TransactionSummary output.
The gRPC server requires this as it must include the properties of
every transaction output, not just those that are controlled by the
wallet.
2016-02-12 11:44:36 -05:00
Josh Rickmar 102cd553c5 Set account name for gettransaction results.
This only sets the name for any kind of "receiving" category
(receive/immature/generate).

Fixes #360.
2016-02-09 09:41:39 -05:00
Josh Rickmar b480a0a09d Set account field in listtransactions result.
This field is only set for non-"send" categories since the wallet does
not track a "from account" like Core's wallet does.

Fixes #353.
2016-02-06 14:59:32 -05:00
Josh Rickmar cc97e063b8 Do not error for empty tx comments.
This prevents the server from returning an error when empty strings
are passed as parameters for transaction comments for the
sendfrom/sendmany/sendtoaddress RPCs.  Non-empty strings will still
cause errors since transaction comments are not saved.

Fixes #356.
2016-02-02 09:56:02 -05:00