Skip to content

Commit

Permalink
Allow dumpblinding key to accept non-CT address
Browse files Browse the repository at this point in the history
This facilitates the following workflow:
1) Obtain an updated psbt with in_witness_utxo and in_utxo_rangeproof
2) Get the blinding key from the input utxo address obtained from input
script pubkey without revealing master blinding key
3) Rewind the proof to obtain blinding factors and implement stateless
blinding
  • Loading branch information
sanket1729 committed Aug 2, 2022
1 parent cd9d64e commit 1e0ef29
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 3 deletions.
8 changes: 5 additions & 3 deletions src/wallet/rpcdump.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2112,7 +2112,8 @@ RPCHelpMan importissuanceblindingkey()
RPCHelpMan dumpblindingkey()
{
return RPCHelpMan{"dumpblindingkey",
"\nDumps the private blinding key for a CT address in hex.",
"\nDumps the private blinding key for a CT address in hex."
"\nNote: If the address is not a CT address, looks for blinding key corresponding to this non-CT address.",
{
{"address", RPCArg::Type::STR, RPCArg::Optional::NO, "The CT address"},
},
Expand Down Expand Up @@ -2142,9 +2143,10 @@ RPCHelpMan dumpblindingkey()
key = pwallet->GetBlindingKey(&script);
if (key.IsValid()) {
CPubKey pubkey(key.GetPubKey());
if (pubkey == GetDestinationBlindingKey(dest)) {
return HexStr(Span<const unsigned char>(key.begin(), key.size()));
if (IsBlindDestination(dest) && pubkey != GetDestinationBlindingKey(dest)) {
throw JSONRPCError(RPC_INVALID_ADDRESS_OR_KEY, "CT address blinding key does not match the blinding key in wallet");
}
return HexStr(Span<const unsigned char>(key.begin(), key.size()));
}

throw JSONRPCError(RPC_WALLET_ERROR, "Blinding key for address is unknown");
Expand Down
5 changes: 5 additions & 0 deletions test/functional/feature_confidential_transactions.py
Original file line number Diff line number Diff line change
Expand Up @@ -272,6 +272,11 @@ def run_test(self):

# Import the blinding key
blindingkey = self.nodes[2].dumpblindingkey(address2)

# Check that importing keys from non-CT address works as intended
blindingkey2 = self.nodes[2].dumpblindingkey(unconfidential_address2)
assert_equal(blindingkey, blindingkey2)

self.nodes[1].importblindingkey(address2, blindingkey)
# Check the auditor's gettransaction and listreceivedbyaddress
# Needs rescan to update wallet txns
Expand Down

0 comments on commit 1e0ef29

Please sign in to comment.