Add support for pay2pubkey for -addressindex

This commit is contained in:
jl777
2018-06-26 04:40:32 -11:00
parent ba31c2f4b4
commit fa7bf712a1
7 changed files with 123 additions and 26 deletions

View File

@@ -172,9 +172,14 @@ UniValue blockToDeltasJSON(const CBlock& block, const CBlockIndex* blockindex)
if (GetSpentIndex(spentKey, spentInfo)) {
if (spentInfo.addressType == 1) {
delta.push_back(Pair("address", CBitcoinAddress(CKeyID(spentInfo.addressHash)).ToString()));
} else if (spentInfo.addressType == 2) {
}
else if (spentInfo.addressType == 2) {
delta.push_back(Pair("address", CBitcoinAddress(CScriptID(spentInfo.addressHash)).ToString()));
} else {
}
else if (spentInfo.addressType == 3) {
xxx delta.push_back(Pair("address", CBitcoinAddress(CScriptID(spentInfo.addressHash)).ToString()));
}
else {
continue;
}
delta.push_back(Pair("satoshis", -1 * spentInfo.satoshis));
@@ -203,10 +208,21 @@ UniValue blockToDeltasJSON(const CBlock& block, const CBlockIndex* blockindex)
vector<unsigned char> hashBytes(out.scriptPubKey.begin()+2, out.scriptPubKey.begin()+22);
delta.push_back(Pair("address", CBitcoinAddress(CScriptID(uint160(hashBytes))).ToString()));
} else if (out.scriptPubKey.IsPayToPublicKeyHash()) {
vector<unsigned char> hashBytes(out.scriptPubKey.begin()+1, out.scriptPubKey.begin()+34);
}
else if (out.scriptPubKey.IsPayToPublicKeyHash()) {
vector<unsigned char> hashBytes(out.scriptPubKey.begin()+3, out.scriptPubKey.begin()+23);
delta.push_back(Pair("address", CBitcoinAddress(CKeyID(uint160(hashBytes))).ToString()));
} else {
}
else if (out.scriptPubKey.IsPayToPublicKey()) {
CTxDestination address;
if (ExtractDestination(out.scriptPubKey, address))
{
//vector<unsigned char> hashBytes(out.scriptPubKey.begin()+1, out.scriptPubKey.begin()+34);
//xxx delta.push_back(Pair("address", CBitcoinAddress(CKeyID(uint160(hashBytes))).ToString()));
delta.push_back(Pair("address", address.ToString()));
}
}
else {
continue;
}