fix address type
This commit is contained in:
@@ -296,13 +296,13 @@ CTxDestination CBitcoinAddress::Get() const
|
||||
return CNoDestination();
|
||||
}
|
||||
|
||||
bool CBitcoinAddress::GetIndexKey(uint160& hashBytes, int& type) const
|
||||
bool CBitcoinAddress::GetIndexKey(uint160& hashBytes, int& type, bool ccflag) const
|
||||
{
|
||||
if (!IsValid()) {
|
||||
return false;
|
||||
} else if (vchVersion == Params().Base58Prefix(CChainParams::PUBKEY_ADDRESS)) {
|
||||
memcpy(&hashBytes, &vchData[0], 20);
|
||||
type = 1;
|
||||
ccflag ? type = 3 : type = 1;
|
||||
return true;
|
||||
} else if (vchVersion == Params().Base58Prefix(CChainParams::SCRIPT_ADDRESS)) {
|
||||
memcpy(&hashBytes, &vchData[0], 20);
|
||||
@@ -392,13 +392,13 @@ CTxDestination CCustomBitcoinAddress::Get() const
|
||||
return CNoDestination();
|
||||
}
|
||||
|
||||
bool CCustomBitcoinAddress::GetIndexKey(uint160& hashBytes, int& type) const
|
||||
bool CCustomBitcoinAddress::GetIndexKey(uint160& hashBytes, int& type, bool ccflag) const
|
||||
{
|
||||
if (!IsValid()) {
|
||||
return false;
|
||||
} else if (vchVersion == base58Prefixes[0]) {
|
||||
memcpy(&hashBytes, &vchData[0], 20);
|
||||
type = 1;
|
||||
ccflag ? type = 3 : type = 1;
|
||||
return true;
|
||||
} else if (vchVersion == base58Prefixes[1]) {
|
||||
memcpy(&hashBytes, &vchData[0], 20);
|
||||
|
||||
@@ -147,7 +147,7 @@ public:
|
||||
CTxDestination Get() const;
|
||||
bool GetKeyID(CKeyID &keyID) const;
|
||||
bool GetKeyID_NoCheck(CKeyID& keyID) const;
|
||||
bool GetIndexKey(uint160& hashBytes, int& type) const;
|
||||
bool GetIndexKey(uint160& hashBytes, int& type, bool ccflag) const;
|
||||
bool IsScript() const;
|
||||
};
|
||||
|
||||
@@ -172,7 +172,7 @@ public:
|
||||
CTxDestination Get() const;
|
||||
bool GetKeyID(CKeyID &keyID) const;
|
||||
bool GetKeyID_NoCheck(CKeyID& keyID) const;
|
||||
bool GetIndexKey(uint160& hashBytes, int& type) const;
|
||||
bool GetIndexKey(uint160& hashBytes, int& type, bool ccflag) const;
|
||||
bool IsScript() const;
|
||||
};
|
||||
|
||||
|
||||
@@ -315,7 +315,7 @@ void SetCCunspents(std::vector<std::pair<CAddressUnspentKey, CAddressUnspentValu
|
||||
for (i=0; i<=n; i++)
|
||||
ptr[i] = coinaddr[i];
|
||||
CBitcoinAddress address(addrstr);
|
||||
if ( address.GetIndexKey(hashBytes, type) == 0 )
|
||||
if ( address.GetIndexKey(hashBytes, type, ccflag) == 0 )
|
||||
return;
|
||||
addresses.push_back(std::make_pair(hashBytes,type));
|
||||
for (std::vector<std::pair<uint160, int> >::iterator it = addresses.begin(); it != addresses.end(); it++)
|
||||
@@ -334,7 +334,7 @@ void SetCCtxids(std::vector<std::pair<CAddressIndexKey, CAmount> > &addressIndex
|
||||
for (i=0; i<=n; i++)
|
||||
ptr[i] = coinaddr[i];
|
||||
CBitcoinAddress address(addrstr);
|
||||
if ( address.GetIndexKey(hashBytes, type) == 0 )
|
||||
if ( address.GetIndexKey(hashBytes, type, ccflag) == 0 )
|
||||
return;
|
||||
addresses.push_back(std::make_pair(hashBytes,type));
|
||||
for (std::vector<std::pair<uint160, int> >::iterator it = addresses.begin(); it != addresses.end(); it++)
|
||||
|
||||
@@ -867,7 +867,7 @@ bool getAddressesFromParams(const UniValue& params, std::vector<std::pair<uint16
|
||||
CBitcoinAddress address(params[0].get_str());
|
||||
uint160 hashBytes;
|
||||
int type = 0;
|
||||
if (!address.GetIndexKey(hashBytes, type)) {
|
||||
if (!address.GetIndexKey(hashBytes, type, 0)) {
|
||||
throw JSONRPCError(RPC_INVALID_ADDRESS_OR_KEY, "Invalid address");
|
||||
}
|
||||
addresses.push_back(std::make_pair(hashBytes, type));
|
||||
@@ -885,7 +885,7 @@ bool getAddressesFromParams(const UniValue& params, std::vector<std::pair<uint16
|
||||
CBitcoinAddress address(it->get_str());
|
||||
uint160 hashBytes;
|
||||
int type = 0;
|
||||
if (!address.GetIndexKey(hashBytes, type)) {
|
||||
if (!address.GetIndexKey(hashBytes, type, 0)) {
|
||||
throw JSONRPCError(RPC_INVALID_ADDRESS_OR_KEY, "Invalid addresses");
|
||||
}
|
||||
addresses.push_back(std::make_pair(hashBytes, type));
|
||||
|
||||
@@ -160,7 +160,7 @@ void CTxMemPool::addAddressIndex(const CTxMemPoolEntry &entry, const CCoinsViewC
|
||||
if (vDest.which())
|
||||
{
|
||||
uint160 hashBytes;
|
||||
if (CBitcoinAddress(vDest).GetIndexKey(hashBytes, keyType))
|
||||
if (CBitcoinAddress(vDest).GetIndexKey(hashBytes, keyType, prevout.scriptPubKey.IsPayToCryptoCondition()))
|
||||
{
|
||||
vSols.push_back(vector<unsigned char>(hashBytes.begin(), hashBytes.end()));
|
||||
}
|
||||
@@ -192,7 +192,7 @@ void CTxMemPool::addAddressIndex(const CTxMemPoolEntry &entry, const CCoinsViewC
|
||||
if (vDest.which())
|
||||
{
|
||||
uint160 hashBytes;
|
||||
if (CBitcoinAddress(vDest).GetIndexKey(hashBytes, keyType))
|
||||
if (CBitcoinAddress(vDest).GetIndexKey(hashBytes, keyType, out.scriptPubKey.IsPayToCryptoCondition()))
|
||||
{
|
||||
vSols.push_back(vector<unsigned char>(hashBytes.begin(), hashBytes.end()));
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user