aboutsummaryrefslogtreecommitdiff
path: root/src/wallet
AgeCommit message (Collapse)Author
2018-07-24wallet: Switch to using output groups instead of coins in coin selectionKarl-Johan Alm
2018-07-24wallet: Add output groupingKarl-Johan Alm
2018-07-24Add -avoidpartialspends and m_avoid_partial_spendsKarl-Johan Alm
2018-07-24wallet: Add input bytes to CInputCoinKarl-Johan Alm
With nInputBytes, coin selection can execute without a reference to the COutput
2018-07-24moveonly: CoinElegibilityFilter into coinselection.hKarl-Johan Alm
2018-07-20Merge #9662: Add createwallet "disableprivatekeys" option: a sane mode for ↵Wladimir J. van der Laan
watchonly-wallets a3fa4d6a6acf19d640a1d5879a00aa1f059e2380 QA: Fix bug in -usecli logic that converts booleans to non-lowercase strings (Jonas Schnelli) 4704e5f074e57782d058404a594a7313cf170cf0 [QA] add createwallet disableprivatekey test (Jonas Schnelli) c7b8f343e99d9d53ea353ddce9a977f1886caf30 [Qt] Disable creating receive addresses when private keys are disabled (Jonas Schnelli) 2f15c2bc20d583b4c1788da78c9c635c36e03ed0 Add disable privatekeys option to createwallet (Jonas Schnelli) cebefba0855cee7fbcb9474b34e6779369e8e9ce Add option to disable private keys during internal wallet creation (Jonas Schnelli) 9995a602a639b64a749545b7c3bafbf67f97324f Add facility to store wallet flags (64 bits) (Jonas Schnelli) Pull request description: This mode ('createwallet {"disableprivatekeys": true}') is intended for a sane pure watch-only mode, ideal for a use-case where one likes to use Bitcoin-Core in conjunction with a hardware-wallet or another solutions for cold-storage. Since we have support for custom change addresses in `fundrawtransaction`, pure watch-only wallets including coin-selection are possible and do make sense for some use cases. This new mode disables all forms of private key generation and ensure that no mix between hot and cold keys are possible. Tree-SHA512: 3ebe7e8d54c4d4e5f790c348d4c292d456f573960a5b04d69ca5ef43a9217c7e7671761c6968cdc56f9a8bc235f3badd358576651af9f10855a0eb731f3fc508
2018-07-19Merge #13712: wallet: Fix non-determinism in ParseHDKeypath(...). Avoid ↵MarcoFalke
using an uninitialized variable in path calculation. 27ee53c1ae wallet: Add error handling. Check return value of ParseUInt32(...) in ParseHDKeypath(...). (practicalswift) 7223263899 wallet: Add tests for ParseHDKeypath(...) (practicalswift) Pull request description: Add error handling. Check return value of `ParseUInt32(...)` in `ParseHDKeypath(...)`. `ParseUInt32(...)` returns `false` if the entire string could not be parsed or when an overflow or underflow occurred. In such case the uninitialized variable `number` would be used in the calculation of `path` (prior to this commit). An example key path triggering this is `m/0/4294967296`: ``` ParseHDKeypath("m/0/4294967296", keypath); ``` `4294967296` is `1` + `0xFFFFFFFF` (`uint32_t` max: `4294967295`). Introduced in a4b06fb42eb0ad94e562ca839391b57e69285136 which was merged into `master` 14 hours ago as part of #13557 ("BIP 174 PSBT Serializations and RPCs"). Tree-SHA512: e5ff423f67c18d82c1231bde6343587a453e793c32004d93dc9b61be6d9372b57a6b2c9978d9eb1000d6cc82fd180f2486013f928dca737fb92daad22c16e467
2018-07-19Merge #13074: [trivial] Correct help text for `importaddress` RPCMarcoFalke
2c71edc2fc [wallet] [rpc] Fix importaddress help text (John Newbery) Pull request description: Help text for `importaddress` referred to the first parameter as `script`, when in fact it's `address`. Calling with a script argument fails: ``` → bcli -named importaddress script=2N3qhMpHK8WNo7wv87W9eHMgvGyJU1593Ei error code: -8 error message: Unknown named parameter script → bcli -named importaddress address=2N3qhMpHK8WNo7wv87W9eHMgvGyJU1593Ei # success! ``` Tree-SHA512: 24dcb2cbd0a43e25896b1c67fa0386df2453ec04d49a339e10992417b3921ce3df8a6aa5abba7d2237d6188b018948b2a21ea2f04d37120ad36c31c7b7fc9f1c
2018-07-19wallet: Add error handling. Check return value of ParseUInt32(...) in ↵practicalswift
ParseHDKeypath(...).
2018-07-19wallet: Add tests for ParseHDKeypath(...)practicalswift
2018-07-18Merge #13500: [wallet] Decouple wallet version from client versionWladimir J. van der Laan
cd3f4aa80810fc077c7f9528a4ef53c1438c86e1 Decouple wallet version from client version (Andrew Chow) Pull request description: Instead of comparing version numbers in the wallet to the client version number, compare them to the latest supported wallet version in the client. This allows for wallet version numbers to be unrelated to the client version number. Tree-SHA512: 69c3e1f45a40bde01d622d504a803fea32fc14e2e27b14b0729725349d8592d56ebca26fd06f117fd6f5164fb4ce980122751b6370f6e25f1a947dbdf4143ddd
2018-07-18Merge #13557: BIP 174 PSBT Serializations and RPCsWladimir J. van der Laan
020628e3a4e88e36647eaf92bac4b3552796ac6a Tests for PSBT (Andrew Chow) a4b06fb42eb0ad94e562ca839391b57e69285136 Create wallet RPCs for PSBT (Andrew Chow) c27fe419efb3b6588c400d764122ffb33375e028 Create utility RPCs for PSBT (Andrew Chow) 8b5ef2793748065727a9a2498805ae5b269dcb4f SignPSBTInput wrapper function (Andrew Chow) 58a8e28918025c28f19ba19cbaa4a72374162942 Refactor transaction creation and transaction funding logic (Andrew Chow) e9d86a43ad8b1ab83b324e9a7a64c43a61337501 Methods for interacting with PSBT structs (Andrew Chow) 12bcc64f277f642ece03c25653e726f2276f0d51 Add pubkeys and whether input was witness to SignatureData (Andrew Chow) 41c607f09badb2c3ed58ff6fb17a8ebbef2cdabd Implement PSBT Structures and un/serialization methods per BIP 174 (Andrew Chow) Pull request description: This Pull Request fully implements the [updated](https://github.com/bitcoin/bips/pull/694) BIP 174 specification. It is based upon #13425 which implements the majority of the signing logic. BIP 174 specifies a binary transaction format which contains the information necessary for a signer to produce signatures for the transaction and holds the signatures for an input while the input does not have a complete set of signatures. This PR contains structs for PSBT, serialization, and deserialzation code. Some changes to `SignatureData` have been made to support detection of UTXO type and storing public keys. *** Many RPCs have been added to handle PSBTs. `walletprocesspsbt` takes a PSBT format transaction, updates the PSBT with any inputs related to this wallet, signs, and finalizes the transaction. There is also an option to not sign and just update. `walletcreatefundedpsbt` creates a PSBT from user provided data in the same form as createrawtransaction. It also funds the transaction and takes an options argument in the same form as `fundrawtransaction`. The resulting PSBT is blank with no input or output data filled in. It is analogous to a combination of `createrawtransaction` and `fundrawtransaction` `decodepsbt` takes a PSBT and decodes it to JSON. It is analogous to `decoderawtransaction` `combinepsbt` takes multiple PSBTs for the same tx and combines them. It is analogous to `combinerawtransaction` `finalizepsbt` takes a PSBT and finalizes the inputs. If all inputs are final, it extracts the network serialized transaction and returns that instead of a PSBT unless instructed otherwise. `createpsbt` is like `createrawtransaction` but for PSBTs instead of raw transactions. `convertpsbt` takes a network serialized transaction and converts it into a psbt. The resulting psbt will lose all signature data and an explicit flag must be set to allow transactions with signature data to be converted. *** This supersedes #12136 Tree-SHA512: 1ac7a79e5bc669933f0a6fcc93ded55263fdde9e8c144a30266b13ef9f62aacf43edd4cbca1ffbe003090b067e9643c9298c79be69d7c1b10231b32acafb6338
2018-07-16Tests for PSBTAndrew Chow
Added functional tests for PSBT that test the RPCs. Also added all of the BIP 174 test vectors (except for the updater tests) in the functional tests. Added a Unit test for the BIP 174 updater test vector.
2018-07-16Create wallet RPCs for PSBTAndrew Chow
walletprocesspsbt takes a PSBT format transaction, updates the PSBT with any inputs related to this wallet, signs, and finalizes the transaction. There is also an option to not sign and just update. walletcreatefundedpsbt creates a PSBT from user provided data in the same form as createrawtransaction. It also funds the transaction and takes an options argument in the same form as fundrawtransaction. The resulting PSBT is blank with no input or output data filled in.
2018-07-16Merge #13652: rpc: Fix that CWallet::AbandonTransaction would leave the ↵Wladimir J. van der Laan
grandchildren, etc. active 89e70f9d7fe384ef9de4fa3828d4c80523290186 Fix that CWallet::AbandonTransaction would only traverse one level (Ben Woosley) Pull request description: Prior to this change, it would mark only the first layer of child transactions abandoned, due to always following the input `hashTx` rather than the current `now` tx. Tree-SHA512: df068b49637d299ad73237c7244005fe5aa966d6beae57aff12e6948f173d9381e1b5d08533f7e3a1416991ed57f9f1f7b834057141d85c07dc60bb1f0872cea
2018-07-13Merge #13072: Update createmultisig RPC to support segwitPieter Wuille
f40b3b82df [tests] functional test for createmultisig RPC (Anthony Towns) b9024fdda3 segwit support for createmultisig RPC (Anthony Towns) d58055d25f Move AddAndGetDestinationForScript from wallet to outputype module (Anthony Towns) 9a44db2e46 Add outputtype module (Anthony Towns) Pull request description: Adds an "address_type" parameter that accepts "legacy", "p2sh-segwit", and "bech32" to choose the type of address created. Defaults to "legacy" rather than the value of the `-address-type` option for backwards compatibility. As part of implementing this, OutputType is moved from wallet into its own module, and `AddAndGetDestinationForScript` is changed to apply to a `CKeyStore` rather than a wallet, and to invoke `keystore.AddCScript(script)` itself rather than expecting the caller to have done that. Fixes #12502 Tree-SHA512: a08c1cfa89976e4fd7d29caa90919ebd34a446354d17abb862e99f2ee60ed9bc19d8a21a18547c51dc3812cb9fbed86af0bef2f1e971f62bf95cade4a7d86237
2018-07-13Merge #13651: [moveonly] Extract CWallet::MarkInputsDirty, and privatize ↵Pieter Wuille
AddToWalletIfInvolvingMe 17e6aa8e33 Privatize CWallet::AddToWalletIfInvolvingMe (Ben Woosley) b7f5650942 Extract CWallet::MarkInputsDirty (Ben Woosley) Pull request description: Thus reducing code and surface area of CWallet. Tree-SHA512: 31a99acc77ef3438ef9b95d60030972b707bd69d6e7b1498a5f776b219d9aabc83464f75bfec7bad5cb635d0b2d686c389914e5cc57a4bb0b93c47bd82ca608c
2018-07-13Merge #13566: Fix get balancePieter Wuille
702ae1e21a [RPC] [wallet] allow getbalance to use min_conf and watch_only without accounts. (John Newbery) cf15761f6d [wallet] GetBalance can take a min_depth argument. (John Newbery) 0f3d6e9ab7 [wallet] factor out GetAvailableWatchOnlyBalance() (John Newbery) 7110c830f8 [wallet] deduplicate GetAvailableCredit logic (John Newbery) ef7bc8893c [wallet] Factor out GetWatchOnlyBalance() (John Newbery) 4279da4785 [wallet] GetBalance can take an isminefilter filter. (John Newbery) Pull request description: #12953 inadvertently removed the functionality to call `getbalance "*" <int> <bool>` to get the wallet's balance with either minconfs or include_watchonly. This restores that functionality (when `-deprecatedrpc=accounts`), and also makes it possible to call ``getbalance minconf=<int> include_watchonly=<bool>` when accounts are not being used. Tree-SHA512: 67e84de9291ed6d34b23c626f4dc5988ba0ae6c99708d02b87dd3aaad3f4b6baa6202a66cc2dadd30dd993a39de8036ee920fcaa8cbb1c5dfe606e6fac183344
2018-07-13Merge #13630: Drop unused pindexRet arg to CMerkleTx::GetDepthInMainChainPieter Wuille
d6f39b6c64 Drop unused pindexRet arg to CMerkleTx::GetDepthInMainChain (Ben Woosley) Pull request description: Tree-SHA512: 5f064a47e71113f90f296ab36dae92173ff3fc632ab4e1e85dc71d556cb9239d15939b1e542f4292dab93d336795b7f2e4ae64f6984303c852df8d24f54ccebe
2018-07-13Refactor transaction creation and transaction funding logicAndrew Chow
In preparation for more create transaction and fund transcation RPCs, refactor the transaction creation and funding logic into separate functions.
2018-07-13Privatize CWallet::AddToWalletIfInvolvingMeBen Woosley
And document in the header.
2018-07-13Extract CWallet::MarkInputsDirtyBen Woosley
To avoid repeated implementations.
2018-07-13Merge #12944: [wallet] ScanforWalletTransactions should mark input txns as dirtyJonas Schnelli
3c292cc19 ScanforWalletTransactions should mark input txns as dirty (Gregory Sanders) Pull request description: I'm hitting a corner case in my mainnet wallet where I load a restore a wallet, call `rescanblockchain` from RPC, and it's "double counting" an output I've sent to myself since currently it never marks input transactions as dirty. This is fixed by a restart of the wallet. Note that this only happens with keys with birthdate *after* the blocks containing the spent funds which gets scanned on startup, so it's hard to test without a set seed function. Tree-SHA512: ee1fa152bb054b57ab4c734e355df10d241181e0372c81d583be61678fffbabe5ae60b09b05dc1bbbcfb4838df9d8538791d4c1d80a09b84d78ad2f50dcb0a61
2018-07-13Fix that CWallet::AbandonTransaction would only traverse one levelBen Woosley
Prior to this change, it would mark only the first layer of child transactions abandoned, due to always following the input hashTx rather than the current now tx.
2018-07-12[QA] add createwallet disableprivatekey testJonas Schnelli
2018-07-12Add disable privatekeys option to createwalletJonas Schnelli
2018-07-12Add option to disable private keys during internal wallet creationJonas Schnelli
2018-07-12Merge #13627: Free keystore.h from file scope level type aliasesWladimir J. van der Laan
d0b9405f964670d6eaa8529f65fa7993b2a406c8 Refactors `keystore.h` type aliases. (251) Pull request description: This pull request frees `keystore.h` from type alias declarations that have been declared at file scope level. `keystore.h` has various type aliases that have been declared ~3 - 6 years ago at file scope level, which can either be encapsulated or removed. Where type alias declarations are encapsulated at the appropriate scope and access level, C++11's `using` notation is used in favor of the `typedef` notation. Tree-SHA512: 1395cdc63e0c7ff5a1b1721675ad4416f71f507e999bd4ba019f03457cbfc08877848f10a8db7f5ccd2cd5ca3f5a291c986616f7703172fb6d79fba7447ffba8
2018-07-12Merge #13145: Use common getPath method to create temp directory in tests.MarcoFalke
075429a482 Use common SetDataDir method to create temp directory in tests. (winder) Pull request description: Took a stab at #12574 Created a `getPath` method which can be used with the `TestingSetup` fixture to create a temp directory. Updated tests using temp directories to use this method. I tried setting up a `BOOST_GLOBAL_FIXTURE` to create a truly global path for all tests but was getting linker errors when including `boost/test/unit_test.hpp` in `test_bitcoin.cpp`. Even if I had gotten the linking to work, it looks like `make check` invokes the test binary a bunch of times, so it may not have worked anyway. Tree-SHA512: b51d0f5fada5d652ccc9362596cf98a742aa47f5daf94f189b5f034d8c035c85d095377befdcff7fb4247154d5160e8c500d70f554a2158e2c185a9d24f694f1
2018-07-12Add facility to store wallet flags (64 bits)Jonas Schnelli
2018-07-11Use common SetDataDir method to create temp directory in tests.winder
2018-07-12Refactors `keystore.h` type aliases.251
This squashed commit either encapsulates type alias declarations at the appropriate scope; or removes type aliases that are not used. The encapsulated type aliases are declared using C++11's `using` notation in favor of the `typedef` notation.
2018-07-11Merge #13114: wallet/keystore: Add Clang thread safety annotations for ↵MarcoFalke
variables guarded by cs_KeyStore 968b76f77c Add missing cs_KeyStore lock (practicalswift) 4bcd5bb87d Add locking annotations for variables guarded by cs_KeyStore (practicalswift) Pull request description: * Add Clang thread safety annotations for variables guarded by `cs_KeyStore` * Add missing `cs_KeyStore` lock Tree-SHA512: 7d93513c2da0cd564b9f1e75aa5156a454a4133eb845020fde8872e685dd5758353e93c33364aeea4a812c08353a810494e503a5ce160cc5be0af5af4bb2e6d7
2018-07-11Drop unused pindexRet arg to CMerkleTx::GetDepthInMainChainBen Woosley
2018-07-09Remove useless mapRequest tracking that just effects Qt display.Matt Corallo
I thought we had removed this a long time ago, TBH, its really confusing feedback to users that we display whether a tx was broadcast to immediate neighbor nodes, given that has little indication of whether the tx propagated very far.
2018-07-10Move AddAndGetDestinationForScript from wallet to outputype moduleAnthony Towns
Makes AddAndGetDestinationForScript use a generic CKeyStore rather than the wallet, and makes it always add the script to the keystore, rather than only adding related (redeem) scripts.
2018-07-09Add outputtype moduleAnthony Towns
Moves OutputType into its own module
2018-07-07Merge #13564: [wallet] loadwallet shouldn't create new wallets.MarcoFalke
ea65182f03 [wallet] loadwallet shouldn't create new wallets. (John Newbery) Pull request description: A bug in the initial implementation of loadwallet meant that if the arguement was a directory that didn't contain a wallet.dat file, a new wallet would be created in that directory. Fix that so that if a directory is passed in, it must contain a wallet.dat file. Bug reported by promag (João Barbosa). Tree-SHA512: 0a59fa8a33fde51a88544ad288b00e4995284fe16424f643076aaba42b8244fff362145217650ee53d518dfab7efbed4237632c34cdd3dcbbecaa9ecaab5fd7b
2018-07-05Merge #13096: [Policy] Fix MAX_STANDARD_TX_WEIGHT checkWladimir J. van der Laan
2f1a30c63 Fix MAX_STANDARD_TX_WEIGHT check (Johnson Lau) Pull request description: As suggested by the constant name and its comment in policy.h, a transaction with a weight of exactly MAX_STANDARD_TX_WEIGHT should be allowed. Users could be confused. Tree-SHA512: af417de1c6a2e6796ebbb39aa0caad8764302ded155cb1bbfbe457e4567c199cc53256189832b17d4aeec369e190b3edd4c6116d5f0b8cf0ede6dfb4ed83bdd3
2018-07-04Merge #13235: Break circular dependency: init -> * -> init by extracting ↵Wladimir J. van der Laan
shutdown.h 1fabd59e7 Break circular dependency: init -> * -> init by extracting shutdown.h (Ben Woosley) e62fdfeea Drop unused init.h includes (Ben Woosley) Pull request description: Most includers just wanted to react to pending shutdown. This isolates access to `fRequestShutdown` and limits access to the shutdown api functions, including the new `CancelShutdown` for setting it to `false`. Tree-SHA512: df42f75dfbba163576710e9a67cf1228531fd99d70a2f187bfba0bcc476d6749cf88180a97e66a81bb5b6c3c7f0917de7402d26039ba7b644cb7509b02f7e267
2018-07-04Merge #13491: Improve handling of INVALID in IsMineWladimir J. van der Laan
bb582a59c Add P2WSH destination helper and use it instead of manual hashing (Pieter Wuille) eaba1c111 Add additional unit tests for invalid IsMine combinations (Pieter Wuille) e6b9730c4 Do not expose invalidity from IsMine (Pieter Wuille) Pull request description: This improves the handling of INVALID in IsMine: * Extra INVALID conditions were added to `IsMine` (following https://github.com/bitcoin/bitcoin/pull/13142/files#r185349057), but these were untested. Add unit tests for them. * In https://github.com/bitcoin/bitcoin/pull/13142#issuecomment-386396975 it was suggested to merge `isInvalid` into the return status. This PR takes a different approach, and removes the `isInvalid` entirely. It was only ever used inside tests, as normal users of IsMine don't care about the reason for non-mine-ness, only whether it is or not. As the unit tests are extensive enough, it seems sufficient to have a black box text (with tests for both compressed and uncompressed keys). Some addition code simplification is done as well. Tree-SHA512: 3267f8846f3fa4e994f57504b155b0e1bbdf13808c4c04dab7c6886c2c0b88716169cee9c5b350513297e0ca2a00812e3401acf30ac9cde5d892f9fb59ad7fef
2018-07-02Delete double semicolon in wallet.cpp and misc.cppMatteo Sumberaz
2018-06-29[RPC] [wallet] allow getbalance to use min_conf and watch_only without accounts.John Newbery
2018-06-28[wallet] GetBalance can take a min_depth argument.John Newbery
2018-06-28[wallet] factor out GetAvailableWatchOnlyBalance()John Newbery
2018-06-28[wallet] deduplicate GetAvailableCredit logicJohn Newbery
2018-06-28[wallet] Factor out GetWatchOnlyBalance()John Newbery
2018-06-28[wallet] GetBalance can take an isminefilter filter.John Newbery
GetBalance() can now take an ismine filter, which is passed down to GetAvailableCredit. This allows GetBalance to be used to get watch-only balances.
2018-06-28[wallet] loadwallet shouldn't create new wallets.John Newbery
A bug in the initial implementation of loadwallet meant that if the arguement was a directory that didn't contain a wallet.dat file, a new wallet would be created in that directory. Fix that so that if a directory is passed in, it must contain a wallet.dat file. Bug reported by promag (João Barbosa).
2018-06-26Merge #13498: [wallet] Fixups from account API deprecationPieter Wuille
df10f07db1 [wallet] Don't use accounts when checking balance in sendmany (John Newbery) e209184101 [wallet] deprecate sendfrom RPC method. (John Newbery) Pull request description: A couple of fixups from the accounts API deprecation PR (#12953): - properly deprecate `sendfrom` - don't use accounts when calculating balance in `sendmany` (unless the `-deprecatedrpc=accounts` flag is being used) Tree-SHA512: 1befde055067438c4c3391bbff1aaed0e6249efd708c567db3f1faad40a0f28e64f95e5bad0679ae826d24a0239e4bc8a1c392dc93e2e7502343a7f6b1d1845c