Merge branch 'bug/cli-wallet-memo-display' into 'develop'
Fix cli wallet memo displaying See merge request PBSA/peerplays!52
This commit is contained in:
commit
b5a9a0101a
1 changed files with 25 additions and 19 deletions
|
|
@ -4184,27 +4184,33 @@ string operation_printer::operator()(const transfer_operation& op) const
|
|||
std::string memo;
|
||||
if( op.memo )
|
||||
{
|
||||
if( wallet.is_locked() )
|
||||
{
|
||||
out << " -- Unlock wallet to see memo.";
|
||||
} else {
|
||||
try {
|
||||
FC_ASSERT(wallet._keys.count(op.memo->to) || wallet._keys.count(op.memo->from), "Memo is encrypted to a key ${to} or ${from} not in this wallet.", ("to", op.memo->to)("from",op.memo->from));
|
||||
if( wallet._keys.count(op.memo->to) ) {
|
||||
auto my_key = wif_to_key(wallet._keys.at(op.memo->to));
|
||||
FC_ASSERT(my_key, "Unable to recover private key to decrypt memo. Wallet may be corrupted.");
|
||||
memo = op.memo->get_message(*my_key, op.memo->from);
|
||||
out << " -- Memo: " << memo;
|
||||
} else {
|
||||
auto my_key = wif_to_key(wallet._keys.at(op.memo->from));
|
||||
FC_ASSERT(my_key, "Unable to recover private key to decrypt memo. Wallet may be corrupted.");
|
||||
memo = op.memo->get_message(*my_key, op.memo->to);
|
||||
out << " -- Memo: " << memo;
|
||||
bool is_encrypted = ((op.memo->from != public_key_type()) && (op.memo->to != public_key_type()));
|
||||
if (is_encrypted) {
|
||||
if( wallet.is_locked() )
|
||||
{
|
||||
out << " -- Unlock wallet to see memo.";
|
||||
} else {
|
||||
try {
|
||||
FC_ASSERT(wallet._keys.count(op.memo->to) || wallet._keys.count(op.memo->from), "Memo is encrypted to a key ${to} or ${from} not in this wallet.", ("to", op.memo->to)("from",op.memo->from));
|
||||
if( wallet._keys.count(op.memo->to) ) {
|
||||
auto my_key = wif_to_key(wallet._keys.at(op.memo->to));
|
||||
FC_ASSERT(my_key, "Unable to recover private key to decrypt memo. Wallet may be corrupted.");
|
||||
memo = op.memo->get_message(*my_key, op.memo->from);
|
||||
out << " -- Memo: " << memo;
|
||||
} else {
|
||||
auto my_key = wif_to_key(wallet._keys.at(op.memo->from));
|
||||
FC_ASSERT(my_key, "Unable to recover private key to decrypt memo. Wallet may be corrupted.");
|
||||
memo = op.memo->get_message(*my_key, op.memo->to);
|
||||
out << " -- Memo: " << memo;
|
||||
}
|
||||
} catch (const fc::exception& e) {
|
||||
out << " -- could not decrypt memo";
|
||||
elog("Error when decrypting memo: ${e}", ("e", e.to_detail_string()));
|
||||
}
|
||||
} catch (const fc::exception& e) {
|
||||
out << " -- could not decrypt memo";
|
||||
elog("Error when decrypting memo: ${e}", ("e", e.to_detail_string()));
|
||||
}
|
||||
} else {
|
||||
memo = op.memo->get_message(private_key_type(), public_key_type());
|
||||
out << " -- Memo: " << memo;
|
||||
}
|
||||
}
|
||||
fee(op.fee);
|
||||
|
|
|
|||
Loading…
Reference in a new issue