Fix pay to pubkey for -addressindex
This commit is contained in:
10
src/main.cpp
10
src/main.cpp
@@ -2430,7 +2430,7 @@ bool DisconnectBlock(CBlock& block, CValidationState& state, CBlockIndex* pindex
|
|||||||
addressUnspentIndex.push_back(make_pair(CAddressUnspentKey(2, uint160(hashBytes), hash, k), CAddressUnspentValue()));
|
addressUnspentIndex.push_back(make_pair(CAddressUnspentKey(2, uint160(hashBytes), hash, k), CAddressUnspentValue()));
|
||||||
|
|
||||||
} else if (out.scriptPubKey.IsPayToPublicKeyHash()) {
|
} else if (out.scriptPubKey.IsPayToPublicKeyHash()) {
|
||||||
vector<unsigned char> hashBytes(out.scriptPubKey.begin()+3, out.scriptPubKey.begin()+23);
|
vector<unsigned char> hashBytes(out.scriptPubKey.begin()+1, out.scriptPubKey.begin()+34);
|
||||||
|
|
||||||
// undo receiving activity
|
// undo receiving activity
|
||||||
addressIndex.push_back(make_pair(CAddressIndexKey(1, uint160(hashBytes), pindex->nHeight, i, hash, k, false), out.nValue));
|
addressIndex.push_back(make_pair(CAddressIndexKey(1, uint160(hashBytes), pindex->nHeight, i, hash, k, false), out.nValue));
|
||||||
@@ -2503,7 +2503,7 @@ bool DisconnectBlock(CBlock& block, CValidationState& state, CBlockIndex* pindex
|
|||||||
|
|
||||||
|
|
||||||
} else if (prevout.scriptPubKey.IsPayToPublicKeyHash()) {
|
} else if (prevout.scriptPubKey.IsPayToPublicKeyHash()) {
|
||||||
vector<unsigned char> hashBytes(prevout.scriptPubKey.begin()+3, prevout.scriptPubKey.begin()+23);
|
vector<unsigned char> hashBytes(prevout.scriptPubKey.begin()+1, prevout.scriptPubKey.begin()+34);
|
||||||
|
|
||||||
// undo spending activity
|
// undo spending activity
|
||||||
addressIndex.push_back(make_pair(CAddressIndexKey(1, uint160(hashBytes), pindex->nHeight, i, hash, j, true), prevout.nValue * -1));
|
addressIndex.push_back(make_pair(CAddressIndexKey(1, uint160(hashBytes), pindex->nHeight, i, hash, j, true), prevout.nValue * -1));
|
||||||
@@ -2784,7 +2784,7 @@ bool ConnectBlock(const CBlock& block, CValidationState& state, CBlockIndex* pin
|
|||||||
hashBytes = uint160(vector <unsigned char>(prevout.scriptPubKey.begin()+2, prevout.scriptPubKey.begin()+22));
|
hashBytes = uint160(vector <unsigned char>(prevout.scriptPubKey.begin()+2, prevout.scriptPubKey.begin()+22));
|
||||||
addressType = 2;
|
addressType = 2;
|
||||||
} else if (prevout.scriptPubKey.IsPayToPublicKeyHash()) {
|
} else if (prevout.scriptPubKey.IsPayToPublicKeyHash()) {
|
||||||
hashBytes = uint160(vector <unsigned char>(prevout.scriptPubKey.begin()+3, prevout.scriptPubKey.begin()+23));
|
hashBytes = uint160(vector <unsigned char>(prevout.scriptPubKey.begin()+1, prevout.scriptPubKey.begin()+34));
|
||||||
addressType = 1;
|
addressType = 1;
|
||||||
} else {
|
} else {
|
||||||
hashBytes.SetNull();
|
hashBytes.SetNull();
|
||||||
@@ -2832,7 +2832,7 @@ bool ConnectBlock(const CBlock& block, CValidationState& state, CBlockIndex* pin
|
|||||||
if (fAddressIndex) {
|
if (fAddressIndex) {
|
||||||
for (unsigned int k = 0; k < tx.vout.size(); k++) {
|
for (unsigned int k = 0; k < tx.vout.size(); k++) {
|
||||||
const CTxOut &out = tx.vout[k];
|
const CTxOut &out = tx.vout[k];
|
||||||
fprintf(stderr,"add %d vouts\n",(int32_t)tx.vout.size());
|
//fprintf(stderr,"add %d vouts\n",(int32_t)tx.vout.size());
|
||||||
if (out.scriptPubKey.IsPayToScriptHash()) {
|
if (out.scriptPubKey.IsPayToScriptHash()) {
|
||||||
vector<unsigned char> hashBytes(out.scriptPubKey.begin()+2, out.scriptPubKey.begin()+22);
|
vector<unsigned char> hashBytes(out.scriptPubKey.begin()+2, out.scriptPubKey.begin()+22);
|
||||||
|
|
||||||
@@ -2843,7 +2843,7 @@ fprintf(stderr,"add %d vouts\n",(int32_t)tx.vout.size());
|
|||||||
addressUnspentIndex.push_back(make_pair(CAddressUnspentKey(2, uint160(hashBytes), txhash, k), CAddressUnspentValue(out.nValue, out.scriptPubKey, pindex->nHeight)));
|
addressUnspentIndex.push_back(make_pair(CAddressUnspentKey(2, uint160(hashBytes), txhash, k), CAddressUnspentValue(out.nValue, out.scriptPubKey, pindex->nHeight)));
|
||||||
|
|
||||||
} else if (out.scriptPubKey.IsPayToPublicKeyHash()) {
|
} else if (out.scriptPubKey.IsPayToPublicKeyHash()) {
|
||||||
vector<unsigned char> hashBytes(out.scriptPubKey.begin()+3, out.scriptPubKey.begin()+23);
|
vector<unsigned char> hashBytes(out.scriptPubKey.begin()+1, out.scriptPubKey.begin()+34);
|
||||||
|
|
||||||
// record receiving activity
|
// record receiving activity
|
||||||
addressIndex.push_back(make_pair(CAddressIndexKey(1, uint160(hashBytes), pindex->nHeight, i, txhash, k, false), out.nValue));
|
addressIndex.push_back(make_pair(CAddressIndexKey(1, uint160(hashBytes), pindex->nHeight, i, txhash, k, false), out.nValue));
|
||||||
|
|||||||
@@ -204,7 +204,7 @@ UniValue blockToDeltasJSON(const CBlock& block, const CBlockIndex* blockindex)
|
|||||||
delta.push_back(Pair("address", CBitcoinAddress(CScriptID(uint160(hashBytes))).ToString()));
|
delta.push_back(Pair("address", CBitcoinAddress(CScriptID(uint160(hashBytes))).ToString()));
|
||||||
|
|
||||||
} else if (out.scriptPubKey.IsPayToPublicKeyHash()) {
|
} else if (out.scriptPubKey.IsPayToPublicKeyHash()) {
|
||||||
vector<unsigned char> hashBytes(out.scriptPubKey.begin()+3, out.scriptPubKey.begin()+23);
|
vector<unsigned char> hashBytes(out.scriptPubKey.begin()+1, out.scriptPubKey.begin()+34);
|
||||||
delta.push_back(Pair("address", CBitcoinAddress(CKeyID(uint160(hashBytes))).ToString()));
|
delta.push_back(Pair("address", CBitcoinAddress(CKeyID(uint160(hashBytes))).ToString()));
|
||||||
} else {
|
} else {
|
||||||
continue;
|
continue;
|
||||||
|
|||||||
@@ -138,7 +138,7 @@ void CTxMemPool::addAddressIndex(const CTxMemPoolEntry &entry, const CCoinsViewC
|
|||||||
mapAddress.insert(make_pair(key, delta));
|
mapAddress.insert(make_pair(key, delta));
|
||||||
inserted.push_back(key);
|
inserted.push_back(key);
|
||||||
} else if (prevout.scriptPubKey.IsPayToPublicKeyHash()) {
|
} else if (prevout.scriptPubKey.IsPayToPublicKeyHash()) {
|
||||||
vector<unsigned char> hashBytes(prevout.scriptPubKey.begin()+3, prevout.scriptPubKey.begin()+23);
|
vector<unsigned char> hashBytes(prevout.scriptPubKey.begin()+1, prevout.scriptPubKey.begin()+34);
|
||||||
CMempoolAddressDeltaKey key(1, uint160(hashBytes), txhash, j, 1);
|
CMempoolAddressDeltaKey key(1, uint160(hashBytes), txhash, j, 1);
|
||||||
CMempoolAddressDelta delta(entry.GetTime(), prevout.nValue * -1, input.prevout.hash, input.prevout.n);
|
CMempoolAddressDelta delta(entry.GetTime(), prevout.nValue * -1, input.prevout.hash, input.prevout.n);
|
||||||
mapAddress.insert(make_pair(key, delta));
|
mapAddress.insert(make_pair(key, delta));
|
||||||
@@ -154,7 +154,7 @@ void CTxMemPool::addAddressIndex(const CTxMemPoolEntry &entry, const CCoinsViewC
|
|||||||
mapAddress.insert(make_pair(key, CMempoolAddressDelta(entry.GetTime(), out.nValue)));
|
mapAddress.insert(make_pair(key, CMempoolAddressDelta(entry.GetTime(), out.nValue)));
|
||||||
inserted.push_back(key);
|
inserted.push_back(key);
|
||||||
} else if (out.scriptPubKey.IsPayToPublicKeyHash()) {
|
} else if (out.scriptPubKey.IsPayToPublicKeyHash()) {
|
||||||
vector<unsigned char> hashBytes(out.scriptPubKey.begin()+3, out.scriptPubKey.begin()+23);
|
vector<unsigned char> hashBytes(out.scriptPubKey.begin()+1, out.scriptPubKey.begin()+34);
|
||||||
std::pair<addressDeltaMap::iterator,bool> ret;
|
std::pair<addressDeltaMap::iterator,bool> ret;
|
||||||
CMempoolAddressDeltaKey key(1, uint160(hashBytes), txhash, k, 0);
|
CMempoolAddressDeltaKey key(1, uint160(hashBytes), txhash, k, 0);
|
||||||
mapAddress.insert(make_pair(key, CMempoolAddressDelta(entry.GetTime(), out.nValue)));
|
mapAddress.insert(make_pair(key, CMempoolAddressDelta(entry.GetTime(), out.nValue)));
|
||||||
@@ -213,7 +213,7 @@ void CTxMemPool::addSpentIndex(const CTxMemPoolEntry &entry, const CCoinsViewCac
|
|||||||
addressHash = uint160(vector<unsigned char> (prevout.scriptPubKey.begin()+2, prevout.scriptPubKey.begin()+22));
|
addressHash = uint160(vector<unsigned char> (prevout.scriptPubKey.begin()+2, prevout.scriptPubKey.begin()+22));
|
||||||
addressType = 2;
|
addressType = 2;
|
||||||
} else if (prevout.scriptPubKey.IsPayToPublicKeyHash()) {
|
} else if (prevout.scriptPubKey.IsPayToPublicKeyHash()) {
|
||||||
addressHash = uint160(vector<unsigned char> (prevout.scriptPubKey.begin()+3, prevout.scriptPubKey.begin()+23));
|
addressHash = uint160(vector<unsigned char> (prevout.scriptPubKey.begin()+1, prevout.scriptPubKey.begin()+34));
|
||||||
addressType = 1;
|
addressType = 1;
|
||||||
} else {
|
} else {
|
||||||
addressHash.SetNull();
|
addressHash.SetNull();
|
||||||
|
|||||||
Reference in New Issue
Block a user