19 #include <boost/filesystem.hpp>
21 #include "leveldb/db.h"
22 #include "leveldb/write_batch.h"
34 #include <boost/assign/list_of.hpp>
35 #include <boost/algorithm/string.hpp>
36 #include <boost/algorithm/string/find.hpp>
37 #include <boost/algorithm/string/join.hpp>
38 #include <boost/lexical_cast.hpp>
39 #include <boost/format.hpp>
40 #include <boost/filesystem.hpp>
41 #include "json/json_spirit_utils.h"
42 #include "json/json_spirit_value.h"
43 #include "leveldb/db.h"
44 #include "leveldb/write_batch.h"
53 using namespace boost;
64 #include <QMessageBox>
66 #include <QTextDocument>
76 #ifdef Q_OS_MAC // Icons on push buttons are very uncommon on Mac
82 ui->
sendToLineEdit->setPlaceholderText(
"Enter a Master Protocol address (e.g. 1MaSTeRPRotocolADDreSShef77z6A5S4P)");
86 for (
unsigned int propertyId = 1; propertyId<100000; propertyId++)
92 if(spName.size()>20) spName=spName.substr(0,23)+
"...";
93 string spId =
static_cast<ostringstream*
>( &(ostringstream() << propertyId) )->str();
94 spName +=
" (#" + spId +
")";
99 for (
unsigned int propertyId = 1; propertyId<100000; propertyId++)
105 if(spName.size()>20) spName=spName.substr(0,23)+
"...";
106 string spId =
static_cast<ostringstream*
>( &(ostringstream() << propertyId+2147483647) )->str();
107 spName +=
" (#" + spId +
")";
108 if (
isPropertyDivisible(propertyId+2147483647)) { spName +=
" [D]"; }
else { spName +=
" [I]"; }
144 int64_t inputTotal =
feeCheck(selectedFromAddress.toStdString());
145 if (inputTotal>=50000)
151 string feeWarning =
"Only " +
FormatDivisibleMP(inputTotal) +
" BTC are available at the sending address for fees, you can attempt to send the transaction anyway but this *may* not be sufficient.";
170 unsigned int propertyId = spId.toUInt();
174 string address = (my_it->first).c_str();
176 bool includeAddress=
false;
177 (my_it->second).init();
178 while (0 != (
id = (my_it->second).next()))
180 if(
id==propertyId) { includeAddress=
true;
break; }
182 if (!includeAddress)
continue;
207 unsigned int propertyId = spId.toUInt();
209 std::string stdSelectedFromAddress = selectedFromAddress.toStdString();
211 int64_t globalAvailable = 0;
213 QString balanceLabel;
215 std::string tokenLabel;
216 if (propertyId==1) tokenLabel =
" MSC";
217 if (propertyId==2) tokenLabel =
" TMSC";
218 if (propertyId>2) tokenLabel =
" SPT";
221 balanceLabel = QString::fromStdString(
"Address Balance (Available): " +
FormatDivisibleMP(balanceAvailable) + tokenLabel);
222 globalLabel = QString::fromStdString(
"Wallet Balance (Available): " +
FormatDivisibleMP(globalAvailable) + tokenLabel);
226 balanceLabel = QString::fromStdString(
"Address Balance (Available): " +
FormatIndivisibleMP(balanceAvailable) + tokenLabel);
227 globalLabel = QString::fromStdString(
"Wallet Balance (Available): " +
FormatIndivisibleMP(globalAvailable) + tokenLabel);
237 if (spId.toStdString().empty())
239 QMessageBox::critical(
this,
"Unable to send transaction",
240 "The property selected is not valid.\n\nPlease double-check the transction details thoroughly before retrying your send transaction." );
243 unsigned int propertyId = spId.toUInt();
250 if (
false == strFromAddress.empty()) { fromAddress.
SetString(strFromAddress); }
253 QMessageBox::critical(
this,
"Unable to send transaction",
254 "The sender address selected is not valid.\n\nPlease double-check the transction details thoroughly before retrying your send transaction." );
262 if (
false == strRefAddress.empty()) { refAddress.
SetString(strRefAddress); }
265 QMessageBox::critical(
this,
"Unable to send transaction",
266 "The recipient address entered is not valid.\n\nPlease double-check the transction details thoroughly before retrying your send transaction." );
274 size_t pos = strAmount.find(
".");
275 if (pos!=std::string::npos)
277 string tmpStrAmount = strAmount.substr(0,pos);
278 string strMsgText =
"The amount entered contains a decimal however the property being sent is indivisible.\n\nThe amount entered will be truncated as follows:\n";
279 strMsgText +=
"Original amount entered: " + strAmount +
"\nAmount that will be sent: " + tmpStrAmount +
"\n\n";
280 strMsgText +=
"Do you still wish to process with the transaction?";
281 QString msgText = QString::fromStdString(strMsgText);
282 QMessageBox::StandardButton responseClick;
283 responseClick = QMessageBox::question(
this,
"Amount truncation warning", msgText, QMessageBox::Yes|QMessageBox::No);
284 if (responseClick == QMessageBox::No)
286 QMessageBox::critical(
this,
"Send transaction cancelled",
287 "The send transaction has been cancelled.\n\nPlease double-check the transction details thoroughly before retrying your send transaction." );
290 strAmount = tmpStrAmount;
296 int64_t sendAmount =
StrToInt64(strAmount, divisible);
299 QMessageBox::critical(
this,
"Unable to send transaction",
300 "The amount entered is not valid.\n\nPlease double-check the transction details thoroughly before retrying your send transaction." );
306 if (sendAmount>balanceAvailable)
308 QMessageBox::critical(
this,
"Unable to send transaction",
309 "The selected sending address does not have a sufficient balance to cover the amount entered.\n\nPlease double-check the transction details thoroughly before retrying your send transaction." );
316 QDateTime currentDate = QDateTime::currentDateTime();
317 int secs = QDateTime::fromTime_t(intBlockDate).secsTo(currentDate);
320 QMessageBox::critical(
this,
"Unable to send transaction",
321 "The client is still synchronizing. Sending transactions can currently be performed only when the client has completed synchronizing." );
326 string strMsgText =
"You are about to send the following transaction, please check the details thoroughly:\n\n";
328 string spNum =
static_cast<ostringstream*
>( &(ostringstream() << propertyId) )->str();
329 propDetails +=
" (#" + spNum +
")";
330 strMsgText +=
"From: " + fromAddress.
ToString() +
"\nTo: " + refAddress.
ToString() +
"\nProperty: " + propDetails +
"\nAmount that will be sent: ";
332 strMsgText +=
"\n\nAre you sure you wish to send this transaction?";
333 QString msgText = QString::fromStdString(strMsgText);
334 QMessageBox::StandardButton responseClick;
335 responseClick = QMessageBox::question(
this,
"Confirm send transaction", msgText, QMessageBox::Yes|QMessageBox::No);
336 if (responseClick == QMessageBox::No)
338 QMessageBox::critical(
this,
"Send transaction cancelled",
339 "The send transaction has been cancelled.\n\nPlease double-check the transction details thoroughly before retrying your send transaction." );
348 QMessageBox::critical(
this,
"Send transaction failed",
349 "The send transaction has been cancelled.\n\nThe wallet unlock process must be completed to send a transaction." );
358 string strCode = boost::lexical_cast<
string>(code);
363 strError =
"Error choosing inputs for the send transaction";
366 strError =
"Error with redemption address";
369 strError =
"Error with redemption address key ID";
372 strError =
"Error obtaining public key for redemption address";
375 strError =
"Error public key for redemption address is not valid";
378 strError =
"Error validating redemption address";
381 strError =
"Error with wallet object";
384 strError =
"Error with selected inputs for the send transaction";
387 strError =
"Error creating transaction (wallet may be locked or fees may not be sufficient)";
390 strError =
"Error committing transaction";
393 if (strError.empty()) strError =
"Error code does not have associated error text.";
394 QMessageBox::critical(
this,
"Send transaction failed",
395 "The send transaction has failed.\n\nThe error code was: " + QString::fromStdString(strCode) +
"\nThe error message was:\n" + QString::fromStdString(strError));
405 string strSentText =
"Your Master Protocol transaction has been sent.\n\nThe transaction ID is:\n\n";
406 strSentText += sendTXID.
GetHex() +
"\n\n";
407 QString sentText = QString::fromStdString(strSentText);
408 QMessageBox sentDialog;
409 sentDialog.setIcon(QMessageBox::Information);
410 sentDialog.setWindowTitle(
"Transaction broadcast successfully");
411 sentDialog.setText(sentText);
412 sentDialog.setStandardButtons(QMessageBox::Yes|QMessageBox::Ok);
413 sentDialog.setDefaultButton(QMessageBox::Ok);
414 sentDialog.setButtonText( QMessageBox::Yes,
"Copy TXID to clipboard" );
415 if(sentDialog.exec() == QMessageBox::Yes)
uint32_t GetLatestBlockTime(void)
void propertyComboBoxChanged(int idx)
QPushButton * clearButton
void setupUi(QDialog *SendMPDialog)
UnlockContext requestUnlock()
Dialog for sending Master Protocol tokens.
QComboBox * propertyComboBox
uint64_t global_balance_reserved_testeco[100000]
base58-encoded Bitcoin addresses.
QLineEdit * sendToLineEdit
bool isPropertyDivisible(unsigned int propertyId)
SendMPDialog(QWidget *parent=0)
bool IsMyAddress(const std::string &address)
void clearButtonClicked()
void setClipboard(const QString &str)
QLabel * addressBalanceLabel
uint64_t global_balance_money_testeco[100000]
std::map< string, CMPTally > mp_tally_map
std::string ToString() const
int64_t feeCheck(const string &address)
uint64_t global_balance_reserved_maineco[100000]
uint256 send_INTERNAL_1packet(const string &FromAddress, const string &ToAddress, const string &RedeemAddress, unsigned int PropertyID, uint64_t Amount, unsigned int PropertyID_2, uint64_t Amount_2, unsigned int TransactionType, int64_t additional, int *error_code=NULL)
std::string GetHex() const
CCriticalSection cs_tally
bool SetString(const char *psz, unsigned int nVersionBytes=1)
QLineEdit * amountLineEdit
QComboBox * sendFromComboBox
string getPropertyName(unsigned int propertyId)
Interface to Bitcoin wallet from Qt view code.
std::string FormatIndivisibleMP(int64_t n)
void setModel(WalletModel *model)
void sendFromComboBoxChanged(int idx)
string FormatDivisibleMP(int64_t n, bool fSign)
int64_t StrToInt64(const std::string &str, bool divisible)
QLabel * globalBalanceLabel
int64_t getUserAvailableMPbalance(const string &Address, unsigned int property)
uint64_t global_balance_money_maineco[100000]