Skip to content

Commit

Permalink
Merge pull request #434 from NAVCoin/cold-staking-index-spending
Browse files Browse the repository at this point in the history
Index cold staking address unspent output by spending address
  • Loading branch information
proletesseract committed Apr 10, 2019
2 parents 197c460 + 0ae6115 commit 404d85f
Showing 1 changed file with 10 additions and 2 deletions.
12 changes: 10 additions & 2 deletions src/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2430,6 +2430,8 @@ bool DisconnectBlock(const CBlock& block, CValidationState& state, const CBlockI
CTxDestination destination;
ExtractDestination(out.scriptPubKey, destination);
CNavCoinAddress address(destination);
if (out.scriptPubKey.IsColdStaking())
address.GetSpendingAddress(address);
address.GetIndexKey(hashBytes, type);

// undo spending activity
Expand Down Expand Up @@ -2509,9 +2511,11 @@ bool DisconnectBlock(const CBlock& block, CValidationState& state, const CBlockI
} else if (prevout.scriptPubKey.IsPayToPublicKey() || prevout.scriptPubKey.IsColdStaking()) {
uint160 hashBytes;
int type = 0;
CTxDestination destination;
CTxDestination destination;
ExtractDestination(prevout.scriptPubKey, destination);
CNavCoinAddress address(destination);
if (prevout.scriptPubKey.IsColdStaking())
address.GetSpendingAddress(address);
address.GetIndexKey(hashBytes, type);

// undo spending activity
Expand Down Expand Up @@ -2975,6 +2979,8 @@ bool ConnectBlock(const CBlock& block, CValidationState& state, CBlockIndex* pin
CTxDestination destination;
ExtractDestination(prevout.scriptPubKey, destination);
CNavCoinAddress address(destination);
if (prevout.scriptPubKey.IsColdStaking())
address.GetSpendingAddress(address);
address.GetIndexKey(hashBytes, addressType);
} else {
hashBytes.SetNull();
Expand Down Expand Up @@ -3091,9 +3097,11 @@ bool ConnectBlock(const CBlock& block, CValidationState& state, CBlockIndex* pin
} else if (out.scriptPubKey.IsPayToPublicKey() || out.scriptPubKey.IsColdStaking()) {
uint160 hashBytes;
int type = 0;
CTxDestination destination;
CTxDestination destination;
ExtractDestination(out.scriptPubKey, destination);
CNavCoinAddress address(destination);
if (out.scriptPubKey.IsColdStaking())
address.GetSpendingAddress(address);
address.GetIndexKey(hashBytes, type);

// undo spending activity
Expand Down

0 comments on commit 404d85f

Please sign in to comment.