aboutsummaryrefslogtreecommitdiff
path: root/src/wallet/rpcsigner.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/wallet/rpcsigner.cpp')
-rw-r--r--src/wallet/rpcsigner.cpp37
1 files changed, 37 insertions, 0 deletions
diff --git a/src/wallet/rpcsigner.cpp b/src/wallet/rpcsigner.cpp
index 76f4f3c6aa..607b778c68 100644
--- a/src/wallet/rpcsigner.cpp
+++ b/src/wallet/rpcsigner.cpp
@@ -3,6 +3,7 @@
// file COPYING or http://www.opensource.org/licenses/mit-license.php.
#include <chainparamsbase.h>
+#include <key_io.h>
#include <rpc/server.h>
#include <rpc/util.h>
#include <util/strencodings.h>
@@ -57,6 +58,41 @@ static RPCHelpMan enumeratesigners()
};
}
+static RPCHelpMan signerdisplayaddress()
+{
+ return RPCHelpMan{
+ "signerdisplayaddress",
+ "Display address on an external signer for verification.\n",
+ {
+ {"address", RPCArg::Type::STR, RPCArg::Optional::NO, /* default_val */ "", "bitcoin address to display"},
+ },
+ RPCResult{RPCResult::Type::NONE,"",""},
+ RPCExamples{""},
+ [](const RPCHelpMan& self, const JSONRPCRequest& request) -> UniValue {
+ std::shared_ptr<CWallet> const wallet = GetWalletForJSONRPCRequest(request);
+ if (!wallet) return NullUniValue;
+ CWallet* const pwallet = wallet.get();
+
+ LOCK(pwallet->cs_wallet);
+
+ CTxDestination dest = DecodeDestination(request.params[0].get_str());
+
+ // Make sure the destination is valid
+ if (!IsValidDestination(dest)) {
+ throw JSONRPCError(RPC_INVALID_ADDRESS_OR_KEY, "Invalid address");
+ }
+
+ if (!pwallet->DisplayAddress(dest)) {
+ throw JSONRPCError(RPC_WALLET_ERROR, "Failed to display address");
+ }
+
+ UniValue result(UniValue::VOBJ);
+ result.pushKV("address", request.params[0].get_str());
+ return result;
+ }
+ };
+}
+
Span<const CRPCCommand> GetSignerRPCCommands()
{
@@ -65,6 +101,7 @@ static const CRPCCommand commands[] =
{ // category actor (function)
// --------------------- ------------------------
{ "signer", &enumeratesigners, },
+ { "signer", &signerdisplayaddress, },
};
// clang-format on
return MakeSpan(commands);