aboutsummaryrefslogtreecommitdiff
path: root/src/rpc
diff options
context:
space:
mode:
authorJarol Rodriguez <jarolrod@tutanota.com>2021-04-06 23:45:31 -0400
committerJarol Rodriguez <jarolrod@tutanota.com>2021-04-06 23:45:31 -0400
commit3e978d1a5dbd43f85bd03e759984ab1f209d6e34 (patch)
tree71caef4c7d9f408858c8a99719b9e6a42d6bb27c /src/rpc
parent5456b345312857981cb426712f0665800c682e09 (diff)
downloadbitcoin-3e978d1a5dbd43f85bd03e759984ab1f209d6e34.tar.xz
rpc: add time_remaining field to listbanned
Diffstat (limited to 'src/rpc')
-rw-r--r--src/rpc/net.cpp3
1 files changed, 3 insertions, 0 deletions
diff --git a/src/rpc/net.cpp b/src/rpc/net.cpp
index b11138cacc..4826f091a6 100644
--- a/src/rpc/net.cpp
+++ b/src/rpc/net.cpp
@@ -753,6 +753,7 @@ static RPCHelpMan listbanned()
{RPCResult::Type::NUM_TIME, "ban_created", "The " + UNIX_EPOCH_TIME + " the ban was created"},
{RPCResult::Type::NUM_TIME, "banned_until", "The " + UNIX_EPOCH_TIME + " the ban expires"},
{RPCResult::Type::NUM_TIME, "ban_duration", "The ban duration, in seconds"},
+ {RPCResult::Type::NUM_TIME, "time_remaining", "The time remaining until the ban expires, in seconds"},
}},
}},
RPCExamples{
@@ -768,6 +769,7 @@ static RPCHelpMan listbanned()
banmap_t banMap;
node.banman->GetBanned(banMap);
+ const int64_t current_time{GetTime()};
UniValue bannedAddresses(UniValue::VARR);
for (const auto& entry : banMap)
@@ -778,6 +780,7 @@ static RPCHelpMan listbanned()
rec.pushKV("ban_created", banEntry.nCreateTime);
rec.pushKV("banned_until", banEntry.nBanUntil);
rec.pushKV("ban_duration", (banEntry.nBanUntil - banEntry.nCreateTime));
+ rec.pushKV("time_remaining", (banEntry.nBanUntil - current_time));
bannedAddresses.push_back(rec);
}