aboutsummaryrefslogtreecommitdiff
path: root/src/simplewallet
diff options
context:
space:
mode:
authorKenshi Takayama <kenshi84@protonmail.ch>2016-12-14 20:44:09 +0900
committerKenshi Takayama <kenshi84@protonmail.ch>2016-12-15 19:01:36 +0900
commit2506d51d60eb31fefc36ca012694ef2454fc9277 (patch)
tree4d6b567d5f45d8d1d31306d51ef9e124e8dc0f59 /src/simplewallet
parentMerge pull request #1445 (diff)
downloadmonero-2506d51d60eb31fefc36ca012694ef2454fc9277.tar.xz
wallet cli: donate command
Diffstat (limited to 'src/simplewallet')
-rw-r--r--src/simplewallet/simplewallet.cpp40
-rw-r--r--src/simplewallet/simplewallet.h1
2 files changed, 41 insertions, 0 deletions
diff --git a/src/simplewallet/simplewallet.cpp b/src/simplewallet/simplewallet.cpp
index 85bdee16f..b46447975 100644
--- a/src/simplewallet/simplewallet.cpp
+++ b/src/simplewallet/simplewallet.cpp
@@ -663,6 +663,7 @@ simple_wallet::simple_wallet()
m_cmd_binder.set_handler("locked_transfer", boost::bind(&simple_wallet::locked_transfer, this, _1), tr("locked_transfer [<mixin_count>] <addr> <amount> <lockblocks>(Number of blocks to lock the transaction for, max 1000000) [<payment_id>]"));
m_cmd_binder.set_handler("sweep_unmixable", boost::bind(&simple_wallet::sweep_unmixable, this, _1), tr("Send all unmixable outputs to yourself with mixin 0"));
m_cmd_binder.set_handler("sweep_all", boost::bind(&simple_wallet::sweep_all, this, _1), tr("sweep_all [mixin] address [payment_id] - Send all unlocked balance an address"));
+ m_cmd_binder.set_handler("donate", boost::bind(&simple_wallet::donate, this, _1), tr("donate [<mixin_count>] <amount> [payment_id] - Donate <amount> to the development team (donate.getmonero.org)"));
m_cmd_binder.set_handler("sign_transfer", boost::bind(&simple_wallet::sign_transfer, this, _1), tr("Sign a transaction from a file"));
m_cmd_binder.set_handler("submit_transfer", boost::bind(&simple_wallet::submit_transfer, this, _1), tr("Submit a signed transaction from a file"));
m_cmd_binder.set_handler("set_log", boost::bind(&simple_wallet::set_log, this, _1), tr("set_log <level> - Change current log detail level, <0-4>"));
@@ -2826,6 +2827,45 @@ bool simple_wallet::sweep_all(const std::vector<std::string> &args_)
return true;
}
//----------------------------------------------------------------------------------------------------
+bool simple_wallet::donate(const std::vector<std::string> &args_)
+{
+ std::vector<std::string> local_args = args_;
+ if(local_args.empty() || local_args.size() > 3)
+ {
+ fail_msg_writer() << tr("wrong number of arguments");
+ return true;
+ }
+ std::string mixin_str;
+ std::string address_str = "donate.getmonero.org";
+ std::string amount_str;
+ std::string payment_id_str;
+ // check payment id
+ crypto::hash payment_id;
+ crypto::hash8 payment_id8;
+ if (tools::wallet2::parse_long_payment_id (local_args.back(), payment_id ) ||
+ tools::wallet2::parse_short_payment_id(local_args.back(), payment_id8))
+ {
+ payment_id_str = local_args.back();
+ local_args.pop_back();
+ }
+ // check mixin
+ if (local_args.size() > 1)
+ {
+ mixin_str = local_args[0];
+ local_args.erase(local_args.begin());
+ }
+ amount_str = local_args[0];
+ // refill args as necessary
+ local_args.clear();
+ if (!mixin_str.empty())
+ local_args.push_back(mixin_str);
+ local_args.push_back(address_str);
+ local_args.push_back(amount_str);
+ if (!payment_id_str.empty())
+ local_args.push_back(payment_id_str);
+ transfer_new(local_args);
+}
+//----------------------------------------------------------------------------------------------------
bool simple_wallet::accept_loaded_tx(const std::function<size_t()> get_num_txes, const std::function<const tools::wallet2::tx_construction_data&(size_t)> &get_tx, const std::string &extra_message)
{
// gather info to ask the user
diff --git a/src/simplewallet/simplewallet.h b/src/simplewallet/simplewallet.h
index 0d83f429b..420597699 100644
--- a/src/simplewallet/simplewallet.h
+++ b/src/simplewallet/simplewallet.h
@@ -124,6 +124,7 @@ namespace cryptonote
bool locked_transfer(const std::vector<std::string> &args);
bool sweep_all(const std::vector<std::string> &args);
bool sweep_unmixable(const std::vector<std::string> &args);
+ bool donate(const std::vector<std::string> &args);
bool sign_transfer(const std::vector<std::string> &args);
bool submit_transfer(const std::vector<std::string> &args);
std::vector<std::vector<cryptonote::tx_destination_entry>> split_amounts(