Skip to content

Commit 57cb0b6

Browse files
committed
rpc: add dust arg to getsilentpaymentblockdata
1 parent 525a36a commit 57cb0b6

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
@@ -704,6 +704,7 @@ static RPCHelpMan getsilentpaymentblockdata()
704704
"\nReturns an array of hex-encoded strings data for the tweaked public key sum of candidate silent transaction inputs in each transaction.\n",
705705
{
706706
{"block_hash", RPCArg::Type::STR_HEX, RPCArg::Optional::NO, "The block hash"},
707+
{"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)},
707708
},
708709
{
709710
RPCResult{
@@ -736,6 +737,14 @@ static RPCHelpMan getsilentpaymentblockdata()
736737
}
737738
}
738739

740+
CAmount dust_threshold{0};
741+
if (!request.params[1].isNull()) {
742+
dust_threshold = AmountFromValue(request.params[1], 0);
743+
if (dust_threshold > BIP352Index::max_dust_threshold) {
744+
throw JSONRPCError(RPC_INVALID_PARAMETER, strprintf("dust argument must be <= %d", BIP352Index::max_dust_threshold));
745+
}
746+
}
747+
739748
BIP352Index::tweak_index_entry tweak_index_entry;
740749
if (!g_bip352_index->FindSilentPayment(block_hash, tweak_index_entry)) {
741750
throw JSONRPCError(RPC_INVALID_PARAMETER, "Block has not been indexed yet");
@@ -745,7 +754,9 @@ static RPCHelpMan getsilentpaymentblockdata()
745754
UniValue tweaks_res(UniValue::VARR);
746755

747756
for (const auto& entry : tweak_index_entry) {
748-
tweaks_res.push_back(HexStr(entry.first));
757+
if ((CAmount(entry.second) << BIP352Index::dust_shift) >= dust_threshold) {
758+
tweaks_res.push_back(HexStr(entry.first));
759+
}
749760
}
750761

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

src/rpc/client.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -320,6 +320,7 @@ static const CRPCConvertParam vRPCConvertParams[] =
320320
{ "stop", 0, "wait" },
321321
{ "addnode", 2, "v2transport" },
322322
{ "addconnection", 2, "v2transport" },
323+
{ "getsilentpaymentblockdata", 1, "dust"},
323324
};
324325
// clang-format on
325326

0 commit comments

Comments
 (0)