From 2f941c718fd3bfe36e0daea1c33445c7523fb151 Mon Sep 17 00:00:00 2001 From: Daniel Larimer Date: Tue, 16 Feb 2016 12:07:24 -0500 Subject: [PATCH] Fix #586 - decoding memo for sender in CLI wallet --- libraries/wallet/wallet.cpp | 18 ++++++++++++------ 1 file changed, 12 insertions(+), 6 deletions(-) diff --git a/libraries/wallet/wallet.cpp b/libraries/wallet/wallet.cpp index 0c37d39f58..3dd8b9e3e6 100644 --- a/libraries/wallet/wallet.cpp +++ b/libraries/wallet/wallet.cpp @@ -2521,12 +2521,18 @@ string operation_printer::operator()(const transfer_operation& op) const out << " -- Unlock wallet to see memo."; } else { try { - FC_ASSERT(wallet._keys.count(op.memo->to), "Memo is encrypted to a key ${k} not in this wallet.", - ("k", 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; + 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()));