parent
8617622e0d
commit
baaa3c4ac0
|
@ -19,6 +19,10 @@ class WalletAccountsTest(BitcoinTestFramework):
|
|||
'-orchardwallet',
|
||||
]] * self.num_nodes)
|
||||
|
||||
def check_receiver_types(self, ua, expected):
|
||||
actual = self.nodes[0].z_listunifiedreceivers(ua)
|
||||
assert_equal(set(expected), set(actual))
|
||||
|
||||
def run_test(self):
|
||||
# With a new wallet, the first account will be 0.
|
||||
account0 = self.nodes[0].z_getnewaccount()
|
||||
|
@ -53,6 +57,10 @@ class WalletAccountsTest(BitcoinTestFramework):
|
|||
ua1 = addr1['unifiedaddress']
|
||||
assert(ua0 != ua1)
|
||||
|
||||
# The UA contains the expected receiver kinds.
|
||||
self.check_receiver_types(ua0, ['transparent', 'sapling'])
|
||||
self.check_receiver_types(ua1, ['transparent', 'sapling'])
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
WalletAccountsTest().main()
|
||||
|
|
|
@ -3285,11 +3285,32 @@ UniValue z_listunifiedreceivers(const UniValue& params, bool fHelp)
|
|||
if (!fExperimentalOrchardWallet) {
|
||||
throw JSONRPCError(RPC_WALLET_ENCRYPTION_FAILED, "Error: the Orchard wallet experimental extensions are disabled.");
|
||||
}
|
||||
std::string ua = params[0].get_str();
|
||||
|
||||
KeyIO keyIO(Params());
|
||||
auto decoded = keyIO.DecodePaymentAddress(params[0].get_str());
|
||||
if (!decoded.has_value()) {
|
||||
throw JSONRPCError(RPC_INVALID_ADDRESS_OR_KEY, "Invalid address");
|
||||
}
|
||||
if (!std::holds_alternative<libzcash::UnifiedAddress>(decoded.value())) {
|
||||
throw JSONRPCError(RPC_INVALID_PARAMETER, "Address is not a unified address");
|
||||
}
|
||||
auto ua = std::get<libzcash::UnifiedAddress>(decoded.value());
|
||||
|
||||
UniValue result(UniValue::VOBJ);
|
||||
result.pushKV("transparent", "TODO");
|
||||
result.pushKV("sapling", "TODO");
|
||||
result.pushKV("orchard", "TODO " + ua);
|
||||
for (const auto& receiver : ua) {
|
||||
std::visit(match {
|
||||
[&](const libzcash::SaplingPaymentAddress& addr) {
|
||||
result.pushKV("sapling", keyIO.EncodePaymentAddress(addr));
|
||||
},
|
||||
[&](const CScriptID& addr) {
|
||||
result.pushKV("transparent", keyIO.EncodePaymentAddress(addr));
|
||||
},
|
||||
[&](const CKeyID& addr) {
|
||||
result.pushKV("transparent", keyIO.EncodePaymentAddress(addr));
|
||||
},
|
||||
[](auto rest) {},
|
||||
}, receiver);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue