Skip to content

Commit 7312bce

Browse files
committed
Added estimatesmartfee function
1 parent 7ff90c4 commit 7312bce

File tree

3 files changed

+18
-1
lines changed

3 files changed

+18
-1
lines changed

src/bitcoinapi/bitcoinapi.cpp

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -406,6 +406,17 @@ double BitcoinAPI::estimatefee(int blocks) {
406406
return result.asDouble();
407407
}
408408

409+
smartfee_t BitcoinAPI::estimatesmartfee(int blocks) {
410+
string command = "estimatesmartfee";
411+
Value params, result;
412+
smartfee_t ret;
413+
params.append(blocks);
414+
result = sendcommand(command, params);
415+
ret.feerate = result["feerate"].asDouble();
416+
ret.blocks = result["blocks"].asInt();
417+
return ret;
418+
}
419+
409420
string BitcoinAPI::signmessage(const std::string& bitcoinaddress, const std::string& message) {
410421
string command = "signmessage";
411422
Value params, result;

src/bitcoinapi/bitcoinapi.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,7 @@ class BitcoinAPI
6565
void keypoolrefill();
6666
bool settxfee(double amount);
6767
double estimatefee(int blocks);
68+
smartfee_t estimatesmartfee(int blocks);
6869

6970
std::string signmessage(const std::string& bitcoinaddress, const std::string& message);
7071
bool verifymessage(const std::string& bitcoinaddress, const std::string& signature, const std::string& message);
@@ -83,7 +84,7 @@ class BitcoinAPI
8384

8485
std::vector<accountinfo_t> listreceivedbyaccount(int minconf = 1, bool includeempty = false);
8586
std::vector<addressinfo_t> listreceivedbyaddress(int minconf = 1, bool includeempty = false);
86-
87+
8788
gettransaction_t gettransaction(const std::string& tx, bool watch);
8889
std::vector<transactioninfo_t> listtransactions();
8990
std::vector<transactioninfo_t> listtransactions(const std::string& account, int count = 10, int from = 0);

src/bitcoinapi/types.h

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -210,6 +210,11 @@
210210

211211

212212
/* === Other === */
213+
214+
struct smartfee_t{
215+
double feerate;
216+
int blocks;
217+
};
213218
struct utxoinfo_t{
214219
std::string bestblock;
215220
int confirmations;

0 commit comments

Comments
 (0)