Skip to content

Commit ffeb806

Browse files
committed
rpc: add dust arg to getsilentpaymentblockdata
1 parent 9d2a114 commit ffeb806

File tree

2 files changed

+13
-1
lines changed

2 files changed

+13
-1
lines changed

src/rpc/blockchain.cpp

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -730,6 +730,7 @@ static RPCHelpMan getsilentpaymentblockdata()
730730
"Returns an array of hex-encoded strings data for the tweaked public key sum of candidate silent transaction inputs in each transaction.\n",
731731
{
732732
{"block_hash", RPCArg::Type::STR_HEX, RPCArg::Optional::NO, "The block hash"},
733+
{"dust", RPCArg::Type::AMOUNT, RPCArg::Default{CAmount(0)}, strprintf("Dust threshold in satoshi (max %d): all outputs must be greater or equal. This filter has limited precision.", BIP352Index::max_dust_threshold)},
733734
},
734735
{
735736
RPCResult{
@@ -762,6 +763,14 @@ static RPCHelpMan getsilentpaymentblockdata()
762763
}
763764
}
764765

766+
CAmount dust_threshold{0};
767+
if (!request.params[1].isNull()) {
768+
dust_threshold = AmountFromValue(request.params[1], 0);
769+
if (dust_threshold > BIP352Index::max_dust_threshold) {
770+
throw JSONRPCError(RPC_INVALID_PARAMETER, strprintf("dust argument must be <= %d", BIP352Index::max_dust_threshold));
771+
}
772+
}
773+
765774
BIP352Index::tweak_index_entry tweak_index_entry;
766775
if (!g_bip352_index->FindSilentPayment(block_hash, tweak_index_entry)) {
767776
throw JSONRPCError(RPC_INVALID_PARAMETER, "Block has not been indexed yet");
@@ -771,7 +780,9 @@ static RPCHelpMan getsilentpaymentblockdata()
771780
UniValue tweaks_res(UniValue::VARR);
772781

773782
for (const auto& entry : tweak_index_entry) {
774-
tweaks_res.push_back(HexStr(entry.first));
783+
if ((CAmount(entry.second) << BIP352Index::dust_shift) >= dust_threshold) {
784+
tweaks_res.push_back(HexStr(entry.first));
785+
}
775786
}
776787

777788
ret.pushKV("bip352_tweaks", tweaks_res);

src/rpc/client.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -310,6 +310,7 @@ static const CRPCConvertParam vRPCConvertParams[] =
310310
{ "stop", 0, "wait" },
311311
{ "addnode", 2, "v2transport" },
312312
{ "addconnection", 2, "v2transport" },
313+
{ "getsilentpaymentblockdata", 1, "dust"},
313314
};
314315
// clang-format on
315316

0 commit comments

Comments
 (0)