CBigNum rem;
while (bn > bn0)
{
- if (!BN_div(&dv, &rem, &bn, &bn58, pctx))
+ if (!BN_div(dv.get(), rem.get(), bn.get(), bn58.get(), pctx))
throw bignum_error("EncodeBase58 : BN_div failed");
bn = dv;
unsigned int c = rem.getuint32();
break;
}
bnChar.setuint32((uint32_t)(p1 - pszBase58));
- if (!BN_mul(&bn, &bn, &bn58, pctx))
+ if (!BN_mul(bn.get(), bn.get(), bn58.get(), pctx))
throw bignum_error("DecodeBase58 : BN_mul failed");
bn += bnChar;
}
return true;
}
+ bool CBitcoinAddress::Set(const CBitcoinAddress &dest)
+ {
+ nVersion = dest.nVersion;
+ vchData = dest.vchData;
+ return true;
+ }
+
bool CBitcoinAddress::IsValid() const
{
unsigned int nExpectedSize = 20;
bool fExpectTestNet = false;
+ bool fSimple = true;
switch(nVersion)
{
case PUBKEY_PAIR_ADDRESS:
nExpectedSize = 68; // Serialized pair of public keys
fExpectTestNet = false;
+ fSimple = false;
break;
case PUBKEY_ADDRESS:
nExpectedSize = 20; // Hash of public key
case PUBKEY_PAIR_ADDRESS_TEST:
nExpectedSize = 68;
fExpectTestNet = true;
+ fSimple = false;
break;
case PUBKEY_ADDRESS_TEST:
nExpectedSize = 20;
default:
return false;
}
- return fExpectTestNet == fTestNet && vchData.size() == nExpectedSize;
+
+ // Basic format sanity check
+ bool fSeemsSane = (fExpectTestNet == fTestNet && vchData.size() == nExpectedSize);
+
+ if (fSeemsSane && !fSimple)
+ {
+ // Perform dditional checking
+ // for pubkey pair addresses
+ CMalleablePubKey mpk;
+ mpk.setvch(vchData);
+ return mpk.IsValid();
+ }
+ else
+ return fSeemsSane;
}
CTxDestination CBitcoinAddress::Get() const {
CMalleablePubKey mPubKey;
mPubKey.setvch(vchData);
keyID = mPubKey.GetID();
+ return true;
}
default: return false;
}
default: return false;
}
}
+
+ bool CBitcoinAddress::IsPubKey() const {
+ if (!IsValid())
+ return false;
+ switch (nVersion) {
+ case PUBKEY_ADDRESS:
+ case PUBKEY_ADDRESS_TEST: {
+ return true;
+ }
+ default: return false;
+ }
+ }
bool CBitcoinAddress::IsPair() const {
if (!IsValid())