Allow frotned to login subaddresses

https://github.com/moneroexamples/openmonero/issues/129
sync_microcore
moneroexamples 5 years ago
parent 0211533d42
commit fc5b6f13e9

@ -462,9 +462,12 @@ var cnUtil = (function(initConfig) {
this.decode_address = function(address) {
var dec = cnBase58.decode(address);
var expectedPrefix = this.encode_varint(CRYPTONOTE_PUBLIC_ADDRESS_BASE58_PREFIX);
var expectedPrefixInt = this.encode_varint(CRYPTONOTE_PUBLIC_INTEGRATED_ADDRESS_BASE58_PREFIX);
var expectedPrefixSub = this.encode_varint(CRYPTONOTE_PUBLIC_SUBADDRESS_BASE58_PREFIX);
var prefix = dec.slice(0, expectedPrefix.length);
if (prefix !== expectedPrefix && prefix !== expectedPrefixInt && prefix !== expectedPrefixSub) {
throw "Invalid address prefix";

@ -76,18 +76,25 @@ thinwalletServices
} catch (e) {
return deferred.reject("invalid address");
}
var expected_view_pub = cnUtil.sec_key_to_pub(view_key);
var expected_spend_pub;
if (spend_key.length === 64) {
expected_spend_pub = cnUtil.sec_key_to_pub(spend_key);
}
if (public_keys.view !== expected_view_pub) {
accountService.logout();
return deferred.reject("invalid view key");
}
if (!view_only && (public_keys.spend !== expected_spend_pub)) {
accountService.logout();
return deferred.reject("invalid spend key");
if (!cnUtil.is_subaddress(address))
{
var expected_view_pub = cnUtil.sec_key_to_pub(view_key);
var expected_spend_pub;
if (spend_key.length === 64) {
expected_spend_pub = cnUtil.sec_key_to_pub(spend_key);
}
if (public_keys.view !== expected_view_pub) {
accountService.logout();
return deferred.reject("invalid view key");
}
if (!view_only && (public_keys.spend !== expected_spend_pub)) {
accountService.logout();
return deferred.reject("invalid spend key");
}
}
public_address = address;
private_keys = {

Loading…
Cancel
Save