Skip to content

Fix the importing and exporting of viewing keys on mainnet + testnet#688

Merged
jl777 merged 1 commit intojl777:devfrom
letolabs:viewingkeys
Jun 3, 2018
Merged

Fix the importing and exporting of viewing keys on mainnet + testnet#688
jl777 merged 1 commit intojl777:devfrom
letolabs:viewingkeys

Conversation

@leto
Copy link
Copy Markdown

@leto leto commented Jun 3, 2018

It turns out that ZCVIEWING_KEY was only defined on regtest, and that it not being defined on mainnet/testnet was not detected. Implicitly "the empty prefix" was used, which lead to viewing keys without the normal "ZiVK" prefix which were not of the expected size, which finally fails this size check in base58.cpp :

template<class DATA_TYPE, CChainParams::Base58Type PREFIX, size_t SER_SIZE>
DATA_TYPE CZCEncoding<DATA_TYPE, PREFIX, SER_SIZE>::Get() const
{
    if (vchData.size() != SER_SIZE) {
        throw std::runtime_error(
            PrependName(" is invalid")
        );
    }

This shows a viewing key being successfully exported on one machine and imported on another, both machines running this branch:

(loki)(~/git/komodo dev *$%= )$ ./src/komodo-cli z_exportviewingkey zcGfyhUgaC8oKhqAR95Nhb2NhpMSe5HqKXSG44GqTDK93yK2updyMispv2s6iwmqKsG7L24emgMGAHtmnMsiT9V4ooqoKh7
ZiVKWkm4XcA5AKZyGqN3rn3iipmgwNeBWM138p1f8EJytZMQzkPdRcTKMEf62ymocxab5rLSJdmZAKF4VZxCLaNoaC7edbWiw

hush@stilgar:~/git/komodo$ ./src/komodo-cli z_importviewingkey ZiVKWkm4XcA5AKZyGqN3rn3iipmgwNeBWM138p1f8EJytZMQzkPdRcTKMEf62ymocxab5rLSJdmZAKF4VZxCLaNoaC7edbWiw no

hush@stilgar:~/git/komodo$ ./src/komodo-cli z_validateaddress zcGfyhUgaC8oKhqAR95Nhb2NhpMSe5HqKXSG44GqTDK93yK2updyMispv2s6iwmqKsG7L24emgMGAHtmnMsiT9V4ooqoKh7
{
  "isvalid": true,
  "address": "zcGfyhUgaC8oKhqAR95Nhb2NhpMSe5HqKXSG44GqTDK93yK2updyMispv2s6iwmqKsG7L24emgMGAHtmnMsiT9V4ooqoKh7",
  "payingkey": "...",
  "transmissionkey": "....",
  "ismine": false
}

The ismine: false above means that the address had a viewing key imported.

@leto
Copy link
Copy Markdown
Author

leto commented Jun 3, 2018

This fixes #687

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants