Skip to content

Commit

Permalink
Port token interfaces
Browse files Browse the repository at this point in the history
  • Loading branch information
timemarkovqtum committed Jun 26, 2024
1 parent 79de43a commit 60c834e
Show file tree
Hide file tree
Showing 10 changed files with 781 additions and 23 deletions.
2 changes: 1 addition & 1 deletion src/bip324.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ void BIP324Cipher::Initialize(const EllSwiftPubKey& their_pubkey, bool initiator
{
// Determine salt (fixed string + network magic bytes)
const auto& message_header = Params().MessageStart();
std::string salt = std::string{"bitcoin_v2_shared_secret"} + std::string(std::begin(message_header), std::end(message_header));
std::string salt = std::string{"qtum_v2_shared_secret"} + std::string(std::begin(message_header), std::end(message_header));

// Perform ECDH to derive shared secret.
ECDHSecret ecdh_secret = m_key.ComputeBIP324ECDHSecret(their_pubkey, m_our_pubkey, initiator);
Expand Down
3 changes: 3 additions & 0 deletions src/interfaces/chain.h
Original file line number Diff line number Diff line change
Expand Up @@ -325,6 +325,9 @@ class Chain
//! Check if shutdown requested.
virtual bool shutdownRequested() = 0;

//! Get adjusted time.
virtual int64_t getAdjustedTime() = 0;

//! Send init message.
virtual void initMessage(const std::string& message) = 0;

Expand Down
2 changes: 1 addition & 1 deletion src/merkleblock.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -152,7 +152,7 @@ uint256 CPartialMerkleTree::ExtractMatches(std::vector<uint256> &vMatch, std::ve
if (nTransactions == 0)
return uint256();
// check for excessively high numbers of transactions
if (nTransactions > MAX_BLOCK_WEIGHT / MIN_TRANSACTION_WEIGHT)
if (nTransactions > dgpMaxBlockSize * WITNESS_SCALE_FACTOR / MIN_TRANSACTION_WEIGHT)
return uint256();
// there can never be more hashes provided than one for every txid
if (vHash.size() > nTransactions)
Expand Down
1 change: 1 addition & 0 deletions src/node/interfaces.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -822,6 +822,7 @@ class ChainImpl : public Chain
return chainman().IsInitialBlockDownload();
}
bool shutdownRequested() override { return ShutdownRequested(m_node); }
int64_t getAdjustedTime() override { return TicksSinceEpoch<std::chrono::seconds>(NodeClock::now()); }
void initMessage(const std::string& message) override { ::uiInterface.InitMessage(message); }
void initWarning(const bilingual_str& message) override { InitWarning(message); }
void initError(const bilingual_str& message) override { InitError(message); }
Expand Down
5 changes: 3 additions & 2 deletions src/undo.h
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ struct TxInUndoFormatter
{
template<typename Stream>
void Ser(Stream &s, const Coin& txout) {
::Serialize(s, VARINT(txout.nHeight * uint32_t{2} + txout.fCoinBase ));
::Serialize(s, VARINT((txout.nHeight << 2) + (txout.fCoinStake ? 2u : 0u) + (txout.fCoinBase ? 1u : 0u)));
if (txout.nHeight > 0) {
// Required to maintain compatibility with older undo format.
::Serialize(s, (unsigned char)0);
Expand All @@ -35,8 +35,9 @@ struct TxInUndoFormatter
void Unser(Stream &s, Coin& txout) {
uint32_t nCode = 0;
::Unserialize(s, VARINT(nCode));
txout.nHeight = nCode >> 1;
txout.nHeight = nCode >> 2;
txout.fCoinBase = nCode & 1;
txout.fCoinStake = (nCode >> 1) & 1;
if (txout.nHeight > 0) {
// Old versions stored the version number for the last spend of
// a transaction's outputs. Non-final spends were indicated with
Expand Down
7 changes: 7 additions & 0 deletions src/versionbits.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -238,6 +238,13 @@ int32_t VersionBitsCache::ComputeBlockVersion(const CBlockIndex* pindexPrev, con
return nVersion;
}

void VersionBitsCache::Erase(CBlockIndex *pindex) {
LOCK(m_mutex);
for (int b = 0; b < Consensus::MAX_VERSION_BITS_DEPLOYMENTS; b++) {
m_caches[b].erase(pindex);
}
}

void VersionBitsCache::Clear()
{
LOCK(m_mutex);
Expand Down
2 changes: 2 additions & 0 deletions src/versionbits.h
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,8 @@ class VersionBitsCache
*/
int32_t ComputeBlockVersion(const CBlockIndex* pindexPrev, const Consensus::Params& params) EXCLUSIVE_LOCKS_REQUIRED(!m_mutex);

void Erase(CBlockIndex *pindex) EXCLUSIVE_LOCKS_REQUIRED(!m_mutex);

void Clear() EXCLUSIVE_LOCKS_REQUIRED(!m_mutex);
};

Expand Down
Loading

0 comments on commit 60c834e

Please sign in to comment.