aboutsummaryrefslogtreecommitdiff
path: root/src/script.h
diff options
context:
space:
mode:
authorPieter Wuille <pieter.wuille@gmail.com>2011-07-05 20:53:43 +0200
committerPieter Wuille <pieter.wuille@gmail.com>2011-07-17 12:09:14 +0200
commit2ffba736e9102d016b96c2e5de2ce7757e612667 (patch)
treefb96acfec05aa767cb3ba2df9b93569f2a6c04db /src/script.h
parent03fbd7904903928b0d1c8542a3d597aaf5bdd31b (diff)
downloadbitcoin-2ffba736e9102d016b96c2e5de2ce7757e612667.tar.xz
Use CBitcoinAddress instead of string/uint160
Instead of conversion functions between pubkey/uint160/address in base58.h, have a fully fledged class CBitcoinAddress (CAddress was already taken) to represent addresses.
Diffstat (limited to 'src/script.h')
-rw-r--r--src/script.h30
1 files changed, 6 insertions, 24 deletions
diff --git a/src/script.h b/src/script.h
index be950f3006..9d94e3f5c8 100644
--- a/src/script.h
+++ b/src/script.h
@@ -622,7 +622,7 @@ public:
}
- uint160 GetBitcoinAddressHash160() const
+ CBitcoinAddress GetBitcoinAddress() const
{
opcodetype opcode;
std::vector<unsigned char> vch;
@@ -634,36 +634,18 @@ public:
if (!GetOp(pc, opcode, vch) || opcode != OP_EQUALVERIFY) return 0;
if (!GetOp(pc, opcode, vch) || opcode != OP_CHECKSIG) return 0;
if (pc != end()) return 0;
- return hash160;
+ return CBitcoinAddress(hash160);
}
- std::string GetBitcoinAddress() const
- {
- uint160 hash160 = GetBitcoinAddressHash160();
- if (hash160 == 0)
- return "";
- return Hash160ToAddress(hash160);
- }
-
- void SetBitcoinAddress(const uint160& hash160)
+ void SetBitcoinAddress(const CBitcoinAddress& address)
{
this->clear();
- *this << OP_DUP << OP_HASH160 << hash160 << OP_EQUALVERIFY << OP_CHECKSIG;
+ *this << OP_DUP << OP_HASH160 << address.GetHash160() << OP_EQUALVERIFY << OP_CHECKSIG;
}
void SetBitcoinAddress(const std::vector<unsigned char>& vchPubKey)
{
- SetBitcoinAddress(Hash160(vchPubKey));
- }
-
- bool SetBitcoinAddress(const std::string& strAddress)
- {
- this->clear();
- uint160 hash160;
- if (!AddressToHash160(strAddress, hash160))
- return false;
- SetBitcoinAddress(hash160);
- return true;
+ SetBitcoinAddress(CBitcoinAddress(vchPubKey));
}
@@ -710,7 +692,7 @@ public:
bool IsStandard(const CScript& scriptPubKey);
bool IsMine(const CKeyStore& keystore, const CScript& scriptPubKey);
-bool ExtractHash160(const CScript& scriptPubKey, const CKeyStore* pkeystore, uint160& hash160Ret);
+bool ExtractAddress(const CScript& scriptPubKey, const CKeyStore* pkeystore, CBitcoinAddress& addressRet);
bool SignSignature(const CKeyStore& keystore, const CTransaction& txFrom, CTransaction& txTo, unsigned int nIn, int nHashType=SIGHASH_ALL, CScript scriptPrereq=CScript());
bool VerifySignature(const CTransaction& txFrom, const CTransaction& txTo, unsigned int nIn, int nHashType=0);