From dd246296b9a30b65909322031f214becba8b3a1a Mon Sep 17 00:00:00 2001 From: auruya Date: Fri, 3 Oct 2025 17:05:49 +0300 Subject: [PATCH] Fix show qr code (#65) * enable dual address type support in show_qr_code command * delete comments --- src/simplewallet/simplewallet.cpp | 25 +++++++++++++++++++++++-- 1 file changed, 23 insertions(+), 2 deletions(-) diff --git a/src/simplewallet/simplewallet.cpp b/src/simplewallet/simplewallet.cpp index a23898a8b..6ce3694bc 100644 --- a/src/simplewallet/simplewallet.cpp +++ b/src/simplewallet/simplewallet.cpp @@ -316,7 +316,7 @@ namespace const char* USAGE_RPC_PAYMENT_INFO("rpc_payment_info"); const char* USAGE_START_MINING_FOR_RPC("start_mining_for_rpc []"); const char* USAGE_STOP_MINING_FOR_RPC("stop_mining_for_rpc"); - const char* USAGE_SHOW_QR_CODE("show_qr_code []"); + const char* USAGE_SHOW_QR_CODE("show_qr_code [] []"); const char* USAGE_VERSION("version"); const char* USAGE_HELP("help [ | all]"); const char* USAGE_APROPOS("apropos [ ...]"); @@ -2559,6 +2559,7 @@ bool simple_wallet::stop_mining_for_rpc(const std::vector &args) bool simple_wallet::show_qr_code(const std::vector &args) { uint32_t subaddress_index = 0; + carrot::AddressDeriveType derive_type; if (args.size() >= 1) { if (!string_tools::get_xtype_from_string(subaddress_index, args[0])) @@ -2572,6 +2573,25 @@ bool simple_wallet::show_qr_code(const std::vector &args) return true; } } + if (args.size() >= 2) + { + // Convert string to AddressDeriveType enum + if (args[1] == "carrot" || args[1] == "Carrot") + { + derive_type = carrot::AddressDeriveType::Carrot; + } + else if (args[1] == "precarrot" || args[1] == "PreCarrot") + { + derive_type = carrot::AddressDeriveType::PreCarrot; + } + else + { + fail_msg_writer() << tr("invalid derive type: must be 'carrot' or 'precarrot'"); + return true; + } + } else { + derive_type = carrot::AddressDeriveType::Auto; + } #ifdef _WIN32 #define PRINT_UTF8(pre, x) std::wcout << pre ## x @@ -2586,7 +2606,8 @@ bool simple_wallet::show_qr_code(const std::vector &args) WTEXTON(); try { - const std::string address = "salvium:" + m_wallet->get_subaddress_as_str({m_current_subaddress_account, subaddress_index}); + const std::string address = "salvium:" + m_wallet->get_subaddress_as_str({m_current_subaddress_account, subaddress_index, derive_type, false}); + message_writer() << "Showing QR code for address: " << address.c_str() << std::endl; const qrcodegen::QrCode qr = qrcodegen::QrCode::encodeText(address.c_str(), qrcodegen::QrCode::Ecc::LOW); for (int y = -2; y < qr.getSize() + 2; y+=2) {