Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions src/Makefile.qt.include
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,7 @@ QT_TS = \
QT_FORMS_UI = \
qt/forms/addressbookpage.ui \
qt/forms/askpassphrasedialog.ui \
qt/forms/assetcontroldialog.ui \
qt/forms/coincontroldialog.ui \
qt/forms/editaddressdialog.ui \
qt/forms/helpmessagedialog.ui \
Expand All @@ -122,6 +123,8 @@ QT_MOC_CPP = \
qt/moc_addressbookpage.cpp \
qt/moc_addresstablemodel.cpp \
qt/moc_askpassphrasedialog.cpp \
qt/moc_assetcontroldialog.cpp \
qt/moc_assetcontroltreewidget.cpp \
qt/moc_bantablemodel.cpp \
qt/moc_ravenaddressvalidator.cpp \
qt/moc_ravenamountfield.cpp \
Expand Down Expand Up @@ -196,6 +199,8 @@ RAVEN_QT_H = \
qt/addressbookpage.h \
qt/addresstablemodel.h \
qt/askpassphrasedialog.h \
qt/assetcontroldialog.h \
qt/assetcontroltreewidget.h \
qt/assetsdialog.h \
qt/createassetdialog.h \
qt/bantablemodel.h \
Expand Down Expand Up @@ -343,6 +348,8 @@ RAVEN_QT_WALLET_CPP = \
qt/addressbookpage.cpp \
qt/addresstablemodel.cpp \
qt/askpassphrasedialog.cpp \
qt/assetcontroldialog.cpp \
qt/assetcontroltreewidget.cpp \
qt/assetsdialog.cpp \
qt/createassetdialog.cpp \
qt/coincontroldialog.cpp \
Expand Down
37 changes: 27 additions & 10 deletions src/assets/assets.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -255,7 +255,7 @@ bool CNewAsset::IsValid(std::string& strError, CAssetsCache& assetCache, bool fC
}

if (nAmount > MAX_MONEY) {
strError = "Invalid parameter: asset amount greater than max money: " + MAX_MONEY / COIN;
strError = "Invalid parameter: asset amount greater than max money: " + std::to_string(MAX_MONEY / COIN);
return false;
}

Expand Down Expand Up @@ -1976,7 +1976,15 @@ void GetAssetData(const CScript& script, CAssetOutputEntry& data)
}
}

void GetAllOwnedAssets(CWallet* pwallet, std::vector<std::string>& names)
void GetAllAdministrativeAssets(CWallet *pwallet, std::vector<std::string> &names)
{
if(!pwallet)
return;

GetAllMyAssets(pwallet, names, true, true);
}

void GetAllMyAssets(CWallet* pwallet, std::vector<std::string>& names, bool fIncludeAdministrator, bool fOnlyAdministrator)
{
if(!pwallet)
return;
Expand All @@ -1985,16 +1993,27 @@ void GetAllOwnedAssets(CWallet* pwallet, std::vector<std::string>& names)
pwallet->AvailableAssets(mapAssets);

for (auto item : mapAssets) {
if (IsAssetNameAnOwner(item.first))
bool isOwner = IsAssetNameAnOwner(item.first);

if (isOwner) {
if (fOnlyAdministrator || fIncludeAdministrator)
names.emplace_back(item.first);
} else {
if (fOnlyAdministrator)
continue;
names.emplace_back(item.first);
}
}
}

void GetAllMyAssets(std::vector<std::string>& names)
void GetAllMyAssetsFromCache(std::vector<std::string>& names)
{
for (auto owned : passets->mapMyUnspentAssets) {
if (!passets)
return;

for (auto owned : passets->mapMyUnspentAssets)
names.emplace_back(owned.first);
}

}

CAmount GetIssueAssetBurnAmount()
Expand Down Expand Up @@ -2391,7 +2410,7 @@ bool CreateReissueAssetTransaction(CWallet* pwallet, const CReissueAsset& reissu
return true;
}

bool CreateTransferAssetTransaction(CWallet* pwallet, const std::vector< std::pair<CAssetTransfer, std::string> >vTransfers, const std::string& changeAddress, std::pair<int, std::string>& error, CWalletTx& wtxNew, CReserveKey& reservekey, CAmount& nFeeRequired)
bool CreateTransferAssetTransaction(CWallet* pwallet, const CCoinControl& coinControl, const std::vector< std::pair<CAssetTransfer, std::string> >vTransfers, const std::string& changeAddress, std::pair<int, std::string>& error, CWalletTx& wtxNew, CReserveKey& reservekey, CAmount& nFeeRequired)
{
// Initialize Values for transaction
std::string strTxError;
Expand Down Expand Up @@ -2451,10 +2470,8 @@ bool CreateTransferAssetTransaction(CWallet* pwallet, const std::vector< std::pa
vecSend.push_back(recipient);
}

CCoinControl coin_control;

// Create and send the transaction
if (!pwallet->CreateTransactionWithTransferAsset(vecSend, wtxNew, reservekey, nFeeRequired, nChangePosRet, strTxError, coin_control)) {
if (!pwallet->CreateTransactionWithTransferAsset(vecSend, wtxNew, reservekey, nFeeRequired, nChangePosRet, strTxError, coinControl)) {
if (!fSubtractFeeFromAmount && nFeeRequired > curBalance) {
error = std::make_pair(RPC_WALLET_ERROR, strprintf("Error: This transaction requires a transaction fee of at least %s", FormatMoney(nFeeRequired)));
return false;
Expand Down
9 changes: 6 additions & 3 deletions src/assets/assets.h
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ class CWallet;
class CReserveKey;
class CWalletTx;
struct CAssetOutputEntry;
class CCoinControl;

// 50000 * 82 Bytes == 4.1 Mb
#define MAX_CACHE_ASSETS_SIZE 50000
Expand Down Expand Up @@ -345,8 +346,10 @@ bool IsScriptTransferAsset(const CScript& scriptPubKey);

bool IsNewOwnerTxValid(const CTransaction& tx, const std::string& assetName, const std::string& address, std::string& errorMsg);

void GetAllOwnedAssets(CWallet* pwallet, std::vector<std::string>& names);
void GetAllMyAssets(std::vector<std::string>& names);
void GetAllAdministrativeAssets(CWallet *pwallet, std::vector<std::string> &names);
void GetAllMyAssets(CWallet* pwallet, std::vector<std::string>& names, bool fIncludeAdministrator = false, bool fOnlyAdministrator = false);
/** TO BE USED ONLY ON STARTUP */
void GetAllMyAssetsFromCache(std::vector<std::string>& names);

void UpdatePossibleAssets();

Expand All @@ -371,6 +374,6 @@ std::string EncodeIPFS(std::string decoded);

bool CreateAssetTransaction(CWallet* pwallet, const CNewAsset& asset, const std::string& address, std::pair<int, std::string>& error, std::string& rvnChangeAddress, CWalletTx& wtxNew, CReserveKey& reservekey, CAmount& nFeeRequired);
bool CreateReissueAssetTransaction(CWallet* pwallet, const CReissueAsset& asset, const std::string& address, const std::string& changeAddress, std::pair<int, std::string>& error, CWalletTx& wtxNew, CReserveKey& reservekey, CAmount& nFeeRequired);
bool CreateTransferAssetTransaction(CWallet* pwallet, const std::vector< std::pair<CAssetTransfer, std::string> >vTransfers, const std::string& changeAddress, std::pair<int, std::string>& error, CWalletTx& wtxNew, CReserveKey& reservekey, CAmount& nFeeRequired);
bool CreateTransferAssetTransaction(CWallet* pwallet, const CCoinControl& coinControl, const std::vector< std::pair<CAssetTransfer, std::string> >vTransfers, const std::string& changeAddress, std::pair<int, std::string>& error, CWalletTx& wtxNew, CReserveKey& reservekey, CAmount& nFeeRequired);
bool SendAssetTransaction(CWallet* pwallet, CWalletTx& transaction, CReserveKey& reserveKey, std::pair<int, std::string>& error, std::string& txid);
#endif //RAVENCOIN_ASSET_PROTOCOL_H
Loading