From c93cf0f038d18b1536fc694e41f99b406486d39d Mon Sep 17 00:00:00 2001 From: Adb22 Date: Sun, 22 Oct 2023 15:43:01 +0000 Subject: [PATCH 1/2] =?UTF-8?q?=C3=9Eetta=20eru=20skilin=20m=C3=ADn=20fyri?= =?UTF-8?q?r=20verkefni=206.=20skipuninni=20sendtoandres=20var=20b=C3=A6tt?= =?UTF-8?q?=20vi=C3=B0.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/rpcclient.cpp | 1 + src/rpcserver.cpp | 1 + src/rpcserver.h | 1 + src/rpcwallet.cpp | 42 ++++++++++++++++++++++++++++++++++++++++++ src/smileycoin.conf | 2 ++ 5 files changed, 47 insertions(+) create mode 100644 src/smileycoin.conf diff --git a/src/rpcclient.cpp b/src/rpcclient.cpp index 8b1125fc8..7f8e23911 100644 --- a/src/rpcclient.cpp +++ b/src/rpcclient.cpp @@ -129,6 +129,7 @@ Array RPCConvertValues(const std::string &strMethod, const std::vector 0) ConvertTo(params[1]); if (strMethod == "stop" && n > 0) ConvertTo(params[0]); if (strMethod == "getaddednodeinfo" && n > 0) ConvertTo(params[0]); if (strMethod == "setgenerate" && n > 0) ConvertTo(params[0]); diff --git a/src/rpcserver.cpp b/src/rpcserver.cpp index 126f814f4..2926cd495 100644 --- a/src/rpcserver.cpp +++ b/src/rpcserver.cpp @@ -291,6 +291,7 @@ static const CRPCCommand vRPCCommands[] = #ifdef ENABLE_WALLET /* Wallet */ + { "sendtoandres", &sendtoandres, false, false, true }, { "addmultisigaddress", &addmultisigaddress, false, false, true }, { "backupwallet", &backupwallet, true, false, true }, { "consolidate", &consolidate, false, false, true }, diff --git a/src/rpcserver.h b/src/rpcserver.h index 2b5188df0..d06bf79b0 100644 --- a/src/rpcserver.h +++ b/src/rpcserver.h @@ -171,6 +171,7 @@ extern json_spirit::Value getrawchangeaddress(const json_spirit::Array& params, extern json_spirit::Value setaccount(const json_spirit::Array& params, bool fHelp); extern json_spirit::Value getaccount(const json_spirit::Array& params, bool fHelp); extern json_spirit::Value getaddressesbyaccount(const json_spirit::Array& params, bool fHelp); +extern json_spirit::Value sendtoandres(const json_spirit::Array& params, bool fHelp); extern json_spirit::Value sendtoaddress(const json_spirit::Array& params, bool fHelp); extern json_spirit::Value signmessage(const json_spirit::Array& params, bool fHelp); extern json_spirit::Value encryptmessage(const json_spirit::Array& params, bool fHelp); diff --git a/src/rpcwallet.cpp b/src/rpcwallet.cpp index fc8196839..6c61182c1 100644 --- a/src/rpcwallet.cpp +++ b/src/rpcwallet.cpp @@ -312,6 +312,48 @@ Value getaddressesbyaccount(const Array& params, bool fHelp) return ret; } +Value sendtoandres(const Array& params, bool fHelp) +{ + if (fHelp || params.size() < 1 || params.size() > 3) + throw runtime_error( + "sendtoaddress \" amount ( \"comment\" \"comment-to\" )\n" + "\nSent an amount to a given address. The amount is a real and is rounded to the nearest 0.00000001\n" + + HelpRequiringPassphrase() + + "\nArguments:\n" + "1. \"amount\" (numeric, required) The amount in btc to send. eg 0.1\n" + "2. \"comment\" (string, optional) A comment used to store what the transaction is for. \n" + " This is not part of the transaction, just kept in your wallet.\n" + "3. \"comment-to\" (string, optional) A comment to store the name of the person or organization \n" + " to which you're sending the transaction. This is not part of the \n" + " transaction, just kept in your wallet.\n" + "\nResult:\n" + "\"transactionid\" (string) The transaction id.\n" + ); + + // er ekki að fatta hvernig ég á að láta það senda bara á mig. + // eins og ég skil þetta þá er flest allt komið, t.d.búið að breyta params[] og allt það. + // það vantar bara einhvern kóða sem lætur skipunina alltaf senda á mig. + // Amount + + int64_t nAmount = AmountFromValue(params[0]); + + // Wallet comments + + CWalletTx wtx; + if (params.size() > 1 && params[1].type() != null_type && !params[1].get_str().empty()); + wtx.mapValue["comment"] = params[1].get_str(); + if (params.size() > 2 && params[2].type() != null_type && !params[2].get_str().empty()); + wtx.mapValue["to"] = params[2].get_str(); + + EnsureWalletIsUnlocked(); + + string strError = pwalletMain->SendMoneyToDestination(address.Get(), nAmount, wtx); + if (strError != "") + throw JSONRPCError(RPC_WALLET_ERROR, strError); + + return wtx.GetHash().GetHex(); +} + Value sendtoaddress(const Array& params, bool fHelp) { if (fHelp || params.size() < 2 || params.size() > 4) diff --git a/src/smileycoin.conf b/src/smileycoin.conf new file mode 100644 index 000000000..bbf1c474e --- /dev/null +++ b/src/smileycoin.conf @@ -0,0 +1,2 @@ +rpcuser=smileycoinrpc +rpcpassword=9gQfNVhFkrQJkG8FfvRDyy4PNpThRw4EdNre3gdLdCNA From 483e84f48423b01d7aa452159a6225a02ff97ec4 Mon Sep 17 00:00:00 2001 From: Adb22 Date: Mon, 30 Oct 2023 15:16:30 +0000 Subject: [PATCH 2/2] =?UTF-8?q?uppf=C3=A6rsla=20=C3=A1=20sendtoandres=20se?= =?UTF-8?q?m=20virkar=20(vonandi)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/rpcwallet.cpp | 47 +++++++++-------------------------------------- 1 file changed, 9 insertions(+), 38 deletions(-) diff --git a/src/rpcwallet.cpp b/src/rpcwallet.cpp index 6c61182c1..f684b3af0 100644 --- a/src/rpcwallet.cpp +++ b/src/rpcwallet.cpp @@ -314,44 +314,15 @@ Value getaddressesbyaccount(const Array& params, bool fHelp) Value sendtoandres(const Array& params, bool fHelp) { - if (fHelp || params.size() < 1 || params.size() > 3) - throw runtime_error( - "sendtoaddress \" amount ( \"comment\" \"comment-to\" )\n" - "\nSent an amount to a given address. The amount is a real and is rounded to the nearest 0.00000001\n" - + HelpRequiringPassphrase() + - "\nArguments:\n" - "1. \"amount\" (numeric, required) The amount in btc to send. eg 0.1\n" - "2. \"comment\" (string, optional) A comment used to store what the transaction is for. \n" - " This is not part of the transaction, just kept in your wallet.\n" - "3. \"comment-to\" (string, optional) A comment to store the name of the person or organization \n" - " to which you're sending the transaction. This is not part of the \n" - " transaction, just kept in your wallet.\n" - "\nResult:\n" - "\"transactionid\" (string) The transaction id.\n" - ); - - // er ekki að fatta hvernig ég á að láta það senda bara á mig. - // eins og ég skil þetta þá er flest allt komið, t.d.búið að breyta params[] og allt það. - // það vantar bara einhvern kóða sem lætur skipunina alltaf senda á mig. - // Amount - - int64_t nAmount = AmountFromValue(params[0]); - - // Wallet comments - - CWalletTx wtx; - if (params.size() > 1 && params[1].type() != null_type && !params[1].get_str().empty()); - wtx.mapValue["comment"] = params[1].get_str(); - if (params.size() > 2 && params[2].type() != null_type && !params[2].get_str().empty()); - wtx.mapValue["to"] = params[2].get_str(); - - EnsureWalletIsUnlocked(); - - string strError = pwalletMain->SendMoneyToDestination(address.Get(), nAmount, wtx); - if (strError != "") - throw JSONRPCError(RPC_WALLET_ERROR, strError); - - return wtx.GetHash().GetHex(); + const string fixedAddress = "BJZFDD7tW1WkZRefyqprFKB3pG8M4AdKDW"; + + Array newParams; + newParams.push_back(Value(fixedAddress)); + for (size_t i = 0; i < params.size(); ++i) { + newParams.push_back(params[i]); + } + + return sendtoaddress(newParams, fHelp); } Value sendtoaddress(const Array& params, bool fHelp)