Browse Source

Fixed namespace creation crash when there is insufficient fund.

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

32
src/qt/locale/bitcoin_en.ts

@ -1181,7 +1181,12 @@ @@ -1181,7 +1181,12 @@
<context>
<name>KevaBookmarksDialog</name>
<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>
<translation type="unfinished"></translation>
</message>
@ -1215,7 +1220,7 @@ @@ -1215,7 +1220,7 @@
<context>
<name>KevaDialog</name>
<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>
<translation type="unfinished"></translation>
</message>
@ -1226,8 +1231,8 @@ @@ -1226,8 +1231,8 @@
<translation type="unfinished"></translation>
</message>
<message>
<location line="-234"/>
<location line="+44"/>
<location line="-238"/>
<location line="+48"/>
<source>The namespace ID with a prefix &quot;N&quot;.</source>
<translation type="unfinished"></translation>
</message>
@ -1327,7 +1332,7 @@ @@ -1327,7 +1332,7 @@
<translation type="unfinished"></translation>
</message>
<message>
<location line="+259"/>
<location line="+262"/>
<source>Warning</source>
<translation type="unfinished">Warning</translation>
</message>
@ -1348,23 +1353,28 @@ @@ -1348,23 +1353,28 @@
</message>
<message>
<location line="+3"/>
<location line="+122"/>
<location line="+125"/>
<location line="+28"/>
<source>Unknown error.</source>
<translation type="unfinished"></translation>
</message>
<message>
<location line="-148"/>
<location line="+122"/>
<location line="-151"/>
<location line="+125"/>
<location line="+28"/>
<source>Error</source>
<translation type="unfinished">Error</translation>
</message>
<message>
<location line="-33"/>
<location line="-36"/>
<source>Namespace too long &quot;%1&quot;</source>
<translation type="unfinished"></translation>
</message>
<message>
<location line="+3"/>
<source>Insufficient funds</source>
<translation type="unfinished">Insufficient funds</translation>
</message>
<message>
<location line="+22"/>
<source>Cannot add key-value. Make sure you own this namespace.</source>
@ -1461,7 +1471,7 @@ @@ -1461,7 +1471,7 @@
<translation type="unfinished"></translation>
</message>
<message>
<location line="+88"/>
<location line="+86"/>
<source>Requested</source>
<translation type="unfinished"></translation>
</message>
@ -4196,7 +4206,7 @@ @@ -4196,7 +4206,7 @@
<context>
<name>WalletModel</name>
<message>
<location filename="../walletmodel.cpp" line="+304"/>
<location filename="../walletmodel.cpp" line="+306"/>
<source>Send Coins</source>
<translation type="unfinished">Send Coins</translation>
</message>

4
src/qt/locale/bitcoin_zh_CN.ts

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

15
src/qt/walletmodel.cpp

@ -19,6 +19,8 @@ @@ -19,6 +19,8 @@
#include <base58.h>
#include <chain.h>
#include <univalue.h>
#include <rpc/protocol.h>
#include <keystore.h>
#include <keva/common.h>
#include <keva/main.h>
@ -915,8 +917,17 @@ int WalletModel::createNamespace(std::string displayNameStr, std::string& namesp @@ -915,8 +917,17 @@ int WalletModel::createNamespace(std::string displayNameStr, std::string& namesp
CCoinControl coinControl;
CWalletTx wtx;
valtype kevaNamespace;
SendMoneyToScript(wallet, newScript, nullptr, kevaNamespace,
KEVA_LOCKED_AMOUNT, false, wtx, coinControl);
try {
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();
namespaceId = EncodeBase58Check(kevaNamespace);

1
src/qt/walletmodel.h

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

Loading…
Cancel
Save