Skip to content

Commit 4fedc4f

Browse files
committed
Merge 1efefc3 into merged_master (Elements PR ElementsProject#1131)
2 parents 98e863f + 1efefc3 commit 4fedc4f

2 files changed

Lines changed: 10 additions & 6 deletions

File tree

src/wallet/rpcdump.cpp

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2112,7 +2112,8 @@ RPCHelpMan importissuanceblindingkey()
21122112
RPCHelpMan dumpblindingkey()
21132113
{
21142114
return RPCHelpMan{"dumpblindingkey",
2115-
"\nDumps the private blinding key for a CT address in hex.",
2115+
"\nDumps the private blinding key for a CT address in hex."
2116+
"\nNote: If the address is not a CT address, looks for blinding key corresponding to this non-CT address.",
21162117
{
21172118
{"address", RPCArg::Type::STR, RPCArg::Optional::NO, "The CT address"},
21182119
},
@@ -2134,17 +2135,15 @@ RPCHelpMan dumpblindingkey()
21342135
if (!IsValidDestination(dest)) {
21352136
throw JSONRPCError(RPC_INVALID_ADDRESS_OR_KEY, "Invalid Bitcoin address");
21362137
}
2137-
if (!IsBlindDestination(dest)) {
2138-
throw JSONRPCError(RPC_INVALID_ADDRESS_OR_KEY, "Not a CT address");
2139-
}
21402138
CScript script = GetScriptForDestination(dest);
21412139
CKey key;
21422140
key = pwallet->GetBlindingKey(&script);
21432141
if (key.IsValid()) {
21442142
CPubKey pubkey(key.GetPubKey());
2145-
if (pubkey == GetDestinationBlindingKey(dest)) {
2146-
return HexStr(Span<const unsigned char>(key.begin(), key.size()));
2143+
if (IsBlindDestination(dest) && pubkey != GetDestinationBlindingKey(dest)) {
2144+
throw JSONRPCError(RPC_INVALID_ADDRESS_OR_KEY, "CT address blinding key does not match the blinding key in wallet");
21472145
}
2146+
return HexStr(Span<const unsigned char>(key.begin(), key.size()));
21482147
}
21492148

21502149
throw JSONRPCError(RPC_WALLET_ERROR, "Blinding key for address is unknown");

test/functional/feature_confidential_transactions.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -272,6 +272,11 @@ def run_test(self):
272272

273273
# Import the blinding key
274274
blindingkey = self.nodes[2].dumpblindingkey(address2)
275+
276+
# Check that importing keys from non-CT address works as intended
277+
blindingkey2 = self.nodes[2].dumpblindingkey(unconfidential_address2)
278+
assert_equal(blindingkey, blindingkey2)
279+
275280
self.nodes[1].importblindingkey(address2, blindingkey)
276281
# Check the auditor's gettransaction and listreceivedbyaddress
277282
# Needs rescan to update wallet txns

0 commit comments

Comments
 (0)