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