Browse Source

Merge remote branch 'refs/remotes/svn/trunk' into svn

miguelfreitas
Gavin Andresen 14 years ago
parent
commit
de374ba6b1
  1. 2
      main.cpp
  2. 110
      ui.cpp

2
main.cpp

@ -929,7 +929,7 @@ bool CheckProofOfWork(uint256 hash, unsigned int nBits)
bool IsInitialBlockDownload() bool IsInitialBlockDownload()
{ {
if (pindexBest == NULL || nBestHeight < 74000) if (pindexBest == NULL || (!fTestNet && nBestHeight < 74000))
return true; return true;
static int64 nLastUpdate; static int64 nLastUpdate;
static CBlockIndex* pindexLastBest; static CBlockIndex* pindexLastBest;

110
ui.cpp

@ -1929,69 +1929,73 @@ void CSendDialog::OnButtonPaste(wxCommandEvent& event)
void CSendDialog::OnButtonSend(wxCommandEvent& event) void CSendDialog::OnButtonSend(wxCommandEvent& event)
{ {
CWalletTx wtx; static CCriticalSection cs_sendlock;
string strAddress = (string)m_textCtrlAddress->GetValue(); TRY_CRITICAL_BLOCK(cs_sendlock)
// Parse amount
int64 nValue = 0;
if (!ParseMoney(m_textCtrlAmount->GetValue(), nValue) || nValue <= 0)
{
wxMessageBox(_("Error in amount "), _("Send Coins"));
return;
}
if (nValue > GetBalance())
{ {
wxMessageBox(_("Amount exceeds your balance "), _("Send Coins")); CWalletTx wtx;
return; string strAddress = (string)m_textCtrlAddress->GetValue();
}
if (nValue + nTransactionFee > GetBalance())
{
wxMessageBox(string(_("Total exceeds your balance when the ")) + FormatMoney(nTransactionFee) + _(" transaction fee is included "), _("Send Coins"));
return;
}
// Parse bitcoin address // Parse amount
uint160 hash160; int64 nValue = 0;
bool fBitcoinAddress = AddressToHash160(strAddress, hash160); if (!ParseMoney(m_textCtrlAmount->GetValue(), nValue) || nValue <= 0)
{
wxMessageBox(_("Error in amount "), _("Send Coins"));
return;
}
if (nValue > GetBalance())
{
wxMessageBox(_("Amount exceeds your balance "), _("Send Coins"));
return;
}
if (nValue + nTransactionFee > GetBalance())
{
wxMessageBox(string(_("Total exceeds your balance when the ")) + FormatMoney(nTransactionFee) + _(" transaction fee is included "), _("Send Coins"));
return;
}
if (fBitcoinAddress) // Parse bitcoin address
{ uint160 hash160;
// Send to bitcoin address bool fBitcoinAddress = AddressToHash160(strAddress, hash160);
CScript scriptPubKey;
scriptPubKey << OP_DUP << OP_HASH160 << hash160 << OP_EQUALVERIFY << OP_CHECKSIG;
string strError = SendMoney(scriptPubKey, nValue, wtx, true); if (fBitcoinAddress)
if (strError == "")
wxMessageBox(_("Payment sent "), _("Sending..."));
else if (strError != "ABORTED")
wxMessageBox(strError + " ", _("Sending..."));
}
else
{
// Parse IP address
CAddress addr(strAddress);
if (!addr.IsValid())
{ {
wxMessageBox(_("Invalid address "), _("Send Coins")); // Send to bitcoin address
return; CScript scriptPubKey;
scriptPubKey << OP_DUP << OP_HASH160 << hash160 << OP_EQUALVERIFY << OP_CHECKSIG;
string strError = SendMoney(scriptPubKey, nValue, wtx, true);
if (strError == "")
wxMessageBox(_("Payment sent "), _("Sending..."));
else if (strError != "ABORTED")
wxMessageBox(strError + " ", _("Sending..."));
} }
else
{
// Parse IP address
CAddress addr(strAddress);
if (!addr.IsValid())
{
wxMessageBox(_("Invalid address "), _("Send Coins"));
return;
}
// Message // Message
wtx.mapValue["to"] = strAddress; wtx.mapValue["to"] = strAddress;
wtx.mapValue["from"] = m_textCtrlFrom->GetValue(); wtx.mapValue["from"] = m_textCtrlFrom->GetValue();
wtx.mapValue["message"] = m_textCtrlMessage->GetValue(); wtx.mapValue["message"] = m_textCtrlMessage->GetValue();
// Send to IP address // Send to IP address
CSendingDialog* pdialog = new CSendingDialog(this, addr, nValue, wtx); CSendingDialog* pdialog = new CSendingDialog(this, addr, nValue, wtx);
if (!pdialog->ShowModal()) if (!pdialog->ShowModal())
return; return;
} }
CRITICAL_BLOCK(cs_mapAddressBook) CRITICAL_BLOCK(cs_mapAddressBook)
if (!mapAddressBook.count(strAddress)) if (!mapAddressBook.count(strAddress))
SetAddressBookName(strAddress, ""); SetAddressBookName(strAddress, "");
EndModal(true); EndModal(true);
}
} }
void CSendDialog::OnButtonCancel(wxCommandEvent& event) void CSendDialog::OnButtonCancel(wxCommandEvent& event)

Loading…
Cancel
Save