Skip to content

Commit

Permalink
Merge pull request #148 from BlockMechanic/segwit
Browse files Browse the repository at this point in the history
Segwit
  • Loading branch information
BlockMechanic authored Oct 24, 2022
2 parents f0408ce + 9b543d5 commit f21aba7
Show file tree
Hide file tree
Showing 6 changed files with 26 additions and 24 deletions.
3 changes: 2 additions & 1 deletion src/assetdb.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -200,10 +200,11 @@ std::vector<CAsset> GetAllAssets(){
return tmp;
}

bool assetExists(CAsset assetToCheck){
bool assetExists(CAsset assetToCheck, uint256 &txhash){

for(auto const& x : passetsCache->GetItemsMap()){
CAsset checkasset = x.second->second.asset;
txhash = x.second->second.txhash;

if(checkasset == assetToCheck)
return true;
Expand Down
2 changes: 1 addition & 1 deletion src/assetdb.h
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ void DumpAssets();

CAsset GetAsset(const std::string& name);
std::vector<CAsset> GetAllAssets();
bool assetExists(CAsset assetToCheck);
bool assetExists(CAsset assetToCheck, uint256 &txhash);
bool assetNameExists(std::string assetName);
bool isSubsidy(CAsset assetToCheck);
CAsset GetSubsidyAsset();
Expand Down
7 changes: 4 additions & 3 deletions src/consensus/tx_verify.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -235,14 +235,15 @@ bool Consensus::CheckTxInputs(const CTransaction& tx, TxValidationState& state,

for(auto & a : outputAssets){
CAsset asset = a.first;
bool exists = assetExists(asset);
uint256 thash = uint256();
bool exists = assetExists(asset, thash);

//Asset exists , check for output rules
if (exists && asset != subsidy_asset) {
// check asset limited

if(asset.isLimited() && inputAssets.begin()->first != asset)
return state.Invalid(TxValidationResult::TX_CONSENSUS, "bad-txns-output-asset-is-limited", strprintf("cannot convert other assets to (%s)", asset.getAssetName()));
if(asset.isLimited() && inputAssets.begin()->first != asset && thash != tx.GetHash())
return state.Invalid(TxValidationResult::TX_CONSENSUS, "bad-txns-output-asset-is-limited", strprintf("cannot convert other assets to (%s)", asset.getAssetName()));

// check asset restricted
// get contract hash, retrieve contract, get issuer , compare input address to issueraddress
Expand Down
4 changes: 2 additions & 2 deletions src/init.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2196,8 +2196,8 @@ bool AppInitMain(const util::Ref& context, NodeContext& node, interfaces::BlockA
DumpContracts();
}, DUMP_BANS_INTERVAL);

node.scheduler->scheduleEvery(std::bind(&ThreadNodeSync, std::ref(*node.connman)), std::chrono::milliseconds{1000});
node.scheduler->scheduleEvery(std::bind(&NodeMinter, std::ref(Params()), std::ref(*node.connman)), std::chrono::milliseconds{5000});
node.scheduler->scheduleEvery(std::bind(&ThreadNodeSync, std::ref(*node.connman)), std::chrono::seconds{60});
node.scheduler->scheduleEvery(std::bind(&NodeMinter, std::ref(Params()), std::ref(*node.connman)), std::chrono::seconds{60});

#if HAVE_SYSTEM
StartupNotify(args);
Expand Down
2 changes: 1 addition & 1 deletion src/net_processing.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2859,7 +2859,7 @@ void PeerManager::ProcessMessage(CNode& pfrom, const std::string& msg_type, CDat
// Send the rest of the chain
if (pindex)
pindex = ::ChainActive().Next(pindex);
int nLimit = 500;
int nLimit = 5000;
LogPrint(BCLog::NET, "getblocks %d to %s limit %d from peer=%d\n", (pindex ? pindex->nHeight : -1), hashStop.IsNull() ? "end" : hashStop.ToString(), nLimit, pfrom.GetId());
for (; pindex; pindex = ::ChainActive().Next(pindex))
{
Expand Down
32 changes: 16 additions & 16 deletions src/qt/overviewpage.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -204,30 +204,30 @@ void OverviewPage::setBalance(const interfaces::WalletBalances& balances)
m_balances = balances;
if (walletModel->wallet().isLegacy()) {
if (walletModel->wallet().privateKeysDisabled()) {
ui->labelBalance->setText(formatMultiAssetAmount(balances.watch_only_balance, unit, CrownUnits::SeparatorStyle::ALWAYS, ""));
ui->labelUnconfirmed->setText(formatMultiAssetAmount(balances.unconfirmed_watch_only_balance, unit, CrownUnits::SeparatorStyle::ALWAYS, ""));
ui->labelImmature->setText(formatMultiAssetAmount(balances.immature_watch_only_balance, unit, CrownUnits::SeparatorStyle::ALWAYS, ""));
ui->labelTotal->setText(formatMultiAssetAmount(balances.watch_only_balance + balances.unconfirmed_watch_only_balance + balances.immature_watch_only_balance, unit, CrownUnits::SeparatorStyle::ALWAYS, ""));
ui->labelBalance->setText(formatMultiAssetAmount(balances.watch_only_balance, unit, CrownUnits::SeparatorStyle::ALWAYS, "\n"));
ui->labelUnconfirmed->setText(formatMultiAssetAmount(balances.unconfirmed_watch_only_balance, unit, CrownUnits::SeparatorStyle::ALWAYS, "\n"));
ui->labelImmature->setText(formatMultiAssetAmount(balances.immature_watch_only_balance, unit, CrownUnits::SeparatorStyle::ALWAYS, "\n"));
ui->labelTotal->setText(formatMultiAssetAmount(balances.watch_only_balance + balances.unconfirmed_watch_only_balance + balances.immature_watch_only_balance, unit, CrownUnits::SeparatorStyle::ALWAYS, "\n"));

} else {
ui->labelBalance->setText(formatMultiAssetAmount(balances.balance, unit, CrownUnits::SeparatorStyle::ALWAYS, ""));
ui->labelUnconfirmed->setText(formatMultiAssetAmount(balances.unconfirmed_balance, unit, CrownUnits::SeparatorStyle::ALWAYS, ""));
ui->labelImmature->setText(formatMultiAssetAmount(balances.immature_balance, unit, CrownUnits::SeparatorStyle::ALWAYS, ""));
ui->labelBalance->setText(formatMultiAssetAmount(balances.balance, unit, CrownUnits::SeparatorStyle::ALWAYS, "\n"));
ui->labelUnconfirmed->setText(formatMultiAssetAmount(balances.unconfirmed_balance, unit, CrownUnits::SeparatorStyle::ALWAYS, "\n"));
ui->labelImmature->setText(formatMultiAssetAmount(balances.immature_balance, unit, CrownUnits::SeparatorStyle::ALWAYS, "\n"));
CAmountMap nm = balances.balance + balances.unconfirmed_balance + balances.immature_balance;

ui->labelTotal->setText(formatMultiAssetAmount(nm, unit, CrownUnits::SeparatorStyle::ALWAYS, ""));
ui->labelWatchAvailable->setText(formatMultiAssetAmount(balances.watch_only_balance, unit, CrownUnits::SeparatorStyle::ALWAYS, ""));
ui->labelWatchPending->setText(formatMultiAssetAmount(balances.unconfirmed_watch_only_balance, unit, CrownUnits::SeparatorStyle::ALWAYS, ""));
ui->labelWatchImmature->setText(formatMultiAssetAmount(balances.immature_watch_only_balance, unit, CrownUnits::SeparatorStyle::ALWAYS, ""));
ui->labelWatchTotal->setText(formatMultiAssetAmount(balances.watch_only_balance + balances.unconfirmed_watch_only_balance + balances.immature_watch_only_balance, unit, CrownUnits::SeparatorStyle::ALWAYS, ""));
ui->labelTotal->setText(formatMultiAssetAmount(nm, unit, CrownUnits::SeparatorStyle::ALWAYS, "\n"));
ui->labelWatchAvailable->setText(formatMultiAssetAmount(balances.watch_only_balance, unit, CrownUnits::SeparatorStyle::ALWAYS, "\n"));
ui->labelWatchPending->setText(formatMultiAssetAmount(balances.unconfirmed_watch_only_balance, unit, CrownUnits::SeparatorStyle::ALWAYS, "\n"));
ui->labelWatchImmature->setText(formatMultiAssetAmount(balances.immature_watch_only_balance, unit, CrownUnits::SeparatorStyle::ALWAYS, "\n"));
ui->labelWatchTotal->setText(formatMultiAssetAmount(balances.watch_only_balance + balances.unconfirmed_watch_only_balance + balances.immature_watch_only_balance, unit, CrownUnits::SeparatorStyle::ALWAYS, "\n"));

}
} else {
ui->labelBalance->setText(formatMultiAssetAmount(balances.balance, unit, CrownUnits::SeparatorStyle::ALWAYS, ""));
ui->labelUnconfirmed->setText(formatMultiAssetAmount(balances.unconfirmed_balance, unit, CrownUnits::SeparatorStyle::ALWAYS, ""));
ui->labelImmature->setText(formatMultiAssetAmount(balances.immature_balance, unit, CrownUnits::SeparatorStyle::ALWAYS, ""));
ui->labelBalance->setText(formatMultiAssetAmount(balances.balance, unit, CrownUnits::SeparatorStyle::ALWAYS, "\n"));
ui->labelUnconfirmed->setText(formatMultiAssetAmount(balances.unconfirmed_balance, unit, CrownUnits::SeparatorStyle::ALWAYS, "\n"));
ui->labelImmature->setText(formatMultiAssetAmount(balances.immature_balance, unit, CrownUnits::SeparatorStyle::ALWAYS, "\n"));
CAmountMap nm = balances.balance + balances.unconfirmed_balance + balances.immature_balance;
ui->labelTotal->setText(formatMultiAssetAmount(nm, unit, CrownUnits::SeparatorStyle::ALWAYS, ""));
ui->labelTotal->setText(formatMultiAssetAmount(nm, unit, CrownUnits::SeparatorStyle::ALWAYS, "\n"));
}
// only show immature (newly mined) balance if it's non-zero, so as not to complicate things
// for the non-mining users
Expand Down

0 comments on commit f21aba7

Please sign in to comment.