|
19 | 19 | #include <boost/tokenizer.hpp> |
20 | 20 | #include <fstream> |
21 | 21 |
|
22 | | - |
23 | | -void SendMoney(const CTxDestination& address, CAmount nValue, CWalletTx& wtxNew, AvailableCoinsType coin_type = ALL_COINS) |
24 | | -{ |
25 | | - // Check amount |
26 | | - if (nValue <= 0) |
27 | | - throw JSONRPCError(RPC_INVALID_PARAMETER, "Invalid amount"); |
28 | | - |
29 | | - if (nValue > pwalletMain->GetBalance()) |
30 | | - throw JSONRPCError(RPC_WALLET_INSUFFICIENT_FUNDS, "Insufficient funds"); |
31 | | - |
32 | | - string strError; |
33 | | - if (pwalletMain->IsLocked()) { |
34 | | - strError = "Error: Wallet locked, unable to create transaction!"; |
35 | | - LogPrintf("SendMoney() : %s", strError); |
36 | | - throw JSONRPCError(RPC_WALLET_ERROR, strError); |
37 | | - } |
38 | | - |
39 | | - // Parse Pivx address |
40 | | - CScript scriptPubKey = GetScriptForDestination(address); |
41 | | - |
42 | | - // Create and send the transaction |
43 | | - CReserveKey reservekey(pwalletMain); |
44 | | - CAmount nFeeRequired; |
45 | | - if (!pwalletMain->CreateTransaction(scriptPubKey, nValue, wtxNew, reservekey, nFeeRequired, strError, NULL, coin_type)) { |
46 | | - if (nValue + nFeeRequired > pwalletMain->GetBalance()) |
47 | | - strError = strprintf("Error: This transaction requires a transaction fee of at least %s because of its amount, complexity, or use of recently received funds!", FormatMoney(nFeeRequired)); |
48 | | - LogPrintf("SendMoney() : %s\n", strError); |
49 | | - throw JSONRPCError(RPC_WALLET_ERROR, strError); |
50 | | - } |
51 | | - if (!pwalletMain->CommitTransaction(wtxNew, reservekey)) |
52 | | - throw JSONRPCError(RPC_WALLET_ERROR, "Error: The transaction was rejected! This might happen if some of the coins in your wallet were already spent, such as if you used a copy of wallet.dat and coins were spent in the copy but not marked as spent here."); |
53 | | -} |
54 | | - |
55 | | -UniValue obfuscation(const UniValue& params, bool fHelp) |
56 | | -{ |
57 | | - throw runtime_error("Obfuscation is not supported any more. Use Zerocoin\n"); |
58 | | - |
59 | | - if (fHelp || params.size() == 0) |
60 | | - throw runtime_error( |
61 | | - "obfuscation <pivxaddress> <amount>\n" |
62 | | - "pivxaddress, reset, or auto (AutoDenominate)" |
63 | | - "<amount> is a real and will be rounded to the next 0.1" + |
64 | | - HelpRequiringPassphrase()); |
65 | | - |
66 | | - if (pwalletMain->IsLocked()) |
67 | | - throw JSONRPCError(RPC_WALLET_UNLOCK_NEEDED, "Error: Please enter the wallet passphrase with walletpassphrase first."); |
68 | | - |
69 | | - if (params[0].get_str() == "auto") { |
70 | | - if (fMasterNode) |
71 | | - return "ObfuScation is not supported from masternodes"; |
72 | | - |
73 | | - return "DoAutomaticDenominating " + (obfuScationPool.DoAutomaticDenominating() ? "successful" : ("failed: " + obfuScationPool.GetStatus())); |
74 | | - } |
75 | | - |
76 | | - if (params[0].get_str() == "reset") { |
77 | | - obfuScationPool.Reset(); |
78 | | - return "successfully reset obfuscation"; |
79 | | - } |
80 | | - |
81 | | - if (params.size() != 2) |
82 | | - throw runtime_error( |
83 | | - "obfuscation <pivxaddress> <amount>\n" |
84 | | - "pivxaddress, denominate, or auto (AutoDenominate)" |
85 | | - "<amount> is a real and will be rounded to the next 0.1" + |
86 | | - HelpRequiringPassphrase()); |
87 | | - |
88 | | - CBitcoinAddress address(params[0].get_str()); |
89 | | - if (!address.IsValid()) |
90 | | - throw JSONRPCError(RPC_INVALID_ADDRESS_OR_KEY, "Invalid Pivx address"); |
91 | | - |
92 | | - // Amount |
93 | | - CAmount nAmount = AmountFromValue(params[1]); |
94 | | - |
95 | | - // Wallet comments |
96 | | - CWalletTx wtx; |
97 | | - // string strError = pwalletMain->SendMoneyToDestination(address.Get(), nAmount, wtx, ONLY_DENOMINATED); |
98 | | - SendMoney(address.Get(), nAmount, wtx, ONLY_DENOMINATED); |
99 | | - // if (strError != "") |
100 | | - // throw JSONRPCError(RPC_WALLET_ERROR, strError); |
101 | | - |
102 | | - return wtx.GetHash().GetHex(); |
103 | | -} |
104 | | - |
105 | | - |
106 | 22 | UniValue getpoolinfo(const UniValue& params, bool fHelp) |
107 | 23 | { |
108 | 24 | if (fHelp || params.size() != 0) |
|
0 commit comments