Commit graph

149 commits

Author SHA1 Message Date
Ross Nicoll ce564e381a Merge AuxPoW support from Namecore
Changes are as below:

Wrap CBlockHeader::nVersion into a new class (CBlockVersion).  This allows to take care of interpreting the field into a base version, auxpow flag and the chain ID.

Update getauxblock.py for new 'generate' RPC call.

Add 'auxpow' to block JSON.

Accept auxpow as PoW verification.

Add unit tests for auxpow verification.

Add check for memory-layout of CBlockVersion.

Weaken auxpow chain ID checks for the testnet.

Allow Params() to overrule when to check the auxpow chain ID and for legacy blocks.  Use this to disable the checks on testnet.

Introduce CPureBlockHeader.

Split the block header part that is used by auxpow and the "real" block header (that uses auxpow) to resolve the cyclic dependency between the two.

Differentiate between uint256 and arith_uint256.

This change was done upstream, modify the auxpow code.

Add missing lock in auxpow_tests.

Fix REST header check for auxpow headers.

Those can be longer, thus take that into account.  Also perform the check actually on an auxpow header.

Correctly set the coinbase for getauxblock results.

Call IncrementExtraNonce in getauxblock so that the coinbase is actually initialised with the stuff it should be.  (BIP30 block height and COINBASE_FLAGS.)

Implement getauxblock plus regression test.

Turn auxpow test into FIXTURE test.

This allows using of the Params() calls.

Move CMerkleTx code to auxpow.cpp.

Otherwise we get linker errors when building without wallet.

Fix rebase with BIP66.

Update the code to handle BIP66's nVersion=3.

Enforce that auxpow parent blocks have no auxpow block version.

This is for compatibility with namecoind.  See also https://github.com/namecoin/namecoin/pull/199.

Move auxpow-related parameters to Consensus::Params.
2019-07-13 22:25:22 +00:00
Ross Nicoll 76a9aab2f4 Scrypt n=1024 PoW hash
Scrypt n=1024 PoW hash based upon Colin Percival's Tarnsnap (2009)

Modified by Artforz, coblee, pooler, wtogami, Nikolay Belikov, Adrian Gallagher, Ross Nicoll
2019-04-03 05:16:26 +00:00
Sjors Provoost f7dbcaa72f
[doc] getblocktemplate: use SegWit in example 2018-10-18 15:06:31 +07:00
MarcoFalke 10b9a811b6
Merge #12764: doc: Remove field in getblocktemplate help that has never been used.
ac8a1d092e [RPC] Remove field in getblocktemplate help that has never been used (Conor Scott)

Pull request description:

  [BIP 22 - getblocktemplate](https://github.com/bitcoin/bips/blob/master/bip-0022.mediawiki#Transactions%20Object%20Format) specifies an optional flag, `required` if the transaction must be in the block.

  Luke's implementation #936 did not include this flag, and it was later added to the help description in #3246 (more than a year later) but the field was still never actually implemented. As far as I can tell, bitcoin core would have never actually included this in a `getblocktemplate` call, so it seems logical to remove it from the help description.

  If I am missing something or this is considered harmless - I can close the PR.

Tree-SHA512: f25dda51cc4e1512aff69309be04e3053bdccc1cf03c8d58e8866aa1fdf9d86cc57df872e85528351fc8a8d6d64a8f46a36c513680834762d854f368fbeb0f44
2018-07-22 09:40:18 -04:00
Ben Woosley 1fabd59e7e
Break circular dependency: init -> * -> init by extracting shutdown.h
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 `AbortShutdown` for setting it to `false`.

Note I originally called `AbortShutdown` `CancelShutdown` but that name was
already taken by winuser.h
https://travis-ci.org/bitcoin/bitcoin/jobs/386913329

This change also triggered a build error in bench. Fixing it required moving LIBBITCOIN_SERVER after LIBBITCOIN_WALLET in bench_bench_bitcoin_LDADD To make
server definitions in src/net.cpp available to wallet methods in
src/wallet/wallet.cpp. Specifically, solving:

  libbitcoin_wallet.a(libbitcoin_wallet_a-wallet.o): In function `CWalletTx::RelayWalletTransaction(CConnman*)':
  wallet.cpp:(.text+0x3f0e): undefined reference to `CConnman::NodeFullyConnected(CNode const*)'
  collect2: error: ld returned 1 exit status

https://travis-ci.org/bitcoin/bitcoin/jobs/392133581

Need for remaining init.h includes confirmed via a thorough search with a more
specific regex:
  \bInterrupt\(\)|\bShutdown\(\)|\bInitLogging\(\)|\bInitParameterInteraction\(\)|\bAppInitBasicSetup\(\)|\bAppInitParameterInteraction\(\)|\bAppInitSanityChecks\(\)|\bAppInitLockDataDirectory\(\)|\bAppInitMain\(\)|\bSetupServerArgs\(\)|\bLicenseInfo\(\)|g_wallet_init_interface|init.h
2018-06-25 00:08:49 -04:00
Jonas Schnelli 3f398d7a17
Merge #13439: rpc: Avoid "duplicate" return value for invalid submitblock
f74894480 Only set fNewBlock to true in AcceptBlock when we write to disk (Matt Corallo)
fa6e49731 rpc: Avoid "duplicate" return value for invalid submitblock (MarcoFalke)

Pull request description:

  This is #13395 with one more commit tacked on. MarcoFalke got tired of dealing with the stupidity of fixing a return code with too many rounds of review (not that I blame him). Honestly we should probably have no return whatsoever, but for now, this fixes it (as well as nLastBlockTime for eviction purposes).

  Original description:

  When `submitblock` of an invalid block, the return value should not be `"duplicate"`.

  This is only seen when the header was previously found (denoted by the incorrectly named boolean `fBlockPresent`). Fix this bug by removing `fBlockPresent`.

Tree-SHA512: 0ce3092655d5d904b4c8c5ff7479f73ce387144a738f20472b8af132564005c6db5594ae366e589508f6258506ee7a28b1c7995a83a8328b334f99316006bf2d
2018-06-19 09:25:17 +02:00
MarcoFalke fa6e49731b
rpc: Avoid "duplicate" return value for invalid submitblock 2018-06-11 15:08:50 -04:00
Ben Woosley ebec7317ca
Drop the chain argument to GetDifficulty
This removes the need to include rpc/blockchain.cpp in order to put
GetDifficulty under test. GetDifficulty was called in two ways:
* with a guaranteed non-null blockindex
* with no argument

Change the latter case to be provided chainActive.Tip() explicitly.
2018-05-20 22:19:42 -07:00
MarcoFalke c5870ab689
Merge #12963: Fix Clang Static Analyzer warnings
159c32d1f1 Add assertion to guide static analyzers. Clang Static Analyzer needs this guidance. (practicalswift)
fd447a6efe Fix dead stores. Values were stored but never read. Limit scope. (practicalswift)

Pull request description:

  Fix Clang Static Analyzer warnings reported by @kallewoof in #12961:

  * Fix dead stores. Values were stored but never read.
  * Add assertion to guide static analyzers. See #12961 for details.

Tree-SHA512: 83dbec821f45217637316bee978e7543f2d2caeb7f7b0b3aec107fede0fff8baa756da8f6b761ae0d38537740839ac9752f6689109c38a4b05c0c041aaa3a1fb
2018-05-14 10:45:24 -04:00
practicalswift c3f34d06be Make it clear which functions that are intended to be translation unit local
Do not share functions that are meant to be translation unit local with
other translation units. Use internal linkage for those consistently.
2018-05-03 21:47:40 +02:00
Wladimir J. van der Laan 84efa9a0f7
Merge #12448: Interrupt block generation on shutdown request
0851a75 rpc: Interrupt block generation on shutdown request (João Barbosa)

Pull request description:

  With this simple change, after running `bitcoin-cli -regtest generate 100000`, it is possible to interrupt `bitcoind` cleanly without waiting for the generation to complete.

Tree-SHA512: f0f7cdde242e595cfdaea31ae8bddbc25933621b63f639e813d272c2b00ce2ef52f0c14ae44954ba8c49f0fc846bcc3bfd5419e52b3347a68bb0341ce6b02d26
2018-04-23 18:04:52 +02:00
Pieter Wuille 4ba6da5574
Merge #12743: Fix csBestBlock/cvBlockChange waiting in rpc/mining
4a6c0e3dcf Modernize best block mutex/cv/hash variable naming (Pieter Wuille)
45dd135039 Fix csBestBlock/cvBlockChange waiting in rpc/mining (Pieter Wuille)

Pull request description:

  This is an alternative to #11694.

  It reintroduces a uint256 variable with the best block hash, protected by csBestBlock, and only updated while holding it.

  Also rename the involved variable to modern guidelines, as there are very few uses.

Tree-SHA512: 826a86c7d3cee7fe49f99f4398ae99e81cb0563197eaeba77306a3ca6072b67cdb932bc35720fc0f99c2a57b218efa029d0b8bdfb240591a629b2e90efa3199d
2018-04-12 18:25:44 -07:00
practicalswift 159c32d1f1 Add assertion to guide static analyzers. Clang Static Analyzer needs this guidance. 2018-04-12 14:37:53 +02:00
MarcoFalke cd8e45b4e7
Merge #12007: [Doc] Clarify the meaning of fee delta not being a fee rate in prioritisetransaction RPC
c198dc00e1 [Doc] Clarify the meaning of fee delta not being a fee rate in prioritisetransaction RPC (Jan Čapek)

Pull request description:

  Hi,

  I have faced some confusion among our developers considering this being a fee rate. Would you consider including this tiny doc update?

  Best regards,

  Jan Capek

Tree-SHA512: cd0560540418e53c5c19ceab2d5aca229f4ef6b788b9543695742522e1c63a7f2cce2574b47fead098a106da2f77e297f0c728474565f6259b50d62369bbe7da
2018-04-09 08:04:10 -04:00
Pieter Wuille 4a6c0e3dcf Modernize best block mutex/cv/hash variable naming 2018-04-03 21:53:27 -07:00
Pieter Wuille 45dd135039 Fix csBestBlock/cvBlockChange waiting in rpc/mining 2018-04-03 21:53:27 -07:00
Wladimir J. van der Laan 3de01268b7
Merge #10742: scripted-diff: Use scoped enumerations (C++11, "enum class")
1f45e21 scripted-diff: Convert 11 enums into scoped enums (C++11) (practicalswift)

Pull request description:

  Rationale (from Bjarne Stroustrup's ["C++11 FAQ"](http://www.stroustrup.com/C++11FAQ.html#enum)):

  >
  > The enum classes ("new enums", "strong enums") address three problems with traditional C++ enumerations:
  >
  > * conventional enums implicitly convert to int, causing errors when someone does not want an enumeration to act as an integer.
  > * conventional enums export their enumerators to the surrounding scope, causing name clashes.
  > * the underlying type of an enum cannot be specified, causing confusion, compatibility problems, and makes forward declaration impossible.
  >
  > The new enums are "enum class" because they combine aspects of traditional enumerations (names values) with aspects of classes (scoped members and absence of conversions).

Tree-SHA512: 9656e1cf4c3cabd4378c7a38d0c2eaf79e4a54d204a3c5762330840e55ee7e141e188a3efb2b4daf0ef3110bbaff80d8b9253abf2a9b015cdc4d60b49ac2b914
2018-03-27 16:38:14 +02:00
Conor Scott ac8a1d092e [RPC] Remove field in getblocktemplate help that has never been used 2018-03-26 13:27:39 +04:00
Wladimir J. van der Laan d42a4fe5aa
Merge #11041: Add LookupBlockIndex
92fabcd44 Add LookupBlockIndex function (João Barbosa)
43a32b739 Add missing cs_lock in CreateWalletFromFile (João Barbosa)
f814a3e8f Fix cs_main lock in LoadExternalBlockFile (João Barbosa)
c651df8b3 Lock cs_main while loading block index in AppInitMain (João Barbosa)
02de6a6bc Assert cs_main is held when accessing mapBlockIndex (João Barbosa)

Pull request description:

  Replace all `mapBlockIndex` lookups with the new `LookupBlockIndex()`. In some cases it avoids a second lookup.

Tree-SHA512: ca31118f028a19721f2191d86f2dd398144d04df345694575a64aeb293be2f85785201480c3c578a0ec99690516205708558c0fd4168b09313378fd4e60a8412
2018-03-13 19:12:35 +01:00
practicalswift 1f45e2164a scripted-diff: Convert 11 enums into scoped enums (C++11)
-BEGIN VERIFY SCRIPT-

sed -i 's/enum DBErrors/enum class DBErrors/g' src/wallet/walletdb.h
git grep -l DB_ | xargs sed -i 's/DB_\(LOAD_OK\|CORRUPT\|NONCRITICAL_ERROR\|TOO_NEW\|LOAD_FAIL\|NEED_REWRITE\)/DBErrors::\1/g'
sed -i 's/^    DBErrors::/    /g' src/wallet/walletdb.h

sed -i 's/enum VerifyResult/enum class VerifyResult/g' src/wallet/db.h
sed -i 's/\(VERIFY_OK\|RECOVER_OK\|RECOVER_FAIL\)/VerifyResult::\1/g' src/wallet/db.cpp

sed -i 's/enum ThresholdState/enum class ThresholdState/g' src/versionbits.h
git grep -l THRESHOLD_ | xargs sed -i 's/THRESHOLD_\(DEFINED\|STARTED\|LOCKED_IN\|ACTIVE\|FAILED\)/ThresholdState::\1/g'
sed -i 's/^    ThresholdState::/    /g' src/versionbits.h

sed -i 's/enum SigVersion/enum class SigVersion/g' src/script/interpreter.h
git grep -l SIGVERSION_ | xargs sed -i 's/SIGVERSION_\(BASE\|WITNESS_V0\)/SigVersion::\1/g'
sed -i 's/^    SigVersion::/    /g' src/script/interpreter.h

sed -i 's/enum RetFormat {/enum class RetFormat {/g' src/rest.cpp
sed -i 's/RF_\(UNDEF\|BINARY\|HEX\|JSON\)/RetFormat::\1/g' src/rest.cpp
sed -i 's/^    RetFormat::/    /g' src/rest.cpp

sed -i 's/enum HelpMessageMode {/enum class HelpMessageMode {/g' src/init.h
git grep -l HMM_ | xargs sed -i 's/HMM_BITCOIN/HelpMessageMode::BITCOIN/g'
sed -i 's/^    HelpMessageMode::/    /g' src/init.h

sed -i 's/enum FeeEstimateHorizon/enum class FeeEstimateHorizon/g' src/policy/fees.h

sed -i 's/enum RBFTransactionState/enum class RBFTransactionState/g' src/policy/rbf.h
git grep -l RBF_ | xargs sed -i 's/RBF_TRANSACTIONSTATE_\(UNKNOWN\|REPLACEABLE_BIP125\|FINAL\)/RBFTransactionState::\1/g'
sed -i 's/^    RBFTransactionState::/    /g' src/policy/rbf.h

sed -i 's/enum BlockSource {/enum class BlockSource {/g' src/qt/clientmodel.h
git grep -l BLOCK_SOURCE_ | xargs sed -i 's/BLOCK_SOURCE_\(NONE\|REINDEX\|DISK\|NETWORK\)/BlockSource::\1/g'
sed -i 's/^    BlockSource::/    /g' src/qt/clientmodel.h

sed -i 's/enum FlushStateMode {/enum class FlushStateMode {/g' src/validation.cpp
sed -i 's/FLUSH_STATE_\(NONE\|IF_NEEDED\|PERIODIC\|ALWAYS\)/FlushStateMode::\1/g' src/validation.cpp
sed -i 's/^    FlushStateMode::/    /g' src/validation.cpp

sed -i 's/enum WitnessMode {/enum class WitnessMode {/g' src/test/script_tests.cpp
sed -i 's/WITNESS_\(NONE\|PKH\|SH\)/WitnessMode::\1/g' src/test/script_tests.cpp
sed -i 's/^    WitnessMode::/    /g' src/test/script_tests.cpp

-END VERIFY SCRIPT-
2018-03-09 15:03:40 +01:00
João Barbosa 92fabcd443 Add LookupBlockIndex function 2018-03-06 19:52:19 +00:00
Pieter Wuille 119b0f85e2 Split key_io (address/key encodings) off from base58 2018-02-19 18:55:21 -08:00
João Barbosa 0851a75b5a rpc: Interrupt block generation on shutdown request 2018-02-16 13:00:32 +00: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
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
John Newbery d066a1c069 [rpc] Remove deprecated getmininginfo RPC option 2018-02-05 15:17:35 -05:00
John Newbery c6f09c2713 [rpc] remove deprecated estimatefee RPC 2018-02-05 15:17:31 -05:00
Akira Takizawa 595a7bab23 Increment MIT Licence copyright header year on files modified in 2017 2018-01-03 02:26:56 +09:00
Jan Čapek c198dc00e1 [Doc] Clarify the meaning of fee delta not being a fee rate in prioritisetransaction RPC 2017-12-24 11:00:30 +00:00
practicalswift a720b928c8 Remove includes in .cpp files for things the corresponding .h file already included 2017-11-16 22:26:34 +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
Matt Corallo 7e319d6393 Fix -Wthread-safety-analysis warnings. Change the sync.h primitives to std from boost.
Commit 1.

This code was written by @TheBlueMatt in the following branch:
* https://github.com/TheBlueMatt/bitcoin/commits/2017-08-test-10923

This commit message was written by me (@practicalswift) who also squashed
@TheBlueMatt's commits into one and tried to summarize the changes made.

Commit 2.

Remove boost include. Remove boost mentions in comments.
2017-11-06 17:41:02 +01:00
Andrew Chow 395cef7601 Change getmininginfo errors field to warnings
Changes the errors field to warnings. To maintain compatibility,
the errors field is deprecated and enabled by starting bitcoind with
-deprecatedrpc=getmininginfo
2017-09-27 11:27:26 -04:00
Andrew Chow 8502b20852 Unify help text for GetWarnings output in get*info RPCs 2017-09-27 11:27:26 -04:00
John Newbery d4cdbd6fb6 [rpc] Deprecate estimatefee RPC
Deprecate estimatefee in v0.16, for final removal in v0.17.

This commit introduces a phased removal of RPC methods. RPC method is
disabled by default in version x, but can be enabled by using the
`-deprecatedrpc=<method>` argument. RPC method is removed entirely in
version (x+1).
2017-09-26 12:17:19 -04:00
MarcoFalke c377feaad8
Merge #11267: rpc: update cli for estimate*fee argument rename
5acd82de9 rpc: make estimatesmartfee argument naming consistent with documentation (Wladimir J. van der Laan)
24697c40e rpc: update cli for estimatefee argument rename (Wladimir J. van der Laan)

Pull request description:

  The first argument of `estimaterawfee` was renamed from `nblocks` to `conf_target` in 06bcdb8da6. Update the client-side table as well.
  This makes #10753 pass again.

Tree-SHA512: 107c0072a45e0f4e083dc803d534973e6bd4c005e62337a867815d7c98ab1c21d97b7a495c32763883975cbbb001b80003001a6709b7d9bdd81ce4d441b667be
2017-09-12 19:31:30 +02:00
Matt Corallo ba206d2c63 Deprecate confusing blockmaxsize, fix getmininginfo output
* This removes block-size-limiting code in favor of GBT clients
  doing the limiting themselves (if at all).
* -blockmaxsize is deprecated and only used to calculate an implied
  blockmaxweight, addressing confusion from multiple users.
* getmininginfo's currentblocksize return value was returning
  garbage values, and has been removed, also removing a
  GetSerializeSize call in some block generation inner loops and
  potentially addressing some performance edge cases.
2017-09-11 15:51:25 -04:00
Wladimir J. van der Laan 5acd82de9a rpc: make estimatesmartfee argument naming consistent with documentation
Part of this was a reversion in ec6902d0ea.
2017-09-08 01:55:59 +02: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
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 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
practicalswift 64fb0ac016 Declare single-argument (non-converting) constructors "explicit"
In order to avoid unintended implicit conversions.
2017-08-16 16:33:25 +02:00
Russell Yanofsky e666efcdba Get rid of redundant RPC params.size() checks
No change in behavior.
2017-08-14 19:38:18 -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
Wladimir J. van der Laan 041dad94b0
Merge #10783: [RPC] Various rpc argument fixes
4dc1915 check for null values in rpc args and handle appropriately (Gregory Sanders)
999ef20 importmulti options are optional (Gregory Sanders)
a70d025 fixup some rpc param counting for rpc help (Gregory Sanders)

Pull request description:

  Audited where named args will fail to use correct default values or may fail when additional optional arguments are added.

  Previously for these parameters, it was fine to omit them as positional arguments, but it would trigger UniValue runtime errors to set them to null, or to omit them while passing named parameters with greater positions (which would internally set earlier missing arguments to null). Now null values are treated the same as missing values so these errors do not occur.

  Included a few other small fixes while working on it.

  I didn't bother fixing account-based rpc calls.

Tree-SHA512: 8baf781a35bd48de7878d4726850a580dab80323d3416c1c146b4fa9062f8a233c03f37e8ae3f3159e9d04a8f39c326627ca64c14e1cb7ce72538f934ab2ae1e
2017-07-20 17:02:07 +02:00
practicalswift e0d459264f Avoid redundant redeclaration of GetWarnings(const string&)
std::string GetWarnings(const std::string& strFor) is declared in
warnings.h and defined in warnings.cpp.
2017-07-18 15:54:38 +02:00
Alex Morcos 06bcdb8da6 Convert named argument from nblocks to conf_target
in estimatesmartfee and estimaterawfee.  Also reuse existing bounds checking.
2017-07-17 10:52:14 -04:00