From a7f6211208c32ca0c095a8ce235715cc2942eb3b Mon Sep 17 00:00:00 2001 From: myriadcoin Date: Wed, 24 Sep 2014 21:10:34 +0200 Subject: [PATCH] Stealth addresses --- src/main.cpp | 20 ++++++++++++++++---- src/main.h | 3 +++ src/qt/walletmodel.cpp | 9 ++++++++- src/wallet.cpp | 7 +++++++ 4 files changed, 34 insertions(+), 5 deletions(-) diff --git a/src/main.cpp b/src/main.cpp index 8188706b..5949a23d 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -559,11 +559,23 @@ bool IsStandardTx(const CTransaction& tx, string& reason) } } - // allow one OP_RETURN per txout - if (nDataOut > nTxnOut) + if (chainActive.Height() < BLOCK_STEALTH_START) { - reason = "multi-op-return"; - return false; + // allow one OP_RETURN per transaction + if (nDataOut > 1) + { + reason = "multi-op-return"; + return false; + } + } + else + { + // allow one OP_RETURN per txout + if (nDataOut > nTxnOut) + { + reason = "multi-op-return"; + return false; + } } return true; diff --git a/src/main.h b/src/main.h index bec0ac32..b111aa91 100644 --- a/src/main.h +++ b/src/main.h @@ -67,6 +67,9 @@ static const int MAX_BLOCKS_IN_TRANSIT_PER_PEER = 128; /** Timeout in seconds before considering a block download peer unresponsive. */ static const unsigned int BLOCK_DOWNLOAD_TIMEOUT = 60; +/** Stealth addresses */ +static const int BLOCK_STEALTH_START = 633800; + #ifdef USE_UPNP static const int fHaveUPnP = true; #else diff --git a/src/qt/walletmodel.cpp b/src/qt/walletmodel.cpp index eb8f68b5..4f020796 100644 --- a/src/qt/walletmodel.cpp +++ b/src/qt/walletmodel.cpp @@ -227,6 +227,13 @@ WalletModel::SendCoinsReturn WalletModel::prepareTransaction(WalletModelTransact if (rcp.typeInd == AddressTableModel::AT_Stealth) { + if (chainActive.Height() < BLOCK_STEALTH_START) + { + emit message(tr("Send Coins"), tr("Stealth addresses not yet supported"), + CClientUIInterface::MSG_ERROR); + return InvalidAddress; + } + CStealthAddress sxAddr; if (sxAddr.SetEncoded(sAddr)) { @@ -320,7 +327,7 @@ WalletModel::SendCoinsReturn WalletModel::prepareTransaction(WalletModelTransact CWalletTx *newTx = transaction.getTransaction(); CReserveKey *keyChange = transaction.getPossibleKeyChange(); - int nChangePos = -1; + // int nChangePos = -1; bool fCreated = wallet->CreateTransaction(vecSend, *newTx, *keyChange, nFeeRequired, /*nChangePos,*/ strFailReason, coinControl); /* diff --git a/src/wallet.cpp b/src/wallet.cpp index a594cdef..2fa5478c 100644 --- a/src/wallet.cpp +++ b/src/wallet.cpp @@ -1834,6 +1834,13 @@ string CWallet::SendStealthMoney(CScript scriptPubKey, int64_t nValue, std::vect CReserveKey reservekey(this); int64_t nFeeRequired; + if (chainActive.Height() < BLOCK_STEALTH_START) + { + string strError = _("Error: Stealth addresses not yet supported"); + LogPrintf("SendStealthMoney() : %s", strError.c_str()); + return strError; + } + if (IsLocked()) { string strError = _("Error: Wallet locked, unable to create transaction ");