aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorRiccardo Spagni <ric@spagni.net>2018-12-12 11:55:13 +0200
committerRiccardo Spagni <ric@spagni.net>2018-12-12 11:55:13 +0200
commitc73ac91af8c150c21087b03ad568c17ce4e14402 (patch)
treef4907034005d83c51bb50fc19a28a2c00970d6f3 /src
parentMerge pull request #4840 (diff)
parentsimplewallet: enable donation on testnet/stagenet for easier testing (diff)
downloadmonero-c73ac91af8c150c21087b03ad568c17ce4e14402.tar.xz
Merge pull request #4897
9b5efad2 simplewallet: enable donation on testnet/stagenet for easier testing (stoffu)
Diffstat (limited to 'src')
-rw-r--r--src/simplewallet/simplewallet.cpp29
1 files changed, 21 insertions, 8 deletions
diff --git a/src/simplewallet/simplewallet.cpp b/src/simplewallet/simplewallet.cpp
index e57565015..b729c4bb7 100644
--- a/src/simplewallet/simplewallet.cpp
+++ b/src/simplewallet/simplewallet.cpp
@@ -6008,12 +6008,6 @@ bool simple_wallet::sweep_below(const std::vector<std::string> &args_)
//----------------------------------------------------------------------------------------------------
bool simple_wallet::donate(const std::vector<std::string> &args_)
{
- if(m_wallet->nettype() != cryptonote::MAINNET)
- {
- fail_msg_writer() << tr("donations are not enabled on the testnet or on the stagenet");
- return true;
- }
-
std::vector<std::string> local_args = args_;
if(local_args.empty() || local_args.size() > 5)
{
@@ -6035,11 +6029,30 @@ bool simple_wallet::donate(const std::vector<std::string> &args_)
amount_str = local_args.back();
local_args.pop_back();
// push back address, amount, payment id
- local_args.push_back(MONERO_DONATION_ADDR);
+ std::string address_str;
+ if (m_wallet->nettype() != cryptonote::MAINNET)
+ {
+ // if not mainnet, convert donation address string to the relevant network type
+ address_parse_info info;
+ if (!cryptonote::get_account_address_from_str(info, cryptonote::MAINNET, MONERO_DONATION_ADDR))
+ {
+ fail_msg_writer() << tr("Failed to parse donation address: ") << MONERO_DONATION_ADDR;
+ return true;
+ }
+ address_str = cryptonote::get_account_address_as_str(m_wallet->nettype(), info.is_subaddress, info.address);
+ }
+ else
+ {
+ address_str = MONERO_DONATION_ADDR;
+ }
+ local_args.push_back(address_str);
local_args.push_back(amount_str);
if (!payment_id_str.empty())
local_args.push_back(payment_id_str);
- message_writer() << (boost::format(tr("Donating %s %s to The Monero Project (donate.getmonero.org or %s).")) % amount_str % cryptonote::get_unit(cryptonote::get_default_decimal_point()) % MONERO_DONATION_ADDR).str();
+ if (m_wallet->nettype() == cryptonote::MAINNET)
+ message_writer() << (boost::format(tr("Donating %s %s to The Monero Project (donate.getmonero.org or %s).")) % amount_str % cryptonote::get_unit(cryptonote::get_default_decimal_point()) % MONERO_DONATION_ADDR).str();
+ else
+ message_writer() << (boost::format(tr("Donating %s %s to %s.")) % amount_str % cryptonote::get_unit(cryptonote::get_default_decimal_point()) % address_str).str();
transfer(local_args);
return true;
}