diff --git a/.gitignore b/.gitignore index bebcef932..3916d4e87 100644 --- a/.gitignore +++ b/.gitignore @@ -120,3 +120,4 @@ src/komodo-cli src/komodod src/komodo-tx src/komodo-test +src/wallet-utility diff --git a/src/chainparams.cpp b/src/chainparams.cpp index 9ccde95ee..1cf2106b0 100644 --- a/src/chainparams.cpp +++ b/src/chainparams.cpp @@ -182,7 +182,7 @@ public: vFixedSeeds = std::vector(pnSeed6_main, pnSeed6_main + ARRAYLEN(pnSeed6_main)); - fMiningRequiresPeers = true; + //fMiningRequiresPeers = true; fDefaultConsistencyChecks = false; fRequireStandard = true; fMineBlocksOnDemand = false; diff --git a/src/wallet-utility b/src/wallet-utility index 289d5d730..85ec51ebe 100644 Binary files a/src/wallet-utility and b/src/wallet-utility differ diff --git a/src/wallet/wallet.cpp b/src/wallet/wallet.cpp index ac033fe17..60b996821 100644 --- a/src/wallet/wallet.cpp +++ b/src/wallet/wallet.cpp @@ -1206,7 +1206,7 @@ bool CWallet::AddToWalletIfInvolvingMe(const CTransaction& tx, const CBlock* pbl bool fExisted = mapWallet.count(tx.GetHash()) != 0; if (fExisted && !fUpdate) return false; auto noteData = FindMyNotes(tx); - if (fExisted || IsMine(tx) || IsFromMe(tx) || noteData.size() > 0) + if (fExisted || IsMineOrWatch(tx) || IsFromMe(tx) || noteData.size() > 0) { CWalletTx wtx(this,tx); @@ -1458,11 +1458,23 @@ CAmount CWallet::GetChange(const CTxOut& txout) const return (IsChange(txout) ? txout.nValue : 0); } -bool CWallet::IsMine(const CTransaction& tx) const +bool CWallet::IsMine(const CTransaction& tx) { - BOOST_FOREACH(const CTxOut& txout, tx.vout) - if (IsMine(txout)) + for (int i = 0; i < tx.vout.size(); i++) + { + if (IsMine(tx, i) == ISMINE_SPENDABLE) + return true; + } + return false; +} + +bool CWallet::IsMineOrWatch(const CTransaction& tx) +{ + for (int i = 0; i < tx.vout.size(); i++) + { + if (IsMine(tx, i) & ISMINE_ALL) return true; + } return false; } @@ -1471,18 +1483,19 @@ bool CWallet::IsMine(const CTransaction& tx) const isminetype CWallet::IsCLTVMine(CScriptExt &script, CScriptID &scriptID, int64_t locktime) { uint8_t pushOp = script.data()[0]; - uint32_t scriptStart = pushOp + 2; + uint32_t scriptStart = pushOp + 3; // check post CLTV script CScriptExt postfix = CScriptExt(script.size() > scriptStart ? script.begin() + scriptStart : script.end(), script.end()); // check again with postfix subscript isminetype ret = ::IsMine(*this, postfix); - if (ret != ISMINE_NO) + if (ret == ISMINE_SPENDABLE) { // once we get here, we should have this script in our // wallet, either as watch only if still time locked, or spendable - if (!chainActive.Tip()->nHeight >= locktime) + CBlockIndex &tip = *(chainActive.Tip()); + if (!(locktime < LOCKTIME_THRESHOLD ? tip.nHeight >= locktime : tip.GetBlockTime() >= locktime)) { ret = ISMINE_WATCH_ONLY; if (!this->HaveWatchOnly(script)) @@ -1518,7 +1531,7 @@ isminetype CWallet::IsMine(const CTransaction& tx, uint32_t voutNum) } CKeyID keyID; - CScriptID scriptID = CScriptID(uint160(vSolutions[0])); + CScriptID scriptID; CScriptExt subscript; int voutNext = voutNum + 1; @@ -1541,6 +1554,7 @@ isminetype CWallet::IsMine(const CTransaction& tx, uint32_t voutNum) break; case TX_SCRIPTHASH: + scriptID = CScriptID(uint160(vSolutions[0])); if (this->GetCScript(scriptID, subscript)) { // if this is a CLTV, handle it differently diff --git a/src/wallet/wallet.h b/src/wallet/wallet.h index e51653069..bacdd0308 100644 --- a/src/wallet/wallet.h +++ b/src/wallet/wallet.h @@ -1055,7 +1055,8 @@ public: CAmount GetCredit(const CTxOut& txout, const isminefilter& filter) const; bool IsChange(const CTxOut& txout) const; CAmount GetChange(const CTxOut& txout) const; - bool IsMine(const CTransaction& tx) const; + bool IsMine(const CTransaction& tx); + bool IsMineOrWatch(const CTransaction& tx); /** should probably be renamed to IsRelevantToMe */ bool IsFromMe(const CTransaction& tx) const; CAmount GetDebit(const CTransaction& tx, const isminefilter& filter) const;