| 673 | } |
| 674 | |
| 675 | UniValue estimatefee(const UniValue& params, bool fHelp) |
| 676 | { |
| 677 | if (fHelp || params.size() != 1) |
| 678 | throw runtime_error( |
| 679 | "estimatefee nblocks\n" |
| 680 | "\nEstimates the approximate fee per kilobyte\n" |
| 681 | "needed for a transaction to begin confirmation\n" |
| 682 | "within nblocks blocks.\n" |
| 683 | "\nArguments:\n" |
| 684 | "1. nblocks (numeric)\n" |
| 685 | "\nResult:\n" |
| 686 | "n : (numeric) estimated fee-per-kilobyte\n" |
| 687 | "\n" |
| 688 | "-1.0 is returned if not enough transactions and\n" |
| 689 | "blocks have been observed to make an estimate.\n" |
| 690 | "\nExample:\n" |
| 691 | + HelpExampleCli("estimatefee", "6") |
| 692 | ); |
| 693 | |
| 694 | RPCTypeCheck(params, boost::assign::list_of(UniValue::VNUM)); |
| 695 | |
| 696 | int nBlocks = params[0].get_int(); |
| 697 | if (nBlocks < 1) |
| 698 | nBlocks = 1; |
| 699 | |
| 700 | CFeeRate feeRate = mempool.estimateFee(nBlocks); |
| 701 | if (feeRate == CFeeRate(0)) |
| 702 | return -1.0; |
| 703 | |
| 704 | return ValueFromAmount(feeRate.GetFeePerK()); |
| 705 | } |
| 706 | |
| 707 | UniValue estimatepriority(const UniValue& params, bool fHelp) |
| 708 | { |
nothing calls this directly
no test coverage detected