3
3
// file COPYING or http://www.opensource.org/licenses/mit-license.php.
4
4
5
5
#include < chainparamsbase.h>
6
+ #include < key_io.h>
6
7
#include < rpc/server.h>
7
8
#include < rpc/util.h>
8
9
#include < util/strencodings.h>
@@ -57,6 +58,41 @@ static RPCHelpMan enumeratesigners()
57
58
};
58
59
}
59
60
61
+ static RPCHelpMan signerdisplayaddress ()
62
+ {
63
+ return RPCHelpMan{
64
+ " signerdisplayaddress" ,
65
+ " Display address on an external signer for verification.\n " ,
66
+ {
67
+ {" address" , RPCArg::Type::STR, RPCArg::Optional::NO, /* default_val */ " " , " bitcoin address to display" },
68
+ },
69
+ RPCResult{RPCResult::Type::NONE," " ," " },
70
+ RPCExamples{" " },
71
+ [](const RPCHelpMan& self, const JSONRPCRequest& request) -> UniValue {
72
+ std::shared_ptr<CWallet> const wallet = GetWalletForJSONRPCRequest (request);
73
+ if (!wallet) return NullUniValue;
74
+ CWallet* const pwallet = wallet.get ();
75
+
76
+ LOCK (pwallet->cs_wallet );
77
+
78
+ CTxDestination dest = DecodeDestination (request.params [0 ].get_str ());
79
+
80
+ // Make sure the destination is valid
81
+ if (!IsValidDestination (dest)) {
82
+ throw JSONRPCError (RPC_INVALID_ADDRESS_OR_KEY, " Invalid address" );
83
+ }
84
+
85
+ if (!pwallet->DisplayAddress (dest)) {
86
+ throw JSONRPCError (RPC_WALLET_ERROR, " Failed to display address" );
87
+ }
88
+
89
+ UniValue result (UniValue::VOBJ);
90
+ result.pushKV (" address" , request.params [0 ].get_str ());
91
+ return result;
92
+ }
93
+ };
94
+ }
95
+
60
96
Span<const CRPCCommand> GetSignerRPCCommands ()
61
97
{
62
98
@@ -65,6 +101,7 @@ static const CRPCCommand commands[] =
65
101
{ // category actor (function)
66
102
// --------------------- ------------------------
67
103
{ " signer" , &enumeratesigners, },
104
+ { " signer" , &signerdisplayaddress, },
68
105
};
69
106
// clang-format on
70
107
return MakeSpan (commands);
0 commit comments