Commit Graph

376 Commits

Author SHA1 Message Date
Andrew Chow b98bfc5ed0 Create getaddressinfo RPC and deprecate parts of validateaddress
Moves the parts of validateaddress which require the wallet into getaddressinfo
which is part of the wallet RPCs. Mark those parts of validateaddress which
require the wallet as deprecated.

Validateaddress will  call getaddressinfo
for the data that both share for right now.

Moves IsMine functions to libbitcoin_common and then links libbitcoin_wallet
before libbitcoin_common in order to prevent linker errors since IsMine is no
longer used in libbitcoin_server.
2018-02-16 12:09:32 -05:00
Wladimir J. van der Laan fd65937ec6
Merge #12356: Fix 'mempool min fee not met' debug output
bb00c95 Consistently use FormatStateMessage in RPC error output (Ben Woosley)
8b8a1c4 Add test for 'mempool min fee not met' rpc error (Ben Woosley)
c04e0f6 Fix 'mempool min fee not met' debug output (Ben Woosley)

Pull request description:

  Output the value that is tested, rather than the unmodified fee value.

  Prompted by looking into: #11955

Tree-SHA512: fc0bad47d4af375d208f657a6ccbad6ef7f4e2989ae2ce1171226c22fa92847494a2c55cca687bd5a1548663ed3313569bcc31c00d53c0c193a1b865dd8a7657
2018-02-15 16:35:42 +01:00
Wladimir J. van der Laan 0cc45edc0f
Merge #12409: rpc: Reject deprecated reserveChangeKey in fundrawtransaction
fa5f518 rpc: Reject deprecated reserveChangeKey in fundrawtransaction (MarcoFalke)

Pull request description:

Tree-SHA512: 8506d1494b13c4582b1379e3b8c3906016f1980ebe847727a43a90e7bb9f71b896a1792bc97a8dc7320ccce0534050eb04f92a6f82f811d08efa74a98b3e43f0
2018-02-14 16:43:55 +01:00
MarcoFalke fa5f51830d
rpc: Reject deprecated reserveChangeKey in fundrawtransaction 2018-02-10 22:11:31 -05:00
Karel Bilek 91986ed206 scripted-diff: Use UniValue.pushKV instead of push_back(Pair())
-BEGIN VERIFY SCRIPT-
git grep -l "push_back(Pair" | xargs sed -i "s/push_back(Pair(\(.*\)));/pushKV(\1);/g"
-END VERIFY SCRIPT-
2018-02-10 10:05:07 -05:00
Ben Woosley bb00c95c16
Consistently use FormatStateMessage in RPC error output
This will include the error code and debug output as well as the reason string.

See #11955 for the motivation.
2018-02-08 11:02:41 -05:00
Wladimir J. van der Laan 663911ed58
Merge #12282: wallet: Disallow abandon of conflicted txes
fa795cf wallet: Disallow abandon of conflicted txes (MarcoFalke)

Pull request description:

  Abandon transactions that are already conflicted is a noop, so don't try and return false/throw instead.

Tree-SHA512: fd2af4149bd2323f7f31fe18685c763790b8589319b4e467b464ab456d5e8971501ab16d124e57a22693666b06ae433ac3e59f0fd6dfbd2be2c6cae8be5bcbd8
2018-02-08 16:32:15 +01:00
Wladimir J. van der Laan 3843780fd8
Merge #12336: Remove deprecated rpc options
db1cbcc [RPC] Remove deprecated addmultisigaddress return format (John Newbery)
cb28a0b [RPC] Remove deprecated createmultisig object (John Newbery)
ed45c82 [tests] Remove test for deprecated createmultsig option (John Newbery)
d066a1c [rpc] Remove deprecated getmininginfo RPC option (John Newbery)
c6f09c2 [rpc] remove deprecated estimatefee RPC (John Newbery)
a8e437a [tests] Remove estimatefee from rpc_deprecated.py test (John Newbery)
a5623b1 [tests] Remove tests for deprecated estimatefee RPC (John Newbery)
d119f2e [tests] Fix style warnings in feature_fee_estimation.py (John Newbery)

Pull request description:

  There were some RPC/RPC options deprecated in v0.16. Those can now be removed from master since v0.16 has been branched.

  - `estimatefee` RPC has been removed. The `feature_fee_estimation.py` test has been updated to remove the RPC, but doesn't yet have good coverage of the replacement RPC `estimatesmartfee`. Improving the test coverage should be done in a new PR. (#11031)
  - the `errors` field returned by `getmininginfo` has been deprecated and replaced by a `warning` field. (#10858)
  - providing addresses as inputs to `createmultisig` has been deprecated. Users should use `addmultisigaddress` instead (#11415)
  - The return format from `addmultisigaddress` has changed (#11415)

  `getwitnessaddress` was also deprecated in v0.16 and can be removed, but many tests are using that RPC, so it's a larger job to remove. It should be removed in a separate PR (possibly after #11739 and #11398 have been merged and the segwit test code tidied up)

Tree-SHA512: 8ffaa5f6094131339b9e9e468e8b141de4b144697d2271efa2992b80b12eb97849ade3da8df5c1c9400ed4c04e6a029926550a3e5846d2029b644f9e84ac7124
2018-02-08 15:38:21 +01:00
John Newbery db1cbcc856 [RPC] Remove deprecated addmultisigaddress return format 2018-02-08 08:59:28 -05:00
MarcoFalke fa795cf9c5
wallet: Disallow abandon of conflicted txes 2018-02-06 09:54:31 -05:00
John Newbery c6f09c2713 [rpc] remove deprecated estimatefee RPC 2018-02-05 15:17:31 -05:00
João Barbosa c409b1adac [rpc] Reduce scope of cs_main and cs_wallet locks in listtransactions 2018-02-02 01:58:24 +00:00
fanquake c6b6385651
[rpc] Mention that HD is enabled if hdmasterkeyid is present 2018-01-29 21:00:27 +08:00
Jonas Schnelli 7abb0f0929
Merge #12194: Add change type option to fundrawtransaction
16f6f59dc [qa] Test fundrawtransaction with change_type option (João Barbosa)
536ddeb17 [rpc] Add change_type option to fundrawtransaction (João Barbosa)
31dbd5af4 [wallet] Add change type to CCoinControl (João Barbosa)

Pull request description:

  Adds a new option `change_type` to `fundrawtransaction` RPC. This is useful to override the node `-changetype` argument.

  The new option is exclusive to `changeAddress` option, setting both raises a RPC error.

  See also #11403, #12119.

Tree-SHA512: 654686444f6125e37015a62f167064d54ec335701534988447be4687fa5ef9c7980a8a07cc0a03fff6ea6c4c1abf0f77a8843d535c4f3fe0bf93f968a4e676e6
2018-01-24 09:09:30 -10:00
João Barbosa 536ddeb173 [rpc] Add change_type option to fundrawtransaction 2018-01-24 16:00:50 +00:00
João Barbosa 886a92f25f [rpc] Add address type option to addmultisigaddress 2018-01-24 14:45:07 +00:00
Wladimir J. van der Laan 95941396ff
Merge #12119: [wallet] use P2WPKH change output if any destination is P2WPKH or P2WSH
596c446 [wallet] use P2WPKH change output if any destination is P2WPKH or P2WSH (Sjors Provoost)

Pull request description:

  If `-changetype` is not explicitly set, then regardless of `-addresstype`, the wallet will use a ~`bech32` change address~ `P2WPKH` change output if any destination is `P2WPKH` or `P2WSH`.

  This seems more intuitive to me and more in line with the spirit of [BIP-69](https://github.com/bitcoin/bips/blob/master/bip-0069.mediawiki).

  When combined with #11991 a QT user could opt to use `bech32` exclusively without having to figure out how to launch with `-changetype=bech32`, although so would #11937.

Tree-SHA512: 9238d3ccd1f3be8dfdd43444ccf45d6bdc6584ced3172a3045f3ecfec4a7cc8999db0cdb76ae49236492a84e6dbf3a1fdf18544d3eaf6d518e1f8bd241db33e7
2018-01-24 15:22:42 +01:00
Wladimir J. van der Laan 69ec021969
Merge #11415: [RPC] Disallow using addresses in createmultisig
1df206f Disallow using addresses in createmultisig (Andrew Chow)

Pull request description:

  This PR should be the last part of #7965.

  This PR makes createmultisig only accept public keys and marks the old functionality of accepting addresses as deprecated.

  It also splits `_createmultisig_redeemscript` into two functions, `_createmultisig_getpubkeys` and `_createmultisig_getaddr_pubkeys`. `_createmultisig_getpubkeys` retrieves public keys from the RPC parameters and `_createmultisig_getaddr_pubkeys` retrieves addresses' public keys from the wallet. `_createmultisig_getaddr_pubkeys` requires the wallet and is only used by `addwitnessaddress` (except when `createmultisig` is used in deprecated mode).

  `addwitnessaddress`'s API is also changed. Instead of returning just an address, it now returns the same thing as `createmultisig`: a JSON object with two fields, address and redeemscript.

Tree-SHA512: a5796e41935ad5e47d8165ff996a8b20d5112b5fc1a06a6d3c7f5513c13e7628a4fd37ec30fde05d8b15abfed51bc250710140f6834b13f64d0a0e47a3817969
2018-01-24 14:03:40 +01:00
Wladimir J. van der Laan 8470e64724
Merge #11281: Avoid permanent cs_main/cs_wallet lock during RescanFromTime
7f81250 Mention that other RPC calls report keys as "imported" while txns are still missing (Jonas Schnelli)
ccd8ef6 Reduce cs_main lock in ReadBlockFromDisk, only read GetBlockPos under the lock (Jonas Schnelli)
bc356b4 Make sure WalletRescanReserver has successfully reserved the rescan (Jonas Schnelli)
dbf8556 Add RAII wallet rescan reserver (Jonas Schnelli)
8d0b610 Avoid pemanent cs_main/cs_wallet lock during wallet rescans (Jonas Schnelli)

Pull request description:

  Right now, we are holding `cs_main`/`cs_wallet` during the whole rescan process (which can take a couple of hours).
  This was probably only done because of laziness and it is an important show-stopper for #11200 (GUI rescan abort).

Tree-SHA512: 0fc3f82d0ee9b2f013e6bacba8d59f7334306660cd676cd64c47bb305c4cb7c7a36219d6a6f76023b74e5fe87f3ab9fc7fd2439e939f71aef653fddb0a1e23b1
2018-01-24 12:56:23 +01:00
Jonas Schnelli bc356b4268
Make sure WalletRescanReserver has successfully reserved the rescan 2018-01-23 20:24:18 -10:00
Jonas Schnelli dbf8556b4d
Add RAII wallet rescan reserver 2018-01-23 20:23:57 -10:00
Jonas Schnelli 8d0b610fe8
Avoid pemanent cs_main/cs_wallet lock during wallet rescans 2018-01-23 20:22:33 -10:00
Sjors Provoost 596c44633f
[wallet] use P2WPKH change output if any destination is P2WPKH or P2WSH
Only if -changetype is not set and -addresstype is not "legacy".
2018-01-23 17:56:15 +01:00
Wladimir J. van der Laan cdf3e03a72 wallet: Deprecate addwitnessaddress
Now that segwit is natively supported by the wallet, deprecate the hack `addwitnessaddress`.
2018-01-18 10:24:18 +01:00
Wladimir J. van der Laan c7978be899
Merge #12101: Clamp walletpassphrase timeout to 2^30 seconds and check its bounds
134cdc7 Test walletpassphrase timeout bounds and clamping (Andrew Chow)
0b63e3c Clamp walletpassphrase timeout to 2^(30) seconds and check its bounds (Andrew Chow)

Pull request description:

  Fixes #12100

  Makes the timeout be clamped to 2^30 seconds to avoid the issue with sign flipping with large timeout values and thus relocking the wallet instantly. Unlocking for at most ~34 years should be sufficient.

  Also checks that the timeout is not negative to avoid instant relocks.

Tree-SHA512: 426922f08c54e323d259e25dcdbebc2cd560708a65111ce6051493a7e7c61e79d9da1ea4026cc0d68807d728f5d7c0d7c58168c6ef4167b94cf6c2877af88794
2018-01-17 12:15:59 +01:00
mruddy 5f911c5cc2 trivial: fix address_type help text of getnewaddress and getrawchangeaddress 2018-01-13 10:49:46 -05:00
Andrew Chow 0b63e3c7b2 Clamp walletpassphrase timeout to 2^(30) seconds and check its bounds
Clamps the timeout of walletpassphrase to 2^(30) seconds, which is
~34 years. Any number greater than that will be forced to be
2^(30). This avoids the sign flipping problem with large values which
can result in a negative time used.

Also perform bounds checks to ensure that the timeout is positive
to avoid immediate relocking of the wallet.
2018-01-11 23:57:38 -05:00
Andrew Chow 1df206f854 Disallow using addresses in createmultisig
Make createmultisig only accept public keys with the old functionality
marked as deprecated.

Splits _createmultisig_redeemscript into two functions, one for
getting public keys from UniValue and one for getting addresses
from UniValue and then their respective public keys. The one for
retrieving address's public keys is located in rpcwallet.cpp

Changes addwitnessaddress's output to be a JSON object with
two fields, address and redeemscript.

Adds a test to deprecated_rpc.py for testing the deprecation.

Update the tests to use addwitnessaddress or give only public keys
to createmultisig. Anything that used addwitnessaddress was also
updated to reflect the new API.
2018-01-11 14:13:24 -05:00
Jonas Schnelli d889c036cd
Merge #11403: SegWit wallet support
b224a47a1 Add address_types test (Pieter Wuille)
7ee54fd7c Support downgrading after recovered keypool witness keys (Pieter Wuille)
940a21932 SegWit wallet support (Pieter Wuille)
f37c64e47 Implicitly know about P2WPKH redeemscripts (Pieter Wuille)
57273f2b3 [test] Serialize CTransaction with witness by default (Pieter Wuille)
cf2c0b6f5 Support P2WPKH and P2SH-P2WPKH in dumpprivkey (Pieter Wuille)
37c03d3e0 Support P2WPKH addresses in create/addmultisig (Pieter Wuille)
3eaa003c8 Extend validateaddress information for P2SH-embedded witness (Pieter Wuille)
30a27dc5b Expose method to find key for a single-key destination (Pieter Wuille)
985c79552 Improve witness destination types and use them more (Pieter Wuille)
cbe197470 [refactor] GetAccount{PubKey,Address} -> GetAccountDestination (Pieter Wuille)
0c8ea6380 Abstract out IsSolvable from Witnessifier (Pieter Wuille)

Pull request description:

  This implements a minimum viable implementation of SegWit wallet support, based on top of #11389, and includes part of the functionality from #11089.

  Two new configuration options are added:
  * `-addresstype`, with options `legacy`, `p2sh`, and `bech32`. It controls what kind of addresses are produced by `getnewaddress`, `getaccountaddress`, and `createmultisigaddress`.
  * `-changetype`, with the same options, and by default equal to `-addresstype`, that controls what kind of change is used.

  All wallet private and public keys can be used for any type of address. Support for address types dependent on different derivation paths will need a major overhaul of how our internal detection of outputs work. I expect that that will happen for a next major version.

  The above also applies to imported keys, as having a distinction there but not for normal operations is a disaster for testing, and probably for comprehension of users. This has some ugly effects, like needing to associate the provided label to `importprivkey` with each style address for the corresponding key.

  To deal with witness outputs requiring a corresponding redeemscript in wallet, three approaches are used:
  * All SegWit addresses created through `getnewaddress` or multisig RPCs explicitly get their redeemscripts added to the wallet file. This means that downgrading after creating a witness address will work, as long as the wallet file is up to date.
  * All SegWit keys in the wallet get an _implicit_ redeemscript added, without it being written to the file. This means recovery of an old backup will work, as long as you use new software.
  * All keypool keys that are seen used in transactions explicitly get their redeemscripts added to the wallet files. This means that downgrading after recovering from a backup that includes a witness address will work.

  These approaches correspond to solutions 3a, 1a, and 5a respectively from https://gist.github.com/sipa/125cfa1615946d0c3f3eec2ad7f250a2. As argued there, there is no full solution for dealing with the case where you both downgrade and restore a backup, so that's also not implemented.

  `dumpwallet`, `importwallet`, `importmulti`, `signmessage` and `verifymessage` don't work with SegWit addresses yet. They're remaining TODOs, for this PR or a follow-up. Because of that, several tests unexpectedly run with `-addresstype=legacy` for now.

Tree-SHA512: d425dbe517c0422061ab8dacdc3a6ae47da071450932ed992c79559d922dff7b2574a31a8c94feccd3761c1dffb6422c50055e6dca8e3cf94a169bc95e39e959
2018-01-10 20:55:41 -10:00
Pieter Wuille 940a21932b SegWit wallet support
This introduces two command line flags (-addresstype and -changetype) which control
the type of addresses/outputs created by the GUI and RPCs. Certain RPCs allow
overriding these (`getnewaddress` and `getrawchangeaddress`). Supported types
are "legacy" (P2PKH and P2SH-multisig), "p2sh-segwit" (P2SH-P2WPKH and P2SH-P2WSH-multisig),
and "bech32" (P2WPKH and P2WSH-multisig).

A few utility functions are added to the wallet to construct different address type
and to add the necessary entries to the wallet file to be compatible with earlier
versions (see `CWallet::LearnRelatedScripts`, `GetDestinationForKey`,
`GetAllDestinationsForKey`, `CWallet::AddAndGetDestinationForScript`).
2018-01-09 15:35:31 -08:00
Pieter Wuille f37c64e477 Implicitly know about P2WPKH redeemscripts
Make CKeyStore automatically known about the redeemscripts necessary for P2SH-P2WPKH
(and due to the extra checks in IsMine, also P2WPKH) spending.
2018-01-09 15:35:27 -08:00
Pieter Wuille b3ecb7bab6
Merge #10677: RPC Docs: addmultisigaddress is intended for non-watchonly addresses
73041c3c99 RPC Docs: addmultisigaddress is intended for non-watchonly addresses (Gregory Sanders)

Pull request description:

  Spent a couple hours debugging why my p2sh watchonly funds were not appearing in various accounting calls when address was imported via `addmultisigaddress`.

Tree-SHA512: 0673e276e5ca8cdc4c9357bd835a29bd5a994520a78179600944932c700917142930288bf179f5e89b0874beaf1a88bd70129f3a297a46df42a10bab847017bb
2018-01-06 02:54:33 -08:00
Pieter Wuille cbe197470e [refactor] GetAccount{PubKey,Address} -> GetAccountDestination 2018-01-03 05:42:57 -08:00
Wladimir J. van der Laan 5961b23898
Merge #12062: Increment MIT Licence copyright header year on files modified in 2017
595a7ba Increment MIT Licence copyright header year on files modified in 2017 (Akira Takizawa)

Pull request description:

  Edited via:

  $ contrib/devtools/copyright_header.py update .

  ps) It is the same commit as #9450

Tree-SHA512: 274bfcd6cf2914315ed52f6db773a68800ce9d6bd225a3142654483f0bbc3fd865009e62f9d954f65765d038c626e55d2a64e37e16843809adc2f67abe659b6d
2018-01-03 14:33:28 +01:00
Pieter Wuille 0c8ea6380c Abstract out IsSolvable from Witnessifier 2018-01-03 05:32:00 -08:00
251 0d663f8197 Fixes issue #12067 `sendmany` curl example is wrong.
This commit removes the escaped backslash and quote characters from the keys in the JSON object to make it a plain JSON object.
2018-01-02 20:53:30 +01:00
Akira Takizawa 595a7bab23 Increment MIT Licence copyright header year on files modified in 2017 2018-01-03 02:26:56 +09:00
Wladimir J. van der Laan fee0370fd6
Merge #11178: Add iswitness parameter to decode- and fundrawtransaction RPCs
6f39ac0 Add test for decoderawtransaction bool (MeshCollider)
bbdbe80 Add iswitness parameter to decode- and fundrawtransaction RPCs (MeshCollider)

Pull request description:

  Suggested in https://github.com/bitcoin/bitcoin/pull/10481#issuecomment-325244946, this adds the option to explicitly choose whether a serialized transaction should be decoded as a witness or non-witness transaction rather than relying on the heuristic checks in #10481. The parameter defaults to relying on #10481 if not included, but it overrides that if included.

Tree-SHA512: d4846a5bb7d64dc19c516445488b00af329fc1f4181d9dfdf9f2382a086568edc98250a4ac7594e24a1bc231dfdee53c699b12c8380c355b920a67cc6770b7a9
2017-12-19 09:55:11 +01:00
Matt Corallo c79d73dc94 Clarify getbalance meaning a tiny bit in response to questions. 2017-12-13 12:18:33 -05:00
MarcoFalke fbce66a982
Merge #10493: Use range-based for loops (C++11) when looping over map elements
680bc2cbb Use range-based for loops (C++11) when looping over map elements (practicalswift)

Pull request description:

  Before this commit:

  ```c++
  for (std::map<T1, T2>::iterator x = y.begin(); x != y.end(); ++x) {
      T1 z = (*x).first;
      …
  }
  ```

  After this commit:

  ```c++
  for (auto& x : y) {
      T1 z = x.first;
      …
  }
  ```

Tree-SHA512: 954b136b7f5e6df09f39248a6b530fd9baa9ab59d7c2c7eb369fd4afbb591b7a52c92ee25f87f1745f47b41d6828b7abfd395b43daf84a55b4e6a3d45015e3a0
2017-11-30 17:10:05 -05:00
MeshCollider 0530ba0eae Add -walletdir parameter to specify custom wallet dir 2017-11-18 00:50:58 +13:00
Wladimir J. van der Laan 99bc0b428b
Merge #11087: Diagnose unsuitable outputs in lockunspent().
28f8b66 Diagnose unsuitable outputs in lockunspent(). (Eelis)

Pull request description:

  Fixes #2667.

  This is a simplified version of pull request #3574, which was abandoned by its author.

  I added some tests as well.

Tree-SHA512: e63e00dec8b1b232079380183805cb0b0b18c78ea6bea769837949aab984689d7f68b2ccfe66b1873517b040b9e616ce0eb058575c3d4382aa8c26eebcf1f14e
2017-11-16 12:24:05 +01:00
MeshCollider 1a445343f6 scripted-diff: Replace #include "" with #include <> (ryanofsky)
-BEGIN VERIFY SCRIPT-
for f in \
  src/*.cpp \
  src/*.h \
  src/bench/*.cpp \
  src/bench/*.h \
  src/compat/*.cpp \
  src/compat/*.h \
  src/consensus/*.cpp \
  src/consensus/*.h \
  src/crypto/*.cpp \
  src/crypto/*.h \
  src/crypto/ctaes/*.h \
  src/policy/*.cpp \
  src/policy/*.h \
  src/primitives/*.cpp \
  src/primitives/*.h \
  src/qt/*.cpp \
  src/qt/*.h \
  src/qt/test/*.cpp \
  src/qt/test/*.h \
  src/rpc/*.cpp \
  src/rpc/*.h \
  src/script/*.cpp \
  src/script/*.h \
  src/support/*.cpp \
  src/support/*.h \
  src/support/allocators/*.h \
  src/test/*.cpp \
  src/test/*.h \
  src/wallet/*.cpp \
  src/wallet/*.h \
  src/wallet/test/*.cpp \
  src/wallet/test/*.h \
  src/zmq/*.cpp \
  src/zmq/*.h
do
  base=${f%/*}/ relbase=${base#src/} sed -i "s:#include \"\(.*\)\"\(.*\):if test -e \$base'\\1'; then echo \"#include <\"\$relbase\"\\1>\\2\"; else echo \"#include <\\1>\\2\"; fi:e" $f
done
-END VERIFY SCRIPT-
2017-11-16 08:23:01 +13:00
MarcoFalke 4ed818060e
Merge #10600: Make feebumper class stateless
aed1d90ac [wallet] Change feebumper from class to functions (Russell Yanofsky)
37bdcca3c [refactor] Make feebumper namespace (Russell Yanofsky)
7c4f00919 [trivial] Rename feebumper variables according to project code style (Russell Yanofsky)

Pull request description:

  Make feebumper methods static and remove stored state in the class.

  Having the results of feebumper calls persist in an object makes process
  separation between Qt and wallet awkward, because it means the feebumper object
  either has to be serialized back and forth between Qt and wallet processes
  between fee bump calls, or that the feebumper object needs to stay alive in the
  wallet process with an object reference passed back to Qt. It's simpler just to
  have fee bumper calls return their results immediately instead of storing them
  in an object with an extended lifetime.

  In addition to making feebumper methods static, also:

  - Move LOCK calls from Qt code to feebumper
  - Move TransactionCanBeBumped implementation from Qt code to feebumper
  - Rename CFeeBumper class to FeeBumper (every CFeeBumper reference had to be
    updated in this PR anyway so this doesn't increase the size of the diff)

  This change was originally part of https://github.com/bitcoin/bitcoin/pull/10244

Tree-SHA512: bf75e0c741b4e9c8912e66cc1dedf0ff715f77ea65fc33f7020d97d9099b0f6448f5852236dac63eea649de7d6fc03b0b21492e2c5140fb7560a39cf085506fd
2017-11-15 12:50:17 -05:00
Wladimir J. van der Laan 927a1d7d08
Merge #10286: Call wallet notify callbacks in scheduler thread (without cs_main)
89f0312 Remove redundant pwallet nullptr check (Matt Corallo)
c4784b5 Add a dev notes document describing the new wallet RPC blocking (Matt Corallo)
3ea8b75 Give ZMQ consistent order with UpdatedBlockTip on scheduler thread (Matt Corallo)
cb06edf Fix wallet RPC race by waiting for callbacks in sendrawtransaction (Matt Corallo)
e545ded Also call other wallet notify callbacks in scheduler thread (Matt Corallo)
17220d6 Use callbacks to cache whether wallet transactions are in mempool (Matt Corallo)
5d67a78 Add calls to CWallet::BlockUntilSyncedToCurrentChain() in RPCs (Matt Corallo)
5ee3172 Add CWallet::BlockUntilSyncedToCurrentChain() (Matt Corallo)
0b2f42d Add CallFunctionInQueue to wait on validation interface queue drain (Matt Corallo)
2b4b345 Add ability to assert a lock is not held in DEBUG_LOCKORDER (Matt Corallo)
0343676 Call TransactionRemovedFromMempool in the CScheduler thread (Matt Corallo)
a7d3936 Add a CValidationInterface::TransactionRemovedFromMempool (Matt Corallo)

Pull request description:

  Based on #10179, this effectively reverts #9583, regaining most of the original speedups of #7946.

  This concludes the work of #9725, #10178, and #10179.

  See individual commit messages for more information.

Tree-SHA512: eead4809b0a75d1fb33b0765174ff52c972e45040635e38cf3686cef310859c1e6b3c00e7186cbd17374c6ae547bfbd6c1718fe36f26c76ba8a8b052d6ed7bc9
2017-11-15 16:25:40 +01:00
Russell Yanofsky aed1d90aca [wallet] Change feebumper from class to functions
Change feebumper from a stateful class into a namespace of stateless
functions.

Having the results of feebumper calls persist in an object makes process
separation between Qt and wallet awkward, because it means the feebumper object
either has to be serialized back and forth between Qt and wallet processes
between fee bump calls, or that the feebumper object needs to stay alive in the
wallet process with an object reference passed back to Qt. It's simpler just to
have fee bumper calls return their results immediately instead of storing them
in an object with an extended lifetime.

In addition to making feebumper stateless, also:

- Move LOCK calls from Qt code to feebumper
- Move TransactionCanBeBumped implementation from Qt code to feebumper
2017-11-10 17:16:46 -05:00
Russell Yanofsky 37bdcca3c3 [refactor] Make feebumper namespace
Future commit will remove the FeeBumper class. This commit simply places
everything into a feebumper namespace, and changes the enum class name
from BumpeFeeResult to feebumper::Result.
2017-11-10 17:03:15 -05:00
Russell Yanofsky 7c4f009195 [trivial] Rename feebumper variables according to project code style
Future PRs will completely refactor this translation unit and touch all
this code so we rename the variables to follow project stlye guidelines
in this preparation commit.

Don't use m_ prefixes for member variables since we're going to remove
the class entirely in the next commits.
2017-11-10 17:01:41 -05:00
John Newbery 5e0ba8f8cd [wallet] getreceivedbyaddress should return error if address is not mine 2017-11-10 16:07:37 -05:00
Wladimir J. van der Laan 77ba4bf960
Merge #10368: [wallet] Remove helper conversion operator from wallet
5a5e4e9 [wallet] Remove CTransaction&() helper conversion operator from wallet implementation. (Karl-Johan Alm)

Pull request description:

  The `CTransaction&()` operator in `CMerkleTx` makes conversion into `CTransaction`s transparent, but was marked as to-be-removed in favor of explicitly getting the `tx` ivar, presumably as the operator can lead to ambiguous behavior and makes the code harder to follow.

  This PR removes the operator and adapts callers. This includes some cases of `static_cast<CTransaction>(wtx)` → `*wtx.tx`, which is definitely an improvement.

Tree-SHA512: 95856fec7194d6a79615ea1c322abfcd6bcedf6ffd0cfa89bbdd332ce13035fa52dd4b828d20df673072dde1be64b79c513529a6f422dd5f0961ce722a32d56a
2017-11-09 14:23:13 +01:00
Wladimir J. van der Laan 77546a3182
Merge #11289: Add wallet backup text to import* and add* RPCs
c098c58 Wrap dumpwallet warning and note scripts aren't dumped (MeshCollider)
a38bfbc Add wallet backup text to import*, add* and dumpwallet RPCs (MeshCollider)

Pull request description:

  Closes https://github.com/bitcoin/bitcoin/issues/11243

  Adds "Requires a new wallet backup" text to `addwitnessaddress`, `importprivkey`, `importmulti`, `importaddress`, `importpubkey`, and `addmultisigaddress`. Also adds a warning to `dumpwallet` that backing up the seed alone is not sufficient to back up non-HD addresses

Tree-SHA512: 76d7cdca54d5b458acf479154620322391b889922525fddd6153f4164cfee393ad743757400cb8f6b1b30f24947df68ea9043b4e509f7df77a8fa05dda370933
2017-11-08 10:29:11 +01:00
MarcoFalke bfb270acfa
Merge #11590: [Wallet] always show help-line of wallet encryption calls
720d9e8fa [Wallet] always show help-line of wallet encryption calls (Jonas Schnelli)

Pull request description:

  We do currently show/hide the wallet encryption RPC calls from the help if the current wallet.
  In case of an encrypted wallet, `encryptwallet` is hidden and `walletpassphrasechange`, `walletpassphrasechange` and `walletlock` do appear in the help.

  This is no longer ideal in case of multiwallet due to the fact that one may want help infos in order to target a specific wallet.

  IMO its preferable to have a static help screen (show everything always). The currently show/hidden calls do handle the possible invalid encryption-state fine.

  Fixes #11588

Tree-SHA512: 513fecd15248a31361f5143685e8cdeb63dfd3fa7120828917e1db54d936dc3db60d48ce46efa5c3a563a48157fe962689879856eeeed53f904686b12aec204e
2017-11-02 12:58:56 -04:00
Jonas Schnelli 720d9e8fa1
[Wallet] always show help-line of wallet encryption calls 2017-10-31 20:22:41 -10:00
Russell Yanofsky 659b2061c4 Make listsinceblock refuse unknown block hash
Change suggested by Cory Fields <cory-nospam-@coryfields.com> who noticed
listsinceblock would ignore invalid block hashes causing it to return a
completely unfiltered list of transactions.
2017-10-26 07:10:59 -04:00
MeshCollider a38bfbc51d Add wallet backup text to import*, add* and dumpwallet RPCs 2017-10-14 13:57:11 +13:00
MeshCollider 43f76f6acd Add missing comma from rescanblockchain 2017-10-14 12:34:04 +13:00
Matt Corallo 89f03120a0 Remove redundant pwallet nullptr check 2017-10-13 19:30:15 -04:00
Matt Corallo 5d67a7868d Add calls to CWallet::BlockUntilSyncedToCurrentChain() in RPCs
This prevents the wallet-RPCs-return-stale-info issue from being
re-introduced when new-block callbacks no longer happen in the
block-connection cs_main lock
2017-10-13 19:29:54 -04:00
Jonas Schnelli 8c2de827e9
Merge #7061: [Wallet] Add RPC call "rescanblockchain <startheight> <stopheight>"
7a91ceb5e [QA] Add RPC based rescan test (Jonas Schnelli)
c77170fbd [Wallet] add rescanblockchain <start_height> <stop_height> RPC command (Jonas Schnelli)

Pull request description:

  A RPC rescan command is much more flexible for the following reasons:
  * You can define the start and end-height
  * It can be called during runtime
  * It can work in multiwallet environment

Tree-SHA512: df67177bad6ad1d08e5a621f095564524fa3eb87204c2048ef7265e77013e4b1b29f991708f807002329a507a254f35e79a4ed28a2d18d4b3da7a75d57ce0ea5
2017-10-13 15:23:22 -07:00
Jonas Schnelli c77170fbdb
[Wallet] add rescanblockchain <start_height> <stop_height> RPC command 2017-10-12 11:59:21 -07:00
Eelis 28f8b66577 Diagnose unsuitable outputs in lockunspent().
Fixes #2667.
2017-10-12 15:56:32 +02:00
practicalswift 680bc2cbb3 Use range-based for loops (C++11) when looping over map elements
Before this commit:

  for (std::map<T1, T2>::iterator x = y.begin(); x != y.end(); ++x) {
  }

After this commit:

  for (auto& x : y) {
  }
2017-10-09 21:31:58 +02:00
Pieter Wuille e278f12ca7 Support BIP173 in addwitnessaddress 2017-09-28 16:24:33 -07:00
Pieter Wuille c091b99379 Implement BIP173 addresses and tests 2017-09-28 16:24:30 -07:00
MarcoFalke 791a0e6dda
Merge #10767: [wallet] Clarify wallet initialization / destruction interface
5d2a3995e [trivial] fixup comment for VerifyWallets() (John Newbery)
43b0e81d0 [wallet] Add StartWallets() function to wallet/init.cpp (John Newbery)
290f3c56d [wallet] Add RegisterWalletRPC() function to wallet/init.cpp (John Newbery)
062d63102 [wallet] Add CloseWallets() function to wallet/init.cpp (John Newbery)
77fe07c15 [wallet] Add StopWallets() function to wallet/init.cpp (John Newbery)
2da5eafa4 [wallet] Add FlushWallets() function to wallet/init.cpp (John Newbery)
1b9cee66e [wallet] Rename WalletVerify() to VerifyWallets() (John Newbery)
9c76ba18c [wallet] Rename InitLoadWallet() to OpenWallets() (John Newbery)

Pull request description:

  Apologies for the mostly code move only PR. This is a pre-req for both #10740 and #10762

  All wallet component initialization/destruction functions are now in their own `wallet/init.cpp` translation unit and are no longer static functions on the CWallet class. The bitcoin_server also no longer has any knowledge that there are multiple wallets in vpwallet.

  There should be no changes in behavior from this PR.

Tree-SHA512: 7c260eb094f2fa1a88d803769ba60935810968a7309f731135e4b17623b97f18c03bbcd293c942093d1efce62c6c978f9ff484d54dc9a60bc2fcb5af2d160fcd
2017-09-07 16:35:52 -07:00
John Newbery 290f3c56d9 [wallet] Add RegisterWalletRPC() function to wallet/init.cpp 2017-09-07 16:21:26 -07:00
Wladimir J. van der Laan efb4383ef6
Merge #10793: Changing &var[0] to var.data()
592404f03 Changing &vec[0] to vec.data(), what 9804 missed (MeshCollider)

Pull request description:

  This just continues the work of https://github.com/bitcoin/bitcoin/pull/9804

  Modifies a lot of `&vector[]`'s to `vector.data()`'s across all the files including tests, just the stuff that 9804 missed

Tree-SHA512: dd1a9dffb999dea4fba78dcc91fe02f90250db86f5c74948e1ff3e8b4036b2154b600555eaa04dece5368920aae3513bc36425dc96e4319ca1041b0928a6b656
2017-09-08 01:16:54 +02:00
MeshCollider 592404f03f Changing &vec[0] to vec.data(), what 9804 missed 2017-09-08 10:36:26 +12:00
Pieter Wuille 5c8ff0d448 Introduce wrappers around CBitcoinAddress
This patch removes the need for the intermediary Base58 type
CBitcoinAddress, by providing {Encode,Decode,IsValid}Destination
function that directly operate on the conversion between strings
and CTxDestination.
2017-09-06 13:07:45 -07:00
MeshCollider bbdbe805a2 Add iswitness parameter to decode- and fundrawtransaction RPCs 2017-09-06 11:24:59 +12:00
MarcoFalke 4eb1f39d42
Merge #11173: RPC: Fix currency unit string in the help text
47ba2c312 Fix currency/fee-rate unit string in the help text (Akio Nakamura)

Pull request description:

  1. The RPC help text should use the constant `CURRENCY_UNIT` defined in `policy/feerate.cpp` instead of the literal `'BTC'`.
    In the following 2 RPC commands, `'BTC'` is written directly in the help text.
    This commit changes them to use that constant.
       1) `estimatesmartfee`
       2) `estimaterawfee`

  2. Some RPC command use `'satoshis'` as the unit.
    It should be written as `'satoshis'` instead of `'Satoshis'` in the RPC help text.
    So, this commit fixes this typo in `getblocktemplate`.

Tree-SHA512: d0bd1cd90560e59bf456b076b958a2a1c998f85a7e65aeb6b2abcaba18919a3ae62f7c3909210461084c1a3275a35b6ba3ea3ec8f5cce33702ffe383c9e84bce
2017-09-05 14:46:05 -07:00
Akio Nakamura 47ba2c312a Fix currency/fee-rate unit string in the help text
1. The RPC help text should use the constant CURRENCY_UNIT defined in
  policy/feerate.cpp instead of the literal 'BTC'. In the following
  2 RPC commands, 'BTC' is written directly in the help text.
    1) estimatesmartfee
    2) estimaterawfee
  And also, for these help strings, the notation
  'fee-per-kilobyte (in BTC)' is somewhat ambiguous.

  To write more precisely, this commit changes to 'fee rate in BTC/kB'
  with using the constant CURRENCY_UNIT.

2. Some RPC command use 'satoshis' as the unit. It should be written
  as 'satoshis' instead of 'Satoshis' in the RPC help text.

  So, this commit fixes this typo in getblocktemplate.

3. The phrase that '... feerate (BTC per KB) ...'  is used to explain
  the fee rate in the help text of following 2 RPC commands.
    1) getmempoolinfo
    2) fundrawtransaction
  But they are different from other similar help text of the RPCs.
  And also, 'KB' implies Kibibyte (2^10 byte).

  To unify and to clarify, this commit changes these phrase to
  '... fee rate in BTC/kB ...'.
  (BTC references the constant 'CURRENCY_UNIT')
2017-09-05 10:07:55 +09:00
Andrew Chow ec6902d0ea rpc: Push down safe mode checks
This contains most of the changes of 10563 "remove safe mode", but doesn't
remove the safe mode yet, but put an `ObserveSafeMode()` check in
individual calls with okSafeMode=false.

This cleans up the ugly "okSafeMode" flag from the dispatch tables,
which is not a concern for the RPC server.

Extra-author: Wladimir J. van der Laan <laanwj@gmail.com>
2017-08-29 10:09:41 +02:00
Wladimir J. van der Laan 07c92b98e2
Merge #10976: [MOVEONLY] Move some static functions out of wallet.h/cpp
f01103c MOVEONLY: Init functions wallet/wallet.cpp -> wallet/init.cpp (Russell Yanofsky)
e7fe320 MOVEONLY: Fee functions wallet/wallet.cpp -> wallet/fees.cpp (Russell Yanofsky)
d97fe20 Move some static functions out of wallet.h/cpp (Russell Yanofsky)

Pull request description:

  This just moves some static wallet fee and init functions out of `wallet/wallet.cpp` and into new `wallet/fees.cpp` and `wallet/init.cpp` source files. There is one commit updating declarations and callers, followed by two MOVEONLY commits actually moving the function bodies.

  This change is desirable because wallet.h/cpp are monolithic and hard to navigate, so pulling things out and grouping together pieces of related functionality should improve the organization.

  Another motivation is the wallet process separation work in https://github.com/bitcoin/bitcoin/pull/10973, where (at least initially) parameter parsing and fee estimation are still done in the main process rather than the wallet process, and having functions that run in different processes scrambled up throughout wallet.cpp is unnecessarily confusing.

Tree-SHA512: 6e6982ff82b2ab4e681c043907e2b1801ceb9513394730070f16c46ad338278a863f5b3759aa13db76a259b268b1c919c81f4e339f0796a3cfb990161e8c316d
2017-08-25 21:30:42 +02:00
Wladimir J. van der Laan 7ed57d3d7c
Merge #11050: Avoid treating null RPC arguments different from missing arguments
745d2e3 Clean up getbalance RPC parameter handling (Russell Yanofsky)
fd5d71e Update developer notes after params.size() cleanup (Russell Yanofsky)
e067673 Avoid treating null RPC arguments different from missing arguments (Russell Yanofsky)
e666efc Get rid of redundant RPC params.size() checks (Russell Yanofsky)

Pull request description:

  This is a followup to #10783.

  - The first commit doesn't change behavior at all, just simplifies code.
  - The second commit just changes RPC methods to treat null arguments the same as missing arguments instead of throwing type errors.
  - The third commit updates developer notes after the cleanup.
  - The forth commit does some additional code cleanup in `getbalance`.

  Followup changes that should happen in future PRs:

  - [ ] Replace uses of `.isTrue()` with calls to `.get_bool()` so numbers, objects, and strings cause type errors instead of being interpreted as false. https://github.com/bitcoin/bitcoin/pull/11050#discussion_r133850525
  - [ ] Add braces around if statements. https://github.com/bitcoin/bitcoin/pull/11050#discussion_r133851133
  - [ ] Maybe improve UniValue type error exceptions and eliminate RPCTypeCheck and RPCTypeCheckArgument functions. https://github.com/bitcoin/bitcoin/pull/11050#discussion_r133829303

Tree-SHA512: e72f696011d20acc0778e996659e41f9426bffce387b29ff63bf59ad1163d5146761e4445b2b9b9e069a80596a57c7f4402b75a15d5d20f69f775ae558cf67e9
2017-08-22 09:26:38 +02:00
Wladimir J. van der Laan fc51565cbd
Merge #11039: Avoid second mapWallet lookup
8f2f1e0 wallet: Avoid second mapWallet lookup (João Barbosa)

Pull request description:

  All calls to `mapWallet.count()` have the intent to detect if a `txid` exists and most are followed by a second lookup to retrieve the `CWalletTx`.

  This PR replaces all `mapWallet.count()` calls with `mapWallet.find()` to avoid the second lookup.

Tree-SHA512: 96b7de7f5520ebf789a1aec1949a4e9c74e13683869cee012f717e5be8e51097d068e2347a36e89097c9a89f1ed1a1529db71760dac9b572e36a3e9ac1155f29
2017-08-18 16:25:59 +02:00
practicalswift 64fb0ac016 Declare single-argument (non-converting) constructors "explicit"
In order to avoid unintended implicit conversions.
2017-08-16 16:33:25 +02:00
practicalswift 36d326e8b0 Use nullptr instead of zero (0) as the null pointer constant 2017-08-16 10:24:18 +02:00
MarcoFalke 4fb2586661
Merge #10956: Fix typos
9d5e98ff8 Fix typos. (practicalswift)

Pull request description:

  Fix some typos not covered by #10705.

Tree-SHA512: f06e9541f6ae13ef5d6731399b61795997b21a8816abeb1749c93e99a5c47354e6cbd4a3d145f4dc6ef8a13db179799a3121ecbb7288abf3e8d81cdf81500d37
2017-08-16 00:37:18 +02:00
Russell Yanofsky 745d2e315f Clean up getbalance RPC parameter handling
Only change in behavior is that unsupported combinations of parameters now
trigger more specific error messages instead of the vague "JSON value is not a
string as expected" error.
2017-08-15 15:47:27 -04:00
Russell Yanofsky e067673f4e Avoid treating null RPC arguments different from missing arguments
This changes RPC methods to treat null arguments the same as missing arguments,
instead of throwing type errors. Specifically:

- `getbalance` method now returns the wallet balance when the `account` param
  is null instead of throwing a type error (same as when parameter is missing).
  It is still an error to supply `minconf` or `watchonly` options when the
  account is null.

- `addnode` and `setban` methods now return help text instead of type errors if
  `command` params are null (same as when params are missing).

- `sendrawtransaction`, `setaccount`, `movecmd`, `sendfrom`,
  `addmultisigaddress`, `listaccounts`, `lockunspent` methods accept null
  default values where missing values were previously allowed, and treat them
  the same.
2017-08-14 19:44:02 -04:00
Russell Yanofsky e666efcdba Get rid of redundant RPC params.size() checks
No change in behavior.
2017-08-14 19:38:18 -04:00
João Barbosa 8f2f1e0458 wallet: Avoid second mapWallet lookup 2017-08-14 23:06:06 +01:00
Russell Yanofsky d97fe2016c Move some static functions out of wallet.h/cpp
This commit just moves a few function declarations and updates callers.
Function bodies are moved in two followup MOVEONLY commits.

This change is desirable because wallet.h/cpp are monolithic and hard to
navigate, so pulling things out and grouping together pieces of related
functionality should improve the organization.

Another proximate motivation is the wallet process separation work in
https://github.com/bitcoin/bitcoin/pull/10973, where (at least initially)
parameter parsing and fee estimation are still done in the main process rather
than the wallet process, and having functions that run in different processes
scrambled up throughout wallet.cpp is unnecessarily confusing.
2017-08-14 11:19:38 -04:00
Marko Bencun bb81e17355 scripted-diff: stop using the gArgs wrappers
They were temporary additions to ease the transition.

-BEGIN VERIFY SCRIPT-
find src/ -name "*.cpp" ! -wholename "src/util.h" ! -wholename "src/util.cpp" | xargs perl -i -pe 's/(?<!\.)(ParseParameters|ReadConfigFile|IsArgSet|(Soft|Force)?(Get|Set)(|Bool|)Arg(s)?)\(/gArgs.\1(/g'
-END VERIFY SCRIPT-
2017-08-14 17:02:10 +02:00
Wladimir J. van der Laan ce74799a3c
Merge #10483: scripted-diff: Use the C++11 keyword nullptr to denote the pointer literal instead of the macro NULL
90d4d89 scripted-diff: Use the C++11 keyword nullptr to denote the pointer literal instead of the macro NULL (practicalswift)

Pull request description:

  Since C++11 the macro `NULL` may be:
  * an integer literal with value zero, or
  * a prvalue of type `std::nullptr_t`

  By using the C++11 keyword `nullptr` we are guaranteed a prvalue of type `std::nullptr_t`.

  For a more thorough discussion, see "A name for the null pointer: nullptr" (Sutter &
  Stroustrup), http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2007/n2431.pdf

  With this patch applied there are no `NULL` macro usages left in the repo:

  ```
  $ git grep NULL -- "*.cpp" "*.h" | egrep -v '(/univalue/|/secp256k1/|/leveldb/|_NULL|NULLDUMMY|torcontrol.*NULL|NULL cert)' | wc -l
  0
  ```

  The road towards `nullptr` (C++11) is split into two PRs:
  * `NULL` → `nullptr` is handled in PR #10483 (scripted, this PR)
  * `0` → `nullptr` is handled in PR #10645 (manual)

Tree-SHA512: 3c395d66f2ad724a8e6fed74b93634de8bfc0c0eafac94e64e5194c939499fefd6e68f047de3083ad0b4eff37df9a8a3a76349aa17d55eabbd8e0412f140a297
2017-08-14 16:30:59 +02:00
practicalswift 9d5e98ff80 Fix typos. 2017-08-08 17:12:57 +02:00
John Newbery 055d95f842 [wallet] return correct error code from resendwallettransaction 2017-08-07 15:50:01 -04:00
practicalswift 90d4d89230 scripted-diff: Use the C++11 keyword nullptr to denote the pointer literal instead of the macro NULL
-BEGIN VERIFY SCRIPT-
sed -i 's/\<NULL\>/nullptr/g' src/*.cpp src/*.h src/*/*.cpp src/*/*.h src/qt/*/*.cpp src/qt/*/*.h src/wallet/*/*.cpp src/wallet/*/*.h src/support/allocators/*.h
sed -i 's/Prefer nullptr, otherwise SAFECOOKIE./Prefer NULL, otherwise SAFECOOKIE./g' src/torcontrol.cpp
sed -i 's/tor: Using nullptr authentication/tor: Using NULL authentication/g' src/torcontrol.cpp
sed -i 's/METHODS=nullptr/METHODS=NULL/g' src/test/torcontrol_tests.cpp src/torcontrol.cpp
sed -i 's/nullptr certificates/NULL certificates/g' src/qt/paymentserver.cpp
sed -i 's/"nullptr"/"NULL"/g' src/torcontrol.cpp src/test/torcontrol_tests.cpp
-END VERIFY SCRIPT-
2017-08-07 07:36:37 +02:00
Matt Corallo 01699fb283 Fix resendwallettransactions assert failure if -walletbroadcast=0 2017-08-06 21:40:56 -04:00
Wladimir J. van der Laan f66c596505
Merge #10788: [RPC] Fix addwitnessaddress by replacing ismine with producesignature
e222dc2 Replace ismine with producesignature check in witnessifier (Andrew Chow)

Pull request description:

  Instead of using ismine to check whether an address can be spent by us, make the witness version of the script or address first and then use ProduceSignature with the DummySignatureCreator to check if we can
  solve for the script.

  This is to fix cases where we don't have all of the private keys (for something like a multisig address) but have the redeemscript so we can witnessify it.

Tree-SHA512: 371777aee839cceb41f099109a13689120d35cf3880cde39216596cc2aac5cc1096af7d9cf07ad9306c3b05c073897f4518a7e97f0b88642f1e3b80b799f481e
2017-08-01 14:27:01 +02:00
Andrew Chow e222dc2aee Replace ismine with producesignature check in witnessifier
Instead of using ismine to check whether an address can be spent by us,
make the witness version of the script or address first and then use
ProduceSignature with the DummySignatureCreator to check if we can
solve for the script.

Also fixes test cases to reflect this change.
2017-07-27 15:04:00 -07:00
Russell Yanofsky df389bca20 Change wallet method disabled error text
Not strictly backwards compatible because the error is not new in this release.
2017-07-26 09:35:17 -04:00
Russell Yanofsky e526b3d34c Fix misleading "Method not found" multiwallet errors
Raise RPC_WALLET_NOT_SPECIFIED instead of RPC_METHOD_NOT_FOUND when a required
wallet filename was not specified in an RPC call.

Also raise more specific RPC_WALLET_NOT_FOUND error instead of
RPC_INVALID_PARAMETER in case an invalid wallet was specified, for consistency.
2017-07-26 02:48:15 -04:00
Wladimir J. van der Laan 78f307b664
Merge #10655: Properly document target_confirmations in listsinceblock
9f8a46f Properly document target_confirmations in listsinceblock (Ryan Havar)

Pull request description:

  There seems to be some misunderstandings about this, but it's a heavily used function so I'd like to make sure the docs are clear about how it works.

  For a later issue:
  * Change the default of target_confirmations to 6  (1 is a pretty silly default)
  * Change the name of target_confirmations (it's really a horrible name)

Tree-SHA512: a2fba2fab30019cea9db56cd7e31de95ba31090617ab336bdf130f9591bfcf3fc5fbd9e7e1e40b6c7bd2f74b9b4658afb1fdc7fc44e1f79520d1319758982a1c
2017-07-26 08:45:01 +02:00
Wladimir J. van der Laan 8537187d42
Merge #10799: Prevent user from specifying conflicting parameters to fundrawtx
99c7fc3 Prevent user from specifying conflicting parameters to fundrawtx (Matt Corallo)

Pull request description:

  estimate_mode/conf_target both are overridden by feeRate, so should
  not be specified together with feeRate.

  Based on #10706

Tree-SHA512: 8ccd08575fd1f2a0d45112538ffbbc73983ee172963230b0cc7ac41d13c6f3c740917f82b212c41ded3a64d873452e7f2c7af49f3b47cab897f8e85117f21333
2017-07-25 22:02:58 +02:00
Ryan Havar 9f8a46f077 Properly document target_confirmations in listsinceblock 2017-07-25 07:25:07 -12:00
Wladimir J. van der Laan 1124328ad1
Merge #10789: Punctuation/grammer fixes in rpcwallet.cpp
a5ecaf1 Fix misspellings and remove safety verbiage (Steven D. Lander)

Pull request description:

  Standardizing punctuation on CLI output and also including a few fixes for grammer.  This PR is for text only changes and includes no code edits.

Tree-SHA512: afde551bf1212838822188b6723f2bf1b7222decfa1cd7aa6b04967489108a29f80833af6059252af028c53437755f258275af0614e0d4d0311e09421cd8e131
2017-07-25 09:49:06 +02:00
Wladimir J. van der Laan 6ef3c7ec62
Merge #9622: [rpc] listsinceblock should include lost transactions when parameter is a reorg'd block
876e92b Testing: listsinceblock should display all transactions that were affected since the given block, including transactions that were removed due to a reorg. (Karl-Johan Alm)
f999c46 listsinceblock: optionally find and list any transactions that were undone due to reorg when requesting a non-main chain block in a new 'removed' array. (Karl-Johan Alm)

Pull request description:

  The following scenario will not notify the caller of the fact `tx0` has been dropped:

  1. User 1 receives BTC in tx0 from utxo1 in block aa1.
  2. User 2 receives BTC in tx1 from utxo1 (same) in block bb1
  3. User 1 sees 2 confirmations at block aa3.
  4. Reorg into bb chain.
  5. User 1 asks `listsinceblock aa3` and does not see that tx0 is now invalidated.

  See `listsinceblock.py` commit for related test.

  The proposed fix is to iterate from the given block down to the fork point, and to check each transaction in the blocks against the wallet, in addition to including all transactions from the fork point to the active chain tip (the current behavior). Any transactions that were present will now also be listed in the `listsinceblock` output in a new `replaced` array. This operation may be a bit heavy but the circumstances (and perceived frequency of occurrence) warrant it, I believe.

  Example output:
  ```Python
  {
    'transactions': [],
    'replaced': [
      {
        'walletconflicts': [],
        'vout': 1,
        'account': '',
        'timereceived': 1485234857,
        'time': 1485234857,
        'amount': '1.00000000',
        'bip125-replaceable': 'unknown',
        'trusted': False,
        'category': 'receive',
        'txid': 'ce673859a30dee1d2ebdb3c05f2eea7b1da54baf68f93bb8bfe37c5f09ed22ff',
        'address': 'miqEt4kWp9zSizwGGuUWLAmxEcTW9bFUnQ',
        'label': '',
        'confirmations': -7
      }
    ],
    'lastblock': '7a388f27d09e3699102a4ebf81597d974fc4c72093eeaa02adffbbf7527f6715'
  }
  ```

  I believe this addresses the comment by @luke-jr in https://github.com/bitcoin/bitcoin/pull/9516#issuecomment-274190081 but I could be wrong..

Tree-SHA512: 607b5dcaeccb9dc0d963d3de138c40490f3e923050b29821e6bd513d26beb587bddc748fbb194503fe618cfe34a6ed65d95e8d9c5764a882b6c5f976520cff35
2017-07-24 12:59:48 +02:00
Karl-Johan Alm f999c46cae
listsinceblock: optionally find and list any transactions that were undone due to reorg when requesting a non-main chain block in a new 'removed' array. 2017-07-21 09:50:59 +09:00