Skip to content

Commit

Permalink
Merge branch 'upstream' into master
Browse files Browse the repository at this point in the history
Conflicts:
	README.md
	chain/chain.go
	cmd/dropwtxmgr/main.go
	config.go
	dcrwallet.go
	internal/legacy/keystore/keystore.go
	internal/legacy/keystore/keystore_test.go
	internal/legacy/rename/rename_unix.go
	internal/rpchelp/genrpcserverhelp.go
	internal/rpchelp/helpdescs_en_US.go
	internal/rpchelp/methods.go
	internal/zero/array.go
	internal/zero/benchmark_test.go
	internal/zero/slice.go
	internal/zero/slice14.go
	internal/zero/zero_test.go
	log.go
	netparams/params.go
	params.go
	rpc/documentation/README.md
	rpc/documentation/api.md
	rpc/legacyrpc/errors.go
	rpc/legacyrpc/methods.go
	rpc/legacyrpc/rpcserver_test.go
	rpc/legacyrpc/server.go
	rpcserver.go
	sample-dcrwallet.conf
	version.go
	votingpool/common_test.go
	votingpool/db.go
	votingpool/db_wb_test.go
	votingpool/doc.go
	votingpool/error.go
	votingpool/error_test.go
	votingpool/example_test.go
	votingpool/factory_test.go
	votingpool/input_selection_wb_test.go
	votingpool/internal_test.go
	votingpool/pool.go
	votingpool/pool_test.go
	votingpool/pool_wb_test.go
	votingpool/test_data_test.go
	votingpool/withdrawal.go
	votingpool/withdrawal_test.go
	votingpool/withdrawal_wb_test.go
	waddrmgr/address.go
	waddrmgr/common_test.go
	waddrmgr/db.go
	waddrmgr/doc.go
	waddrmgr/error.go
	waddrmgr/error_test.go
	waddrmgr/internal_test.go
	waddrmgr/manager.go
	waddrmgr/manager_test.go
	waddrmgr/sync.go
	wallet/chainntfns.go
	wallet/createtx.go
	wallet/createtx_test.go
	wallet/createtx_test_disabled.go
	wallet/doc.go
	wallet/loader.go
	wallet/notifications.go
	wallet/rescan.go
	wallet/wallet.go
	walletdb/bdb/db.go
	walletdb/bdb/doc.go
	walletdb/bdb/driver.go
	walletdb/bdb/driver_test.go
	walletdb/bdb/interface_test.go
	walletdb/db_test.go
	walletdb/doc.go
	walletdb/example_test.go
	walletdb/interface.go
	walletdb/interface_test.go
	walletsetup.go
	wtxmgr/db.go
	wtxmgr/doc.go
	wtxmgr/example_test.go
	wtxmgr/query.go
	wtxmgr/query_test.go
	wtxmgr/tx.go
	wtxmgr/tx_test.go
	wtxmgr/unconfirmed.go
  • Loading branch information
jrick committed Mar 24, 2016
2 parents 0d61bd9 + fcccae3 commit 2133b7b
Show file tree
Hide file tree
Showing 110 changed files with 1,890 additions and 3,337 deletions.
14 changes: 14 additions & 0 deletions LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
Copyright (c) 2013-2016 The btcsuite developers
Copyright (c) 2015-2016 The Decred developers

Permission to use, copy, modify, and distribute this software for any
purpose with or without fee is hereby granted, provided that the above
copyright notice and this permission notice appear in all copies.

THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
16 changes: 5 additions & 11 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ dcrwallet is a daemon handling decred wallet functionality for a
single user. It acts as both an RPC client to dcrd and an RPC server
for wallet clients and legacy RPC applications.

Public and private keys are derived using the heirarchical
Public and private keys are derived using the hierarchical
deterministic format described by
[BIP0032](https://github.com/bitcoin/bips/blob/master/bip-0032.mediawiki).
Unencrypted private keys are not supported and are never written to
Expand Down Expand Up @@ -50,12 +50,6 @@ Wallet clients can use one of two RPC servers:
notifications for changes to the wallet, this is the RPC server to use.
The gRPC server is documented [here](./rpc/documentation/README.md).

Mainnet support is currently disabled by default. Use of dcrwallet on
mainnet requires passing the `--mainnet` flag on the command line or
adding `mainnet=1` to the configuration file. Mainnet will be enabled
by default in a future release after further database changes and
testing.

## Installation and updating

### Windows - MSIs Available
Expand All @@ -80,14 +74,14 @@ go get -u -v github.com/decred/dcrwallet/...

## Getting Started

The following instructions detail how to get started with dcrwallet
connecting to a localhost dcrd. Commands should be run in `cmd.exe`
or PowerShell on Windows, or any terminal emulator on *nix.
The following instructions detail how to get started with dcrwallet connecting
to a localhost dcrd. Commands should be run in `cmd.exe` or PowerShell on
Windows, or any terminal emulator on *nix.

- Run the following command to start dcrd:

```
dcrd --testnet -u rpcuser -P rpcpass
dcrd -u rpcuser -P rpcpass
```

- Run the following command to create a wallet:
Expand Down
20 changes: 4 additions & 16 deletions chain/chain.go
Original file line number Diff line number Diff line change
@@ -1,19 +1,7 @@
/*
* Copyright (c) 2013-2015 The btcsuite developers
* Copyright (c) 2015-2016 The Decred developers
*
* Permission to use, copy, modify, and distribute this software for any
* purpose with or without fee is hereby granted, provided that the above
* copyright notice and this permission notice appear in all copies.
*
* THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
* WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
* MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
* ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
* WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
* ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
* OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
*/
// Copyright (c) 2013-2015 The btcsuite developers
// Copyright (c) 2015-2016 The Decred developers
// Use of this source code is governed by an ISC
// license that can be found in the LICENSE file.

package chain

Expand Down
18 changes: 3 additions & 15 deletions chain/log.go
Original file line number Diff line number Diff line change
@@ -1,18 +1,6 @@
/*
* Copyright (c) 2013, 2014 The btcsuite developers
*
* Permission to use, copy, modify, and distribute this software for any
* purpose with or without fee is hereby granted, provided that the above
* copyright notice and this permission notice appear in all copies.
*
* THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
* WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
* MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
* ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
* WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
* ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
* OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
*/
// Copyright (c) 2013-2014 The btcsuite developers
// Use of this source code is governed by an ISC
// license that can be found in the LICENSE file.

package chain

Expand Down
14 changes: 2 additions & 12 deletions cmd/dropwtxmgr/main.go
Original file line number Diff line number Diff line change
@@ -1,17 +1,7 @@
// Copyright (c) 2015 The btcsuite developers
// Copyright (c) 2015-2016 The Decred developers
//
// Permission to use, copy, modify, and distribute this software for any
// purpose with or without fee is hereby granted, provided that the above
// copyright notice and this permission notice appear in all copies.
//
// THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
// WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
// MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
// ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
// WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
// ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
// OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
// Use of this source code is governed by an ISC
// license that can be found in the LICENSE file.

package main

Expand Down
30 changes: 6 additions & 24 deletions config.go
Original file line number Diff line number Diff line change
@@ -1,19 +1,7 @@
/*
* Copyright (c) 2013-2016 The btcsuite developers
* Copyright (c) 2015 The Decred developers
*
* Permission to use, copy, modify, and distribute this software for any
* purpose with or without fee is hereby granted, provided that the above
* copyright notice and this permission notice appear in all copies.
*
* THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
* WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
* MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
* ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
* WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
* ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
* OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
*/
// Copyright (c) 2013-2016 The btcsuite developers
// Copyright (c) 2015 The Decred developers
// Use of this source code is governed by an ISC
// license that can be found in the LICENSE file.

package main

Expand All @@ -39,7 +27,6 @@ const (
defaultLogLevel = "info"
defaultLogDirname = "logs"
defaultLogFilename = "dcrwallet.log"
defaultDisallowFree = false
defaultRPCMaxClients = 10
defaultRPCMaxWebsockets = 25
defaultEnableStakeMining = false
Expand Down Expand Up @@ -97,7 +84,7 @@ type config struct {
TicketMaxPrice float64 `long:"ticketmaxprice" description:"The maximum price the user is willing to spend on buying a ticket"`

// RPC client options
RPCConnect string `short:"c" long:"rpcconnect" description:"Hostname/IP and port of dcrd RPC server to connect to (default localhost:19109, mainnet: localhost:9109, simnet: localhost:18556)"`
RPCConnect string `short:"c" long:"rpcconnect" description:"Hostname/IP and port of dcrd RPC server to connect to (default localhost:9109, testnet: localhost:19109, simnet: localhost:18556)"`
CAFile string `long:"cafile" description:"File containing root certificates to authenticate a TLS connections with dcrd"`
DisableClientTLS bool `long:"noclienttls" description:"Disable TLS for the RPC client -- NOTE: This is only allowed if the RPC client is connecting to localhost"`
DcrdUsername string `long:"dcrdusername" description:"Username for dcrd authentication"`
Expand Down Expand Up @@ -129,9 +116,6 @@ type config struct {
// These options will change (and require changes to config files, etc.)
// when the new gRPC server is enabled.
ExperimentalRPCListeners []string `long:"experimentalrpclisten" description:"Listen for RPC connections on this interface/port"`

// Deprecated options
KeypoolSize uint `short:"k" long:"keypoolsize" description:"DEPRECATED -- Maximum number of addresses in keypool"`
}

// cleanAndExpandPath expands environement variables and leading ~ in the
Expand Down Expand Up @@ -255,7 +239,6 @@ func loadConfig() (*config, []string, error) {
WalletPass: wallet.InsecurePubPassphrase,
RPCKey: defaultRPCKeyFile,
RPCCert: defaultRPCCertFile,
DisallowFree: defaultDisallowFree,
LegacyRPCMaxClients: defaultRPCMaxClients,
LegacyRPCMaxWebsockets: defaultRPCMaxWebsockets,
EnableStakeMining: defaultEnableStakeMining,
Expand Down Expand Up @@ -345,7 +328,6 @@ func loadConfig() (*config, []string, error) {
// Choose the active network params based on the selected network.
// Multiple networks can't be selected simultaneously.
numNets := 0
activeNet = &netparams.MainNetParams
if cfg.TestNet {
activeNet = &netparams.TestNetParams
numNets++
Expand All @@ -355,7 +337,7 @@ func loadConfig() (*config, []string, error) {
numNets++
}
if numNets > 1 {
str := "%s: The mainnet, testnet, and simnet params can't be used " +
str := "%s: The testnet and simnet params can't be used " +
"together -- choose one"
err := fmt.Errorf(str, "loadConfig")
fmt.Fprintln(os.Stderr, err)
Expand Down
56 changes: 19 additions & 37 deletions dcrwallet.go
Original file line number Diff line number Diff line change
@@ -1,19 +1,7 @@
/*
* Copyright (c) 2013-2015 The btcsuite developers
* Copyright (c) 2015 The Decred developers
*
* Permission to use, copy, modify, and distribute this software for any
* purpose with or without fee is hereby granted, provided that the above
* copyright notice and this permission notice appear in all copies.
*
* THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
* WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
* MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
* ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
* WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
* ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
* OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
*/
// Copyright (c) 2013-2015 The btcsuite developers
// Copyright (c) 2015 The Decred developers
// Use of this source code is governed by an ISC
// license that can be found in the LICENSE file.

package main

Expand All @@ -31,7 +19,6 @@ import (
"github.com/decred/dcrwallet/chain"
"github.com/decred/dcrwallet/rpc/legacyrpc"
"github.com/decred/dcrwallet/wallet"
"github.com/decred/dcrwallet/walletdb"
)

var (
Expand Down Expand Up @@ -124,21 +111,8 @@ func walletMain() error {
go rpcClientConnectLoop(legacyRPCServer, loader)
}

var closeDB func() error
defer func() {
if closeDB != nil {
err := closeDB()
if err != nil {
log.Errorf("Unable to close wallet database: %v", err)
}
}
}()
loader.RunAfterLoad(func(w *wallet.Wallet, db walletdb.DB) {
loader.RunAfterLoad(func(w *wallet.Wallet) {
startWalletRPCServices(w, rpcs, legacyRPCServer)
closeDB = func() error {
w.CloseDatabases()
return db.Close()
}
})

if !cfg.NoInitialLoad {
Expand All @@ -151,7 +125,15 @@ func walletMain() error {
}
}

// Shutdown the server(s) when interrupt signal is received.
// Add interrupt handlers to shutdown the various process components
// before exiting. Interrupt handlers run in LIFO order, so the wallet
// (which should be closed last) is added first.
addInterruptHandler(func() {
err := loader.UnloadWallet()
if err != nil && err != wallet.ErrNotLoaded {
log.Errorf("Failed to close wallet: %v", err)
}
})
if rpcs != nil {
addInterruptHandler(func() {
// TODO: Does this need to wait for the grpc server to
Expand All @@ -162,15 +144,15 @@ func walletMain() error {
})
}
if legacyRPCServer != nil {
go func() {
<-legacyRPCServer.RequestProcessShutdown()
simulateInterrupt()
}()
addInterruptHandler(func() {
log.Warn("Stopping legacy RPC server...")
legacyRPCServer.Stop()
log.Info("Legacy RPC server shutdown")
})
go func() {
<-legacyRPCServer.RequestProcessShutdown()
simulateInterrupt()
}()
}

<-interruptHandlersDone
Expand Down Expand Up @@ -208,7 +190,7 @@ func rpcClientConnectLoop(legacyRPCServer *legacyrpc.Server, loader *wallet.Load
}
}
mu := new(sync.Mutex)
loader.RunAfterLoad(func(w *wallet.Wallet, db walletdb.DB) {
loader.RunAfterLoad(func(w *wallet.Wallet) {
mu.Lock()
associate := associateRPCClient
mu.Unlock()
Expand Down
18 changes: 3 additions & 15 deletions internal/cfgutil/file.go
Original file line number Diff line number Diff line change
@@ -1,18 +1,6 @@
/*
* Copyright (c) 2015 The btcsuite developers
*
* Permission to use, copy, modify, and distribute this software for any
* purpose with or without fee is hereby granted, provided that the above
* copyright notice and this permission notice appear in all copies.
*
* THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
* WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
* MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
* ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
* WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
* ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
* OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
*/
// Copyright (c) 2015 The btcsuite developers
// Use of this source code is governed by an ISC
// license that can be found in the LICENSE file.

package cfgutil

Expand Down
18 changes: 3 additions & 15 deletions internal/cfgutil/normalization.go
Original file line number Diff line number Diff line change
@@ -1,18 +1,6 @@
/*
* Copyright (c) 2015 The btcsuite developers
*
* Permission to use, copy, modify, and distribute this software for any
* purpose with or without fee is hereby granted, provided that the above
* copyright notice and this permission notice appear in all copies.
*
* THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
* WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
* MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
* ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
* WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
* ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
* OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
*/
// Copyright (c) 2015 The btcsuite developers
// Use of this source code is governed by an ISC
// license that can be found in the LICENSE file.

package cfgutil

Expand Down
27 changes: 27 additions & 0 deletions internal/helpers/helpers.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
// Copyright (c) 2016 The btcsuite developers
// Copyright (c) 2016 The Decred developers
// Use of this source code is governed by an ISC
// license that can be found in the LICENSE file.

// Package helpers provides convenience functions to simplify wallet code. This
// package is intended for internal wallet use only.
package helpers

import (
"github.com/decred/dcrd/wire"
"github.com/decred/dcrutil"
)

func SumOutputValues(outputs []*wire.TxOut) (totalOutput dcrutil.Amount) {
for _, txOut := range outputs {
totalOutput += dcrutil.Amount(txOut.Value)
}
return totalOutput
}

func SumOutputSerializeSizes(outputs []*wire.TxOut) (serializeSize int) {
for _, txOut := range outputs {
serializeSize += txOut.SerializeSize()
}
return serializeSize
}
20 changes: 4 additions & 16 deletions internal/legacy/keystore/keystore.go
Original file line number Diff line number Diff line change
@@ -1,19 +1,7 @@
/*
* Copyright (c) 2013, 2014 The btcsuite developers
* Copyright (c) 2015-2016 The Decred developers
*
* Permission to use, copy, modify, and distribute this software for any
* purpose with or without fee is hereby granted, provided that the above
* copyright notice and this permission notice appear in all copies.
*
* THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
* WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
* MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
* ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
* WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
* ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
* OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
*/
// Copyright (c) 2013-2014 The btcsuite developers
// Copyright (c) 2015-2016 The Decred developers
// Use of this source code is governed by an ISC
// license that can be found in the LICENSE file.

package keystore

Expand Down
Loading

0 comments on commit 2133b7b

Please sign in to comment.