aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLuke Dashjr <luke-jr+git@utopios.org>2012-03-16 16:45:32 -0400
committerLuke Dashjr <luke-jr+git@utopios.org>2012-03-16 16:45:32 -0400
commiteca170286ef79096b9005c28d0a6e1145b440f60 (patch)
tree2f749271fc7631196a3bd6f46971e61170bdc1b0
parent7f23df06d7126e32bb2b80df355855bc9c8b242a (diff)
parent78b9d2de40144e6f420518bcdf62168855546ded (diff)
downloadbitcoin-eca170286ef79096b9005c28d0a6e1145b440f60.tar.xz
Merge branch '0.5.0.x' into 0.5.x
Conflicts: bitcoin-qt.pro doc/README doc/README_windows.txt share/setup.nsi src/serialize.h
-rw-r--r--bitcoin-qt.pro4
-rw-r--r--contrib/gitian-descriptors/qt-win32.yml1
-rw-r--r--src/bitcoinrpc.cpp4
-rw-r--r--src/key.h13
-rw-r--r--src/main.cpp22
-rw-r--r--src/main.h2
-rw-r--r--src/qt/addressbookpage.cpp6
-rw-r--r--src/qt/guiutil.cpp49
-rw-r--r--src/qt/guiutil.h15
-rw-r--r--src/qt/transactionview.cpp6
10 files changed, 101 insertions, 21 deletions
diff --git a/bitcoin-qt.pro b/bitcoin-qt.pro
index ea9b52acf8..bb7682590a 100644
--- a/bitcoin-qt.pro
+++ b/bitcoin-qt.pro
@@ -251,8 +251,8 @@ isEmpty(BOOST_INCLUDE_PATH) {
macx:BOOST_INCLUDE_PATH = /opt/local/include
}
-windows:LIBS += -lws2_32
-windows:DEFINES += WIN32
+windows:LIBS += -lmingwthrd -lws2_32
+windows:DEFINES += _MT WIN32
windows:RC_FILE = src/qt/res/bitcoin-qt.rc
macx:HEADERS += src/qt/macdockiconhandler.h
diff --git a/contrib/gitian-descriptors/qt-win32.yml b/contrib/gitian-descriptors/qt-win32.yml
index 6eb76b2170..adccebbb91 100644
--- a/contrib/gitian-descriptors/qt-win32.yml
+++ b/contrib/gitian-descriptors/qt-win32.yml
@@ -47,6 +47,7 @@ script: |
cp -a bin $SRCDIR/
cd $INSTDIR
find . -name *.prl | xargs -l sed 's|/$||' -i
+ sed 's/QMAKE_LIBS_QT_ENTRY = -lmingw32 -lqtmain/QMAKE_LIBS_QT_ENTRY = -lqtmain/' -i mkspecs/unsupported/win32-g++-cross/qmake.conf
#sed 's|QMAKE_PRL_LIBS.*|QMAKE_PRL_LIBS = -lQtDeclarative -lQtScript -lQtSvg -lQtSql -lQtXmlPatterns -lQtGui -lgdi32 -lcomdlg32 -loleaut32 -limm32 -lwinmm -lwinspool -lmsimg32 -lQtNetwork -lQtCore -lole32 -luuid -lws2_32 -ladvapi32 -lshell32 -luser32 -lkernel32|' -i imports/Qt/labs/particles/qmlparticlesplugin.prl
# as zip stores file timestamps, use faketime to intercept stat calls to set dates for all files to reference date
diff --git a/src/bitcoinrpc.cpp b/src/bitcoinrpc.cpp
index 5be2e0a3db..102fa14496 100644
--- a/src/bitcoinrpc.cpp
+++ b/src/bitcoinrpc.cpp
@@ -1658,7 +1658,7 @@ Value getwork(const Array& params, bool fHelp)
}
// Update nTime
- pblock->nTime = max(pindexPrev->GetMedianTimePast()+1, GetAdjustedTime());
+ pblock->UpdateTime(pindexPrev);
pblock->nNonce = 0;
// Update nExtraNonce
@@ -1755,7 +1755,7 @@ Value getmemorypool(const Array& params, bool fHelp)
}
// Update nTime
- pblock->nTime = max(pindexPrev->GetMedianTimePast()+1, GetAdjustedTime());
+ pblock->UpdateTime(pindexPrev);
pblock->nNonce = 0;
Array transactions;
diff --git a/src/key.h b/src/key.h
index f20acb3348..b1869505fb 100644
--- a/src/key.h
+++ b/src/key.h
@@ -290,13 +290,14 @@ public:
bool Sign(uint256 hash, std::vector<unsigned char>& vchSig)
{
- vchSig.clear();
- unsigned char pchSig[10000];
- unsigned int nSize = 0;
- if (!ECDSA_sign(0, (unsigned char*)&hash, sizeof(hash), pchSig, &nSize, pkey))
+ unsigned int nSize = ECDSA_size(pkey);
+ vchSig.resize(nSize); // Make sure it is big enough
+ if (!ECDSA_sign(0, (unsigned char*)&hash, sizeof(hash), &vchSig[0], &nSize, pkey))
+ {
+ vchSig.clear();
return false;
- vchSig.resize(nSize);
- memcpy(&vchSig[0], pchSig, nSize);
+ }
+ vchSig.resize(nSize); // Shrink to fit actual size
return true;
}
diff --git a/src/main.cpp b/src/main.cpp
index 747805450a..46e367391f 100644
--- a/src/main.cpp
+++ b/src/main.cpp
@@ -820,6 +820,15 @@ void static InvalidChainFound(CBlockIndex* pindexNew)
printf("InvalidChainFound: WARNING: Displayed transactions may not be correct! You may need to upgrade, or other nodes may need to upgrade.\n");
}
+void CBlock::UpdateTime(const CBlockIndex* pindexPrev)
+{
+ nTime = max(pindexPrev->GetMedianTimePast()+1, GetAdjustedTime());
+
+ // Updating time can change work required on testnet:
+ if (fTestNet)
+ nBits = GetNextWorkRequired(pindexPrev, this);
+}
+
@@ -1950,7 +1959,7 @@ bool static ProcessMessage(CNode* pfrom, string strCommand, CDataStream& vRecv)
}
// Ask the first connected node for block updates
- static int nAskedForBlocks;
+ static int nAskedForBlocks = 0;
if (!pfrom->fClient &&
(pfrom->nVersion < 32000 || pfrom->nVersion >= 32400) &&
(nAskedForBlocks < 1 || vNodes.size() <= 1))
@@ -2949,7 +2958,7 @@ CBlock* CreateNewBlock(CReserveKey& reservekey)
// Fill in header
pblock->hashPrevBlock = pindexPrev->GetBlockHash();
pblock->hashMerkleRoot = pblock->BuildMerkleTree();
- pblock->nTime = max(pindexPrev->GetMedianTimePast()+1, GetAdjustedTime());
+ pblock->UpdateTime(pindexPrev);
pblock->nBits = GetNextWorkRequired(pindexPrev, pblock.get());
pblock->nNonce = 0;
@@ -3105,6 +3114,7 @@ void static BitcoinMiner(CWallet *pwallet)
FormatHashBuffers(pblock.get(), pmidstate, pdata, phash1);
unsigned int& nBlockTime = *(unsigned int*)(pdata + 64 + 4);
+ unsigned int& nBlockBits = *(unsigned int*)(pdata + 64 + 8);
unsigned int& nBlockNonce = *(unsigned int*)(pdata + 64 + 12);
@@ -3192,8 +3202,14 @@ void static BitcoinMiner(CWallet *pwallet)
break;
// Update nTime every few seconds
- pblock->nTime = max(pindexPrev->GetMedianTimePast()+1, GetAdjustedTime());
+ pblock->UpdateTime(pindexPrev);
nBlockTime = ByteReverse(pblock->nTime);
+ if (fTestNet)
+ {
+ // Changing pblock->nTime can change work required on testnet:
+ nBlockBits = ByteReverse(pblock->nBits);
+ hashTarget = CBigNum().SetCompact(pblock->nBits).getuint256();
+ }
}
}
}
diff --git a/src/main.h b/src/main.h
index a1fb548f08..083d34029a 100644
--- a/src/main.h
+++ b/src/main.h
@@ -856,6 +856,8 @@ public:
return n;
}
+ void UpdateTime(const CBlockIndex* pindexPrev);
+
uint256 BuildMerkleTree() const
{
diff --git a/src/qt/addressbookpage.cpp b/src/qt/addressbookpage.cpp
index 0a147c9e10..76061233fc 100644
--- a/src/qt/addressbookpage.cpp
+++ b/src/qt/addressbookpage.cpp
@@ -7,7 +7,6 @@
#include <QSortFilterProxyModel>
#include <QClipboard>
-#include <QFileDialog>
#include <QMessageBox>
AddressBookPage::AddressBookPage(Mode mode, Tabs tab, QWidget *parent) :
@@ -206,10 +205,9 @@ void AddressBookPage::done(int retval)
void AddressBookPage::exportClicked()
{
// CSV is currently the only supported format
- QString filename = QFileDialog::getSaveFileName(
+ QString filename = GUIUtil::getSaveFileName(
this,
- tr("Export Address Book Data"),
- QDir::currentPath(),
+ tr("Export Address Book Data"), QString(),
tr("Comma separated file (*.csv)"));
if (filename.isNull()) return;
diff --git a/src/qt/guiutil.cpp b/src/qt/guiutil.cpp
index bc443ceeb6..d1490c8f70 100644
--- a/src/qt/guiutil.cpp
+++ b/src/qt/guiutil.cpp
@@ -11,6 +11,8 @@
#include <QFont>
#include <QLineEdit>
#include <QUrl>
+#include <QFileDialog>
+#include <QDesktopServices>
QString GUIUtil::dateTimeStr(qint64 nTime)
{
@@ -86,3 +88,50 @@ bool GUIUtil::parseBitcoinURL(QString url, SendCoinsRecipient *out)
QUrl urlInstance(url);
return parseBitcoinURL(&urlInstance, out);
}
+
+QString GUIUtil::getSaveFileName(QWidget *parent, const QString &caption,
+ const QString &dir,
+ const QString &filter,
+ QString *selectedSuffixOut)
+{
+ QString selectedFilter;
+ QString myDir;
+ if(dir.isEmpty()) // Default to user documents location
+ {
+ myDir = QDesktopServices::storageLocation(QDesktopServices::DocumentsLocation);
+ }
+ else
+ {
+ myDir = dir;
+ }
+ QString result = QFileDialog::getSaveFileName(parent, caption, myDir, filter, &selectedFilter);
+
+ /* Extract first suffix from filter pattern "Description (*.foo)" or "Description (*.foo *.bar ...) */
+ QRegExp filter_re(".* \\(\\*\\.(.*)[ \\)]");
+ QString selectedSuffix;
+ if(filter_re.exactMatch(selectedFilter))
+ {
+ selectedSuffix = filter_re.cap(1);
+ }
+
+ /* Add suffix if needed */
+ QFileInfo info(result);
+ if(!result.isEmpty())
+ {
+ if(info.suffix().isEmpty() && !selectedSuffix.isEmpty())
+ {
+ /* No suffix specified, add selected suffix */
+ if(!result.endsWith("."))
+ result.append(".");
+ result.append(selectedSuffix);
+ }
+ }
+
+ /* Return selected suffix if asked to */
+ if(selectedSuffixOut)
+ {
+ *selectedSuffixOut = selectedSuffix;
+ }
+ return result;
+}
+
diff --git a/src/qt/guiutil.h b/src/qt/guiutil.h
index e63e6aa45d..a7eee0990b 100644
--- a/src/qt/guiutil.h
+++ b/src/qt/guiutil.h
@@ -32,6 +32,21 @@ public:
// See Bitcoin URL definition discussion here: https://bitcointalk.org/index.php?topic=33490.0
static bool parseBitcoinURL(const QUrl *url, SendCoinsRecipient *out);
static bool parseBitcoinURL(QString url, SendCoinsRecipient *out);
+
+ /** Get save file name, mimics QFileDialog::getSaveFileName, except that it appends a default suffix
+ when no suffix is provided by the user.
+
+ @param[in] parent Parent window (or 0)
+ @param[in] caption Window caption (or empty, for default)
+ @param[in] dir Starting directory (or empty, to default to documents directory)
+ @param[in] filter Filter specification such as "Comma Separated Files (*.csv)"
+ @param[out] selectedSuffixOut Pointer to return the suffix (file type) that was selected (or 0).
+ Can be useful when choosing the save file format based on suffix.
+ */
+ static QString getSaveFileName(QWidget *parent=0, const QString &caption=QString(),
+ const QString &dir=QString(), const QString &filter=QString(),
+ QString *selectedSuffixOut=0);
+
};
#endif // GUIUTIL_H
diff --git a/src/qt/transactionview.cpp b/src/qt/transactionview.cpp
index 3ef31854fb..0bfce351a4 100644
--- a/src/qt/transactionview.cpp
+++ b/src/qt/transactionview.cpp
@@ -20,7 +20,6 @@
#include <QTableView>
#include <QHeaderView>
#include <QPushButton>
-#include <QFileDialog>
#include <QMessageBox>
#include <QPoint>
#include <QMenu>
@@ -265,10 +264,9 @@ void TransactionView::changedAmount(const QString &amount)
void TransactionView::exportClicked()
{
// CSV is currently the only supported format
- QString filename = QFileDialog::getSaveFileName(
+ QString filename = GUIUtil::getSaveFileName(
this,
- tr("Export Transaction Data"),
- QDir::currentPath(),
+ tr("Export Transaction Data"), QString(),
tr("Comma separated file (*.csv)"));
if (filename.isNull()) return;