{"action":"created","comment":{"url":"https://api.github.com/repos/bitcoin/bitcoin/pulls/comments/112303336","pull_request_review_id":33608339,"id":112303336,"diff_hunk":"@@ -853,15 +855,98 @@ UniValue estimatesmartfee(const JSONRPCRequest& request)\n     RPCTypeCheck(request.params, boost::assign::list_of(UniValue::VNUM));\n \n     int nBlocks = request.params[0].get_int();\n+    bool conservative = true;\n+    if (request.params.size() > 1 && !request.params[1].isNull()) {\n+        RPCTypeCheckArgument(request.params[1], UniValue::VBOOL);\n+        conservative = request.params[1].get_bool();\n+    }\n \n     UniValue result(UniValue::VOBJ);\n     int answerFound;\n-    CFeeRate feeRate = mempool.estimateSmartFee(nBlocks, &answerFound);\n+    CFeeRate feeRate = ::feeEstimator.estimateSmartFee(nBlocks, &answerFound, ::mempool, conservative);\n     result.push_back(Pair(\"feerate\", feeRate == CFeeRate(0) ? -1.0 : ValueFromAmount(feeRate.GetFeePerK())));\n     result.push_back(Pair(\"blocks\", answerFound));\n     return result;\n }\n \n+UniValue estimaterawfee(const JSONRPCRequest& request)\n+{\n+    if (request.fHelp || request.params.size() < 1|| request.params.size() > 3)\n+        throw std::runtime_error(\n+            \"estimaterawfee nblocks\\n\"\n+            \"\\nWARNING: This interface is unstable and may disappear or change!\\n\"\n+            \"\\nWARNING: This is an advanced API call that is tightly coupled to the specific\\n\"\n+            \"         implementation of fee estimation. The parameters it can be called with\\n\"\n+            \"         and the results it returns will change if the internal implementaion changes.\\n\"\n+            \"\\nEstimates the approximate fee per kilobyte needed for a transaction to begin\\n\"\n+            \"confirmation within nblocks blocks if possible. Uses virtual transaction size as defined\\n\"\n+            \"in BIP 141 (witness data is discounted).\\n\"\n+            \"\\nArguments:\\n\"\n+            \"1. nblocks     (numeric)\\n\"\n+            \"2. threshold   (numeric, optional) The proportion of transactions in a given feerate range that must have been\\n\"\n+            \"               confirmed within nblocks in order to consider those feerates as high enough and proceed to check\\n\"\n+            \"               lower buckets.  Default: 0.95\\n\"\n+            \"3. horizon     (numeric, optional) How long a history of estimates to consider. 0=short, 1=medium, 2=long.\\n\"\n+            \"               Default: 1\\n\"\n+            \"\\nResult:\\n\"\n+            \"{\\n\"\n+            \"  \\\"feerate\\\" : x.x,        (numeric) estimate fee-per-kilobyte (in BTC)\\n\"\n+            \"  \\\"decay\\\" : x.x,          (numeric) exponential decay for historical moving average of confirmation data\\n\"\n+            \"  \\\"scale\\\" : x,            (numeric) The resolution of confirmation targets at this time horizon\\n\"\n+            \"  \\\"pass.\\\"                 information about the last range of feerates to succeed in meeting the threshold\\n\"\n+            \"  \\\"fail.\\\"                 information about the first range of feerates to fail to meet the threshold\\n\"\n+            \"  \\\"startrange\\\" : x.x,     (numeric) start of feerate range\\n\"\n+            \"  \\\"endrange\\\" : x.x,       (numeric) end of feerate range\\n\"\n+            \"  \\\"withintarget\\\" : x.x,   (numeric) number of txs over history horizon in the feerate range that were confirmed within target\\n\"\n+            \"  \\\"totalconfirmed\\\" : x.x, (numeric) number of txs over history horizon in the feerate range total\\n\"\n+            \"  \\\"inmempool\\\" : x.x,      (numeric) current number of txs in mempool in the feerate range unconfirmed for at least target blocks\\n\"\n+            \"  \\\"leftmempool\\\" : x.x,    (numeric) number of txs over history horizon in the feerate range that left mempool unconfirmed after target\\n\"\n+            \"}\\n\"\n+            \"\\n\"\n+            \"A negative value is returned if no answer can be given.\\n\"\n+            \"\\nExample:\\n\"\n+            + HelpExampleCli(\"estimaterawfee\", \"6 0.9 1\")\n+            );\n+\n+    RPCTypeCheck(request.params, boost::assign::list_of(UniValue::VNUM)(UniValue::VNUM)(UniValue::VNUM), true);\n+    RPCTypeCheckArgument(request.params[0], UniValue::VNUM);\n+    int nBlocks = request.params[0].get_int();\n+    double threshold = 0.95;\n+    if (!request.params[1].isNull())\n+        threshold = request.params[1].get_real();","path":"src/rpc/mining.cpp","position":108,"original_position":108,"commit_id":"7306590db98a0d175083d89d572ac86d3c4ba4cb","original_commit_id":"7306590db98a0d175083d89d572ac86d3c4ba4cb","user":{"login":"jlopp","id":288011,"avatar_url":"https://avatars1.githubusercontent.com/u/288011?v=3","gravatar_id":"","url":"https://api.github.com/users/jlopp","html_url":"https://github.com/jlopp","followers_url":"https://api.github.com/users/jlopp/followers","following_url":"https://api.github.com/users/jlopp/following{/other_user}","gists_url":"https://api.github.com/users/jlopp/gists{/gist_id}","starred_url":"https://api.github.com/users/jlopp/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/jlopp/subscriptions","organizations_url":"https://api.github.com/users/jlopp/orgs","repos_url":"https://api.github.com/users/jlopp/repos","events_url":"https://api.github.com/users/jlopp/events{/privacy}","received_events_url":"https://api.github.com/users/jlopp/received_events","type":"User","site_admin":false},"body":"Would prefer more explicit range bounding on the threshold with an \"Invalid threshold\" error response; it currently allows numbers < 0 and > 1 and just returns a -1 feerate.","created_at":"2017-04-19T20:18:07Z","updated_at":"2017-04-19T20:18:07Z","html_url":"https://github.com/bitcoin/bitcoin/pull/10199#discussion_r112303336","pull_request_url":"https://api.github.com/repos/bitcoin/bitcoin/pulls/10199","_links":{"self":{"href":"https://api.github.com/repos/bitcoin/bitcoin/pulls/comments/112303336"},"html":{"href":"https://github.com/bitcoin/bitcoin/pull/10199#discussion_r112303336"},"pull_request":{"href":"https://api.github.com/repos/bitcoin/bitcoin/pulls/10199"}}},"pull_request":{"url":"https://api.github.com/repos/bitcoin/bitcoin/pulls/10199","id":115592945,"html_url":"https://github.com/bitcoin/bitcoin/pull/10199","diff_url":"https://github.com/bitcoin/bitcoin/pull/10199.diff","patch_url":"https://github.com/bitcoin/bitcoin/pull/10199.patch","issue_url":"https://api.github.com/repos/bitcoin/bitcoin/issues/10199","number":10199,"state":"open","locked":false,"title":"Better fee estimates","user":{"login":"morcos","id":4360349,"avatar_url":"https://avatars1.githubusercontent.com/u/4360349?v=3","gravatar_id":"","url":"https://api.github.com/users/morcos","html_url":"https://github.com/morcos","followers_url":"https://api.github.com/users/morcos/followers","following_url":"https://api.github.com/users/morcos/following{/other_user}","gists_url":"https://api.github.com/users/morcos/gists{/gist_id}","starred_url":"https://api.github.com/users/morcos/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/morcos/subscriptions","organizations_url":"https://api.github.com/users/morcos/orgs","repos_url":"https://api.github.com/users/morcos/repos","events_url":"https://api.github.com/users/morcos/events{/privacy}","received_events_url":"https://api.github.com/users/morcos/received_events","type":"User","site_admin":false},"body":"This is a substantial improvement of fee estimation code built off #9942.\r\nAlthough in many cases the estimates will not appear to differ by much from previous estimates, they will handle some situations much better.\r\n\r\nA summary of major changes:\r\n- Estimates can now be given for up to a 1008 block target.\r\n- Estimates are tracked on 3 different time horizons which allows for both the longer targets and lets the estimates adjust more quickly to changes in conditions.\r\n- estimatefee is deprecated in favor of using only estimatesmartfee (already used by the GUI)\r\n- estimateSmartFee now requires a 60% success rate at target/2, an 85% rate at target and a 95% rate at 2*target.\r\n- estimates are by default conservative which requires the 95% rate for 2*target to be met at longer time horizons as well, but by choosing non-conservative estimates, the estimates are drastically reduced during periods of less transaction activity (such as the weekend).\r\n- estimates are smarter about making sure enough data has been gathered in order to return a valid estimate (at least twice the number of blocks as the requested target much have been recorded)\r\n- Fee rate buckets are half as big leading to a bit more precision.\r\n- estimaterawfee is added so that customized logic can be implemented to analyze the raw data and calculate estimates.\r\n- Transactions which leave the mempool due to eviction or other non-confirmed reasons now count as failures.  These are also saved at shutdown.\r\n\r\nA summary of open issues:\r\n- Estimates are not backwards compatible.  Currently when updating to this patch, any old fee estimates will be discarded and your node will have to be running for a while to provide new estimates.  It is a possibility to add logic to return the old estimates for targets 2-25 until the new estimates have gathered enough data.\r\n- estimatefee is probably a roughly similar calculation to what it used to be, but I've made no effort to make sure the quality of the estimates it gives have not degraded, so infrastructure which doesn't support estimatesmartfee should update.\r\n- The GUI needs to be updated to access the new range of estimates.  I would suggest providing options for targets of: 2,4,6,12,24,48,144,504,1008\r\n\r\n","created_at":"2017-04-12T17:18:26Z","updated_at":"2017-04-19T20:18:07Z","closed_at":null,"merged_at":null,"merge_commit_sha":"314f375615757a1e94e9f9314b19c81b612b3645","assignee":null,"assignees":[],"milestone":null,"commits_url":"https://api.github.com/repos/bitcoin/bitcoin/pulls/10199/commits","review_comments_url":"https://api.github.com/repos/bitcoin/bitcoin/pulls/10199/comments","review_comment_url":"https://api.github.com/repos/bitcoin/bitcoin/pulls/comments{/number}","comments_url":"https://api.github.com/repos/bitcoin/bitcoin/issues/10199/comments","statuses_url":"https://api.github.com/repos/bitcoin/bitcoin/statuses/7306590db98a0d175083d89d572ac86d3c4ba4cb","head":{"label":"morcos:smarterfee","ref":"smarterfee","sha":"7306590db98a0d175083d89d572ac86d3c4ba4cb","user":{"login":"morcos","id":4360349,"avatar_url":"https://avatars1.githubusercontent.com/u/4360349?v=3","gravatar_id":"","url":"https://api.github.com/users/morcos","html_url":"https://github.com/morcos","followers_url":"https://api.github.com/users/morcos/followers","following_url":"https://api.github.com/users/morcos/following{/other_user}","gists_url":"https://api.github.com/users/morcos/gists{/gist_id}","starred_url":"https://api.github.com/users/morcos/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/morcos/subscriptions","organizations_url":"https://api.github.com/users/morcos/orgs","repos_url":"https://api.github.com/users/morcos/repos","events_url":"https://api.github.com/users/morcos/events{/privacy}","received_events_url":"https://api.github.com/users/morcos/received_events","type":"User","site_admin":false},"repo":{"id":21699686,"name":"bitcoin","full_name":"morcos/bitcoin","owner":{"login":"morcos","id":4360349,"avatar_url":"https://avatars1.githubusercontent.com/u/4360349?v=3","gravatar_id":"","url":"https://api.github.com/users/morcos","html_url":"https://github.com/morcos","followers_url":"https://api.github.com/users/morcos/followers","following_url":"https://api.github.com/users/morcos/following{/other_user}","gists_url":"https://api.github.com/users/morcos/gists{/gist_id}","starred_url":"https://api.github.com/users/morcos/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/morcos/subscriptions","organizations_url":"https://api.github.com/users/morcos/orgs","repos_url":"https://api.github.com/users/morcos/repos","events_url":"https://api.github.com/users/morcos/events{/privacy}","received_events_url":"https://api.github.com/users/morcos/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/morcos/bitcoin","description":"Bitcoin Core integration/staging tree","fork":true,"url":"https://api.github.com/repos/morcos/bitcoin","forks_url":"https://api.github.com/repos/morcos/bitcoin/forks","keys_url":"https://api.github.com/repos/morcos/bitcoin/keys{/key_id}","collaborators_url":"https://api.github.com/repos/morcos/bitcoin/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/morcos/bitcoin/teams","hooks_url":"https://api.github.com/repos/morcos/bitcoin/hooks","issue_events_url":"https://api.github.com/repos/morcos/bitcoin/issues/events{/number}","events_url":"https://api.github.com/repos/morcos/bitcoin/events","assignees_url":"https://api.github.com/repos/morcos/bitcoin/assignees{/user}","branches_url":"https://api.github.com/repos/morcos/bitcoin/branches{/branch}","tags_url":"https://api.github.com/repos/morcos/bitcoin/tags","blobs_url":"https://api.github.com/repos/morcos/bitcoin/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/morcos/bitcoin/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/morcos/bitcoin/git/refs{/sha}","trees_url":"https://api.github.com/repos/morcos/bitcoin/git/trees{/sha}","statuses_url":"https://api.github.com/repos/morcos/bitcoin/statuses/{sha}","languages_url":"https://api.github.com/repos/morcos/bitcoin/languages","stargazers_url":"https://api.github.com/repos/morcos/bitcoin/stargazers","contributors_url":"https://api.github.com/repos/morcos/bitcoin/contributors","subscribers_url":"https://api.github.com/repos/morcos/bitcoin/subscribers","subscription_url":"https://api.github.com/repos/morcos/bitcoin/subscription","commits_url":"https://api.github.com/repos/morcos/bitcoin/commits{/sha}","git_commits_url":"https://api.github.com/repos/morcos/bitcoin/git/commits{/sha}","comments_url":"https://api.github.com/repos/morcos/bitcoin/comments{/number}","issue_comment_url":"https://api.github.com/repos/morcos/bitcoin/issues/comments{/number}","contents_url":"https://api.github.com/repos/morcos/bitcoin/contents/{+path}","compare_url":"https://api.github.com/repos/morcos/bitcoin/compare/{base}...{head}","merges_url":"https://api.github.com/repos/morcos/bitcoin/merges","archive_url":"https://api.github.com/repos/morcos/bitcoin/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/morcos/bitcoin/downloads","issues_url":"https://api.github.com/repos/morcos/bitcoin/issues{/number}","pulls_url":"https://api.github.com/repos/morcos/bitcoin/pulls{/number}","milestones_url":"https://api.github.com/repos/morcos/bitcoin/milestones{/number}","notifications_url":"https://api.github.com/repos/morcos/bitcoin/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/morcos/bitcoin/labels{/name}","releases_url":"https://api.github.com/repos/morcos/bitcoin/releases{/id}","deployments_url":"https://api.github.com/repos/morcos/bitcoin/deployments","created_at":"2014-07-10T15:39:10Z","updated_at":"2016-01-17T15:49:59Z","pushed_at":"2017-04-12T16:32:46Z","git_url":"git://github.com/morcos/bitcoin.git","ssh_url":"git@github.com:morcos/bitcoin.git","clone_url":"https://github.com/morcos/bitcoin.git","svn_url":"https://github.com/morcos/bitcoin","homepage":"https://bitcoin.org/en/download","size":77151,"stargazers_count":1,"watchers_count":1,"language":"C++","has_issues":false,"has_projects":true,"has_downloads":false,"has_wiki":false,"has_pages":false,"forks_count":1,"mirror_url":null,"open_issues_count":3,"forks":1,"open_issues":3,"watchers":1,"default_branch":"master"}},"base":{"label":"bitcoin:master","ref":"master","sha":"b44adf92342ad4f9c343ba29c081a91687932936","user":{"login":"bitcoin","id":528860,"avatar_url":"https://avatars1.githubusercontent.com/u/528860?v=3","gravatar_id":"","url":"https://api.github.com/users/bitcoin","html_url":"https://github.com/bitcoin","followers_url":"https://api.github.com/users/bitcoin/followers","following_url":"https://api.github.com/users/bitcoin/following{/other_user}","gists_url":"https://api.github.com/users/bitcoin/gists{/gist_id}","starred_url":"https://api.github.com/users/bitcoin/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/bitcoin/subscriptions","organizations_url":"https://api.github.com/users/bitcoin/orgs","repos_url":"https://api.github.com/users/bitcoin/repos","events_url":"https://api.github.com/users/bitcoin/events{/privacy}","received_events_url":"https://api.github.com/users/bitcoin/received_events","type":"Organization","site_admin":false},"repo":{"id":1181927,"name":"bitcoin","full_name":"bitcoin/bitcoin","owner":{"login":"bitcoin","id":528860,"avatar_url":"https://avatars1.githubusercontent.com/u/528860?v=3","gravatar_id":"","url":"https://api.github.com/users/bitcoin","html_url":"https://github.com/bitcoin","followers_url":"https://api.github.com/users/bitcoin/followers","following_url":"https://api.github.com/users/bitcoin/following{/other_user}","gists_url":"https://api.github.com/users/bitcoin/gists{/gist_id}","starred_url":"https://api.github.com/users/bitcoin/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/bitcoin/subscriptions","organizations_url":"https://api.github.com/users/bitcoin/orgs","repos_url":"https://api.github.com/users/bitcoin/repos","events_url":"https://api.github.com/users/bitcoin/events{/privacy}","received_events_url":"https://api.github.com/users/bitcoin/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/bitcoin/bitcoin","description":"Bitcoin Core integration/staging tree","fork":false,"url":"https://api.github.com/repos/bitcoin/bitcoin","forks_url":"https://api.github.com/repos/bitcoin/bitcoin/forks","keys_url":"https://api.github.com/repos/bitcoin/bitcoin/keys{/key_id}","collaborators_url":"https://api.github.com/repos/bitcoin/bitcoin/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/bitcoin/bitcoin/teams","hooks_url":"https://api.github.com/repos/bitcoin/bitcoin/hooks","issue_events_url":"https://api.github.com/repos/bitcoin/bitcoin/issues/events{/number}","events_url":"https://api.github.com/repos/bitcoin/bitcoin/events","assignees_url":"https://api.github.com/repos/bitcoin/bitcoin/assignees{/user}","branches_url":"https://api.github.com/repos/bitcoin/bitcoin/branches{/branch}","tags_url":"https://api.github.com/repos/bitcoin/bitcoin/tags","blobs_url":"https://api.github.com/repos/bitcoin/bitcoin/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/bitcoin/bitcoin/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/bitcoin/bitcoin/git/refs{/sha}","trees_url":"https://api.github.com/repos/bitcoin/bitcoin/git/trees{/sha}","statuses_url":"https://api.github.com/repos/bitcoin/bitcoin/statuses/{sha}","languages_url":"https://api.github.com/repos/bitcoin/bitcoin/languages","stargazers_url":"https://api.github.com/repos/bitcoin/bitcoin/stargazers","contributors_url":"https://api.github.com/repos/bitcoin/bitcoin/contributors","subscribers_url":"https://api.github.com/repos/bitcoin/bitcoin/subscribers","subscription_url":"https://api.github.com/repos/bitcoin/bitcoin/subscription","commits_url":"https://api.github.com/repos/bitcoin/bitcoin/commits{/sha}","git_commits_url":"https://api.github.com/repos/bitcoin/bitcoin/git/commits{/sha}","comments_url":"https://api.github.com/repos/bitcoin/bitcoin/comments{/number}","issue_comment_url":"https://api.github.com/repos/bitcoin/bitcoin/issues/comments{/number}","contents_url":"https://api.github.com/repos/bitcoin/bitcoin/contents/{+path}","compare_url":"https://api.github.com/repos/bitcoin/bitcoin/compare/{base}...{head}","merges_url":"https://api.github.com/repos/bitcoin/bitcoin/merges","archive_url":"https://api.github.com/repos/bitcoin/bitcoin/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/bitcoin/bitcoin/downloads","issues_url":"https://api.github.com/repos/bitcoin/bitcoin/issues{/number}","pulls_url":"https://api.github.com/repos/bitcoin/bitcoin/pulls{/number}","milestones_url":"https://api.github.com/repos/bitcoin/bitcoin/milestones{/number}","notifications_url":"https://api.github.com/repos/bitcoin/bitcoin/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/bitcoin/bitcoin/labels{/name}","releases_url":"https://api.github.com/repos/bitcoin/bitcoin/releases{/id}","deployments_url":"https://api.github.com/repos/bitcoin/bitcoin/deployments","created_at":"2010-12-19T15:16:43Z","updated_at":"2017-04-19T19:27:50Z","pushed_at":"2017-04-19T19:47:46Z","git_url":"git://github.com/bitcoin/bitcoin.git","ssh_url":"git@github.com:bitcoin/bitcoin.git","clone_url":"https://github.com/bitcoin/bitcoin.git","svn_url":"https://github.com/bitcoin/bitcoin","homepage":"https://bitcoin.org/en/download","size":81146,"stargazers_count":12162,"watchers_count":12162,"language":"C++","has_issues":true,"has_projects":true,"has_downloads":false,"has_wiki":false,"has_pages":false,"forks_count":7897,"mirror_url":null,"open_issues_count":658,"forks":7897,"open_issues":658,"watchers":12162,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/bitcoin/bitcoin/pulls/10199"},"html":{"href":"https://github.com/bitcoin/bitcoin/pull/10199"},"issue":{"href":"https://api.github.com/repos/bitcoin/bitcoin/issues/10199"},"comments":{"href":"https://api.github.com/repos/bitcoin/bitcoin/issues/10199/comments"},"review_comments":{"href":"https://api.github.com/repos/bitcoin/bitcoin/pulls/10199/comments"},"review_comment":{"href":"https://api.github.com/repos/bitcoin/bitcoin/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/bitcoin/bitcoin/pulls/10199/commits"},"statuses":{"href":"https://api.github.com/repos/bitcoin/bitcoin/statuses/7306590db98a0d175083d89d572ac86d3c4ba4cb"}}}}
{"actor":{"display_login":"jlopp"}}