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
31 changes: 14 additions & 17 deletions src/assets/assets.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -927,30 +927,29 @@ bool CAssetsCache::TrySpendCoin(const COutPoint& out, const CTxOut& txOut)
CAmount nAmount = -1;

// Get the asset tx data
int nType = 0;
int nType = -1;
bool fIsOwner = false;
if (txOut.scriptPubKey.IsAssetScript(nType, fIsOwner)) {
txnouttype type = (txnouttype)nType;

// Get the New Asset or Transfer Asset from the scriptPubKey
if (type == TX_NEW_ASSET && !fIsOwner) {
if (nType == TX_NEW_ASSET && !fIsOwner) {
CNewAsset asset;
if (AssetFromScript(txOut.scriptPubKey, asset, address)) {
assetName = asset.strName;
nAmount = asset.nAmount;
}
} else if (type == TX_TRANSFER_ASSET) {
} else if (nType == TX_TRANSFER_ASSET) {
CAssetTransfer transfer;
if (TransferAssetFromScript(txOut.scriptPubKey, transfer, address)) {
assetName = transfer.strName;
nAmount = transfer.nAmount;
}
} else if (type == TX_NEW_ASSET && fIsOwner) {
} else if (nType == TX_NEW_ASSET && fIsOwner) {
if (!OwnerAssetFromScript(txOut.scriptPubKey, assetName, address))
return error("%s : ERROR Failed to get owner asset from the OutPoint: %s", __func__,
out.ToString());
nAmount = OWNER_ASSET_AMOUNT;
} else if (type == TX_REISSUE_ASSET) {
} else if (nType == TX_REISSUE_ASSET) {
CReissueAsset reissue;
if (ReissueAssetFromScript(txOut.scriptPubKey, reissue, address)) {
assetName = reissue.strName;
Expand Down Expand Up @@ -1045,13 +1044,11 @@ bool CAssetsCache::UndoAssetCoin(const Coin& coin, const COutPoint& out)
CAmount nAmount = 0;

// Get the asset tx from the script
txnouttype type;
int nType = 0;
int nType = -1;
bool fIsOwner = false;
if(coin.out.scriptPubKey.IsAssetScript(nType, fIsOwner)) {
type = (txnouttype) nType;

if (type == TX_NEW_ASSET && !fIsOwner) {
if (nType == TX_NEW_ASSET && !fIsOwner) {
CNewAsset asset;
if (!AssetFromScript(coin.out.scriptPubKey, asset, strAddress)) {
return error("%s : Failed to get asset from script while trying to undo asset spend. OutPoint : %s",
Expand All @@ -1061,7 +1058,7 @@ bool CAssetsCache::UndoAssetCoin(const Coin& coin, const COutPoint& out)
assetName = asset.strName;

nAmount = asset.nAmount;
} else if (type == TX_TRANSFER_ASSET) {
} else if (nType == TX_TRANSFER_ASSET) {
CAssetTransfer transfer;
if (!TransferAssetFromScript(coin.out.scriptPubKey, transfer, strAddress))
return error(
Expand All @@ -1071,15 +1068,15 @@ bool CAssetsCache::UndoAssetCoin(const Coin& coin, const COutPoint& out)

assetName = transfer.strName;
nAmount = transfer.nAmount;
} else if (type == TX_NEW_ASSET && fIsOwner) {
} else if (nType == TX_NEW_ASSET && fIsOwner) {
std::string ownerName;
if (!OwnerAssetFromScript(coin.out.scriptPubKey, ownerName, strAddress))
return error(
"%s : Failed to get owner asset from script while trying to undo asset spend. OutPoint : %s",
__func__, out.ToString());
assetName = ownerName;
nAmount = OWNER_ASSET_AMOUNT;
} else if (type == TX_REISSUE_ASSET) {
} else if (nType == TX_REISSUE_ASSET) {
CReissueAsset reissue;
if (!ReissueAssetFromScript(coin.out.scriptPubKey, reissue, strAddress))
return error(
Expand Down Expand Up @@ -1808,7 +1805,7 @@ bool IsScriptNewAsset(const CScript& scriptPubKey, int& nStartingIndex)
int nType = 0;
bool fIsOwner =false;
if (scriptPubKey.IsAssetScript(nType, fIsOwner, nStartingIndex)) {
return (txnouttype)nType == TX_NEW_ASSET && !fIsOwner;
return nType == TX_NEW_ASSET && !fIsOwner;
}

return false;
Expand Down Expand Up @@ -1851,7 +1848,7 @@ bool IsScriptOwnerAsset(const CScript& scriptPubKey, int& nStartingIndex)
int nType = 0;
bool fIsOwner =false;
if (scriptPubKey.IsAssetScript(nType, fIsOwner, nStartingIndex)) {
return (txnouttype)nType == TX_NEW_ASSET && fIsOwner;
return nType == TX_NEW_ASSET && fIsOwner;
}

return false;
Expand All @@ -1868,7 +1865,7 @@ bool IsScriptReissueAsset(const CScript& scriptPubKey, int& nStartingIndex)
int nType = 0;
bool fIsOwner =false;
if (scriptPubKey.IsAssetScript(nType, fIsOwner, nStartingIndex)) {
return (txnouttype)nType == TX_REISSUE_ASSET;
return nType == TX_REISSUE_ASSET;
}

return false;
Expand All @@ -1885,7 +1882,7 @@ bool IsScriptTransferAsset(const CScript& scriptPubKey, int& nStartingIndex)
int nType = 0;
bool fIsOwner =false;
if (scriptPubKey.IsAssetScript(nType, fIsOwner, nStartingIndex)) {
return (txnouttype)nType == TX_TRANSFER_ASSET;
return nType == TX_TRANSFER_ASSET;
}

return false;
Expand Down
2 changes: 1 addition & 1 deletion src/coins.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -162,7 +162,7 @@ void AddCoins(CCoinsViewCache& cache, const CTransaction &tx, int nHeight, bool
error("%s: Failed to add an reissued asset I own to my Unspent Asset Cache. Asset Name : %s",
__func__, reissue.strName);
} else if (tx.IsNewUniqueAsset()) {
for (int n = 0; n < tx.vout.size(); n++) {
for (int n = 0; n < (int)tx.vout.size(); n++) {
auto out = tx.vout[n];

CNewAsset asset;
Expand Down
2 changes: 1 addition & 1 deletion src/consensus/tx_verify.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -203,7 +203,7 @@ bool CheckTransaction(const CTransaction& tx, CValidationState &state, CAssetsCa
if (AreAssetsDeployed() && isAsset) {
if (assetCache) {
// Get the transfer transaction data from the scriptPubKey
if ((txnouttype) nType == TX_TRANSFER_ASSET) {
if ( nType == TX_TRANSFER_ASSET) {
CAssetTransfer transfer;
std::string address;
if (!TransferAssetFromScript(txout.scriptPubKey, transfer, address))
Expand Down
5 changes: 3 additions & 2 deletions src/qt/ravengui.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -117,6 +117,7 @@ RavenGUI::RavenGUI(const PlatformStyle *_platformStyle, const NetworkStyle *netw
openRPCConsoleAction(0),
openAction(0),
showHelpMessageAction(0),
assetAction(0),
trayIcon(0),
trayIconMenu(0),
notificator(0),
Expand All @@ -125,8 +126,8 @@ RavenGUI::RavenGUI(const PlatformStyle *_platformStyle, const NetworkStyle *netw
modalOverlay(0),
prevBlocks(0),
spinnerFrame(0),
platformStyle(_platformStyle),
assetAction(0)
platformStyle(_platformStyle)

{
QSettings settings;
if (!restoreGeometry(settings.value("MainWindowGeometry").toByteArray())) {
Expand Down
2 changes: 1 addition & 1 deletion src/rpc/assets.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -300,7 +300,7 @@ UniValue issueunique(const JSONRPCRequest& request)
}

std::vector<CNewAsset> assets;
for (int i = 0; i < assetTags.size(); i++) {
for (int i = 0; i < (int)assetTags.size(); i++) {
std::string tag = assetTags[i].get_str();

if (!IsUniqueTagValid(tag)) {
Expand Down
2 changes: 1 addition & 1 deletion src/rpc/rawtransaction.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -633,7 +633,7 @@ UniValue createrawtransaction(const JSONRPCRequest& request)
rawTx.vout.push_back(out);

// Create the assets
for (int i = 0; i < asset_tags.size(); i++) {
for (int i = 0; i < (int)asset_tags.size(); i++) {

// Create a new asset
CNewAsset asset;
Expand Down
2 changes: 1 addition & 1 deletion src/validation.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1734,7 +1734,7 @@ static DisconnectResult DisconnectBlock(const CBlock& block, const CBlockIndex*
}
}
} else if (tx.IsNewUniqueAsset()) {
for (int n = 0; n < tx.vout.size(); n++) {
for (int n = 0; n < (int)tx.vout.size(); n++) {
auto out = tx.vout[n];
CNewAsset asset;
std::string strAddress;
Expand Down
20 changes: 9 additions & 11 deletions src/wallet/wallet.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2291,22 +2291,22 @@ void CWallet::AvailableCoinsAll(std::vector<COutput>& vCoins, std::map<std::stri
// Looking for Asset Tx OutPoints Only
if (fGetAssets && AreAssetsDeployed() && pcoin->tx->vout[i].scriptPubKey.IsAssetScript(nType, fIsOwner)) {

if ((txnouttype) nType == TX_TRANSFER_ASSET) {
if ( nType == TX_TRANSFER_ASSET) {
if (TransferAssetFromScript(pcoin->tx->vout[i].scriptPubKey, assetTransfer, address)) {
strAssetName = assetTransfer.strName;
fWasTransferAssetOutPoint = true;
}
} else if ((txnouttype) nType == TX_NEW_ASSET && !fIsOwner) {
} else if ( nType == TX_NEW_ASSET && !fIsOwner) {
if (AssetFromScript(pcoin->tx->vout[i].scriptPubKey, asset, address)) {
strAssetName = asset.strName;
fWasNewAssetOutPoint = true;
}
} else if ((txnouttype) nType == TX_NEW_ASSET && fIsOwner) {
} else if ( nType == TX_NEW_ASSET && fIsOwner) {
if (OwnerAssetFromScript(pcoin->tx->vout[i].scriptPubKey, ownerName, address)) {
strAssetName = ownerName;
fWasOwnerAssetOutPoint = true;
}
} else if ((txnouttype) nType == TX_REISSUE_ASSET) {
} else if ( nType == TX_REISSUE_ASSET) {
if (ReissueAssetFromScript(pcoin->tx->vout[i].scriptPubKey, reissue, address)) {
strAssetName = reissue.strName;
fWasReissueAssetOutPoint = true;
Expand Down Expand Up @@ -2808,36 +2808,34 @@ bool CWallet::SelectAssetsMinConf(const CAmount& nTargetValue, const int nConfMi

//-------------------------------

int nType = 0;
int nType = -1;
bool fIsOwner = false;
if (!coin.txout.scriptPubKey.IsAssetScript(nType, fIsOwner)) {
// TODO - Remove std::cout this before mainnet release
std::cout << "This shouldn't be occuring: Non Asset Script pub key made it to the SelectAssetsMinConf function call. Look into this!" << std::endl;
continue;
}

txnouttype type = (txnouttype) nType;

CAmount nTempAmount = 0;
if (type == TX_NEW_ASSET && !fIsOwner) { // Root/Sub Asset
if (nType == TX_NEW_ASSET && !fIsOwner) { // Root/Sub Asset
CNewAsset assetTemp;
std::string address;
if (!AssetFromScript(coin.txout.scriptPubKey, assetTemp, address))
continue;
nTempAmount = assetTemp.nAmount;
} else if (type == TX_TRANSFER_ASSET) { // Transfer Asset
} else if (nType == TX_TRANSFER_ASSET) { // Transfer Asset
CAssetTransfer transferTemp;
std::string address;
if (!TransferAssetFromScript(coin.txout.scriptPubKey, transferTemp, address))
continue;
nTempAmount = transferTemp.nAmount;
} else if (type == TX_NEW_ASSET && fIsOwner) { // Owner Asset
} else if (nType == TX_NEW_ASSET && fIsOwner) { // Owner Asset
std::string ownerName;
std::string address;
if (!OwnerAssetFromScript(coin.txout.scriptPubKey, ownerName, address))
continue;
nTempAmount = OWNER_ASSET_AMOUNT;
} else if (type == TX_REISSUE_ASSET) { // Reissue Asset
} else if (nType == TX_REISSUE_ASSET) { // Reissue Asset
CReissueAsset reissueTemp;
std::string address;
if (!ReissueAssetFromScript(coin.txout.scriptPubKey, reissueTemp, address))
Expand Down