Browse Source

Fixed namespace creation crash when there is insufficient fund.

views
Just Wonder 5 years ago
parent
commit
a13b6aa276
  1. 3
      src/qt/kevadialog.cpp
  2. 32
      src/qt/locale/bitcoin_en.ts
  3. 4
      src/qt/locale/bitcoin_zh_CN.ts
  4. 15
      src/qt/walletmodel.cpp
  5. 1
      src/qt/walletmodel.h

3
src/qt/kevadialog.cpp

@ -457,6 +457,9 @@ int KevaDialog::createNamespace(std::string displayName, std::string& namespaceI
case WalletModel::NamespaceTooLong: case WalletModel::NamespaceTooLong:
msg = tr("Namespace too long \"%1\"").arg(QString::fromStdString(displayName)); msg = tr("Namespace too long \"%1\"").arg(QString::fromStdString(displayName));
break; break;
case WalletModel::InsufficientFund:
msg = tr("Insufficient funds");
break;
default: default:
msg = tr("Unknown error."); msg = tr("Unknown error.");
} }

32
src/qt/locale/bitcoin_en.ts

@ -1181,7 +1181,12 @@
<context> <context>
<name>KevaBookmarksDialog</name> <name>KevaBookmarksDialog</name>
<message> <message>
<location filename="../kevabookmarksdialog.cpp" line="+23"/> <location filename="../kevabookmarksdialog.cpp" line="+22"/>
<source>&amp;Show</source>
<translation type="unfinished"></translation>
</message>
<message>
<location line="+2"/>
<source>&amp;Edit</source> <source>&amp;Edit</source>
<translation type="unfinished"></translation> <translation type="unfinished"></translation>
</message> </message>
@ -1215,7 +1220,7 @@
<context> <context>
<name>KevaDialog</name> <name>KevaDialog</name>
<message> <message>
<location filename="../forms/kevadialog.ui" line="+267"/> <location filename="../forms/kevadialog.ui" line="+271"/>
<source>Show the selected request (does the same as double clicking an entry)</source> <source>Show the selected request (does the same as double clicking an entry)</source>
<translation type="unfinished"></translation> <translation type="unfinished"></translation>
</message> </message>
@ -1226,8 +1231,8 @@
<translation type="unfinished"></translation> <translation type="unfinished"></translation>
</message> </message>
<message> <message>
<location line="-234"/> <location line="-238"/>
<location line="+44"/> <location line="+48"/>
<source>The namespace ID with a prefix &quot;N&quot;.</source> <source>The namespace ID with a prefix &quot;N&quot;.</source>
<translation type="unfinished"></translation> <translation type="unfinished"></translation>
</message> </message>
@ -1327,7 +1332,7 @@
<translation type="unfinished"></translation> <translation type="unfinished"></translation>
</message> </message>
<message> <message>
<location line="+259"/> <location line="+262"/>
<source>Warning</source> <source>Warning</source>
<translation type="unfinished">Warning</translation> <translation type="unfinished">Warning</translation>
</message> </message>
@ -1348,23 +1353,28 @@
</message> </message>
<message> <message>
<location line="+3"/> <location line="+3"/>
<location line="+122"/> <location line="+125"/>
<location line="+28"/> <location line="+28"/>
<source>Unknown error.</source> <source>Unknown error.</source>
<translation type="unfinished"></translation> <translation type="unfinished"></translation>
</message> </message>
<message> <message>
<location line="-148"/> <location line="-151"/>
<location line="+122"/> <location line="+125"/>
<location line="+28"/> <location line="+28"/>
<source>Error</source> <source>Error</source>
<translation type="unfinished">Error</translation> <translation type="unfinished">Error</translation>
</message> </message>
<message> <message>
<location line="-33"/> <location line="-36"/>
<source>Namespace too long &quot;%1&quot;</source> <source>Namespace too long &quot;%1&quot;</source>
<translation type="unfinished"></translation> <translation type="unfinished"></translation>
</message> </message>
<message>
<location line="+3"/>
<source>Insufficient funds</source>
<translation type="unfinished">Insufficient funds</translation>
</message>
<message> <message>
<location line="+22"/> <location line="+22"/>
<source>Cannot add key-value. Make sure you own this namespace.</source> <source>Cannot add key-value. Make sure you own this namespace.</source>
@ -1461,7 +1471,7 @@
<translation type="unfinished"></translation> <translation type="unfinished"></translation>
</message> </message>
<message> <message>
<location line="+88"/> <location line="+86"/>
<source>Requested</source> <source>Requested</source>
<translation type="unfinished"></translation> <translation type="unfinished"></translation>
</message> </message>
@ -4196,7 +4206,7 @@
<context> <context>
<name>WalletModel</name> <name>WalletModel</name>
<message> <message>
<location filename="../walletmodel.cpp" line="+304"/> <location filename="../walletmodel.cpp" line="+306"/>
<source>Send Coins</source> <source>Send Coins</source>
<translation type="unfinished">Send Coins</translation> <translation type="unfinished">Send Coins</translation>
</message> </message>

4
src/qt/locale/bitcoin_zh_CN.ts

@ -1065,6 +1065,10 @@
<source>Namespace too long &quot;%1&quot;</source> <source>Namespace too long &quot;%1&quot;</source>
<translation><numerusform>: &quot;%1&quot;</numerusform></translation> <translation><numerusform>: &quot;%1&quot;</numerusform></translation>
</message> </message>
<message>
<source>Insufficient funds</source>
<translation></translation>
</message>
<message> <message>
<source>Cannot add key-value. Make sure you own this namespace.</source> <source>Cannot add key-value. Make sure you own this namespace.</source>
<translation></translation> <translation></translation>

15
src/qt/walletmodel.cpp

@ -19,6 +19,8 @@
#include <base58.h> #include <base58.h>
#include <chain.h> #include <chain.h>
#include <univalue.h>
#include <rpc/protocol.h>
#include <keystore.h> #include <keystore.h>
#include <keva/common.h> #include <keva/common.h>
#include <keva/main.h> #include <keva/main.h>
@ -915,8 +917,17 @@ int WalletModel::createNamespace(std::string displayNameStr, std::string& namesp
CCoinControl coinControl; CCoinControl coinControl;
CWalletTx wtx; CWalletTx wtx;
valtype kevaNamespace; valtype kevaNamespace;
SendMoneyToScript(wallet, newScript, nullptr, kevaNamespace, try {
KEVA_LOCKED_AMOUNT, false, wtx, coinControl); SendMoneyToScript(wallet, newScript, nullptr, kevaNamespace,
KEVA_LOCKED_AMOUNT, false, wtx, coinControl);
} catch (const UniValue& objError) {
UniValue code = objError["code"];
if (code.get_int() == RPC_WALLET_INSUFFICIENT_FUNDS) {
return WalletModel::InsufficientFund;
}
return WalletModel::CannotUpdate;
}
keyName.KeepKey(); keyName.KeepKey();
namespaceId = EncodeBase58Check(kevaNamespace); namespaceId = EncodeBase58Check(kevaNamespace);

1
src/qt/walletmodel.h

@ -131,6 +131,7 @@ public:
KeyNotFound, KeyNotFound,
ValueTooLong, ValueTooLong,
CannotUpdate, CannotUpdate,
InsufficientFund,
}; };
enum EncryptionStatus enum EncryptionStatus

Loading…
Cancel
Save