CKey keyL(pvchSecretL);
CKey keyH(pvchSecretH);
- if (!keyL.IsValid() || !keyL.IsValid())
+ if (!keyL.IsValid() || !keyH.IsValid())
return false;
vchSecretL = pvchSecretL;
CMalleablePubKey CMalleableKey::GetMalleablePubKey() const
{
- CKey L, H;
- L.SetSecret(vchSecretL, true);
- H.SetSecret(vchSecretH, true);
-
- std::vector<unsigned char> vchPubKeyL = L.GetPubKey().Raw();
- std::vector<unsigned char> vchPubKeyH = H.GetPubKey().Raw();
-
- return CMalleablePubKey(vchPubKeyL, vchPubKeyH);
+ CKey L(vchSecretL), H(vchSecretH);
+ return CMalleablePubKey(L.GetPubKey().Raw(), H.GetPubKey().Raw());
}
// Check ownership
throw key_error("CMalleableKey::CheckKeyVariant() : Unable to decode R value");
}
- CKey H;
- H.SetSecret(vchSecretH, true);
+ CKey H(vchSecretH);
std::vector<unsigned char> vchPubKeyH = H.GetPubKey().Raw();
CPoint point_H;
throw key_error("CMalleableKey::CheckKeyVariant() : Unable to decode R value");
}
- CKey H;
- H.SetSecret(vchSecretH, true);
+ CKey H(vchSecretH);
std::vector<unsigned char> vchPubKeyH = H.GetPubKey().Raw();
CPoint point_H;
CBigNum bnp = bnHash + bnh;
std::vector<unsigned char> vchp = bnp.getBytes();
- privKeyVariant.SetSecret(CSecret(vchp.begin(), vchp.end()), true);
+ privKeyVariant.SetSecret(CSecret(vchp.begin(), vchp.end()));
return true;
}
throw key_error("CMalleableKeyView::CMalleableKeyView() : L size must be 32 bytes");
if (b.vchSecretH.size() != 32)
- throw key_error("CMalleableKeyView::CMalleableKeyView() : L size must be 32 bytes");
+ throw key_error("CMalleableKeyView::CMalleableKeyView() : H size must be 32 bytes");
vchSecretL = b.vchSecretL;
- CKey H;
- H.SetSecret(b.vchSecretH, true);
-
+ CKey H(b.vchSecretH);
vchPubKeyH = H.GetPubKey().Raw();
}
{
vchSecretL = b.vchSecretL;
- CKey H;
- H.SetSecret(b.vchSecretH, true);
+ CKey H(b.vchSecretH);
vchPubKeyH = H.GetPubKey().Raw();
return (*this);
CMalleablePubKey CMalleableKeyView::GetMalleablePubKey() const
{
- CKey keyL;
- keyL.SetSecret(vchSecretL, true);
+ CKey keyL(vchSecretL);
return CMalleablePubKey(keyL.GetPubKey(), vchPubKeyH);
}
int64_t nNet = nCredit - nDebit;
uint256 hash = wtx.GetHash(), hashPrev = 0;
std::map<std::string, std::string> mapValue = wtx.mapValue;
+
+ bool fCoinBase = wtx.IsCoinBase(),
+ fCoinStake = wtx.IsCoinStake();
- if (nNet > 0 || wtx.IsCoinBase() || wtx.IsCoinStake())
+ if (nNet > 0 || fCoinBase || fCoinStake)
{
//
// Credit
sub.idx = parts.size(); // sequence number
sub.credit = txout.nValue;
- std::string address;
- if (pwalletMain->ExtractAddress(txout.scriptPubKey, address))
+ CBitcoinAddress addressRet;
+ if (pwalletMain->ExtractAddress(txout.scriptPubKey, addressRet))
{
sub.type = TransactionRecord::RecvWithAddress;
- sub.address = address;
+ sub.address = addressRet.ToString();
}
else
{
sub.address = mapValue["from"];
}
- if (wtx.IsCoinBase())
+ if (fCoinBase || fCoinStake)
{
- // Generated (proof-of-work)
+ // Generated
sub.type = TransactionRecord::Generated;
- }
- if (wtx.IsCoinStake())
- {
- // Generated (proof-of-stake)
-
- if (hashPrev == hash)
- continue; // last coinstake output
-
- sub.type = TransactionRecord::Generated;
- sub.credit = nNet > 0 ? nNet : wtx.GetValueOut() - nDebit;
- hashPrev = hash;
+ if (fCoinStake)
+ {
+ // proof-of-stake
+ if (hashPrev == hash)
+ continue; // last coinstake output
+ sub.credit = nNet > 0 ? nNet : wtx.GetValueOut() - nDebit;
+ hashPrev = hash;
+ }
}
parts.append(sub);
cout = COutput(&wallet->mapWallet[cout.tx->vin[0].prevout.hash], cout.tx->vin[0].prevout.n, 0, true);
}
- std::string address;
- if(!out.fSpendable || !wallet->ExtractAddress(cout.tx->vout[cout.i].scriptPubKey, address))
+ CBitcoinAddress addressRet;
+ if(!out.fSpendable || !wallet->ExtractAddress(cout.tx->vout[cout.i].scriptPubKey, addressRet))
continue;
- mapCoins[address.c_str()].push_back(out);
+ mapCoins[addressRet.ToString().c_str()].push_back(out);
}
}
EraseFromWallet(*it);
}
-bool CWallet::ExtractAddress(const CScript& scriptPubKey, std::string& addressRet)
+bool CWallet::ExtractAddress(const CScript& scriptPubKey, CBitcoinAddress& addressRet)
{
vector<valtype> vSolutions;
txnouttype whichType;
if (whichType == TX_PUBKEY)
{
- addressRet = CBitcoinAddress(CPubKey(vSolutions[0]).GetID()).ToString();
+ addressRet = CBitcoinAddress(CPubKey(vSolutions[0]).GetID());
return true;
}
if (whichType == TX_PUBKEY_DROP)
if (!CheckOwnership(CPubKey(vSolutions[0]), CPubKey(vSolutions[1]), view))
return false;
- addressRet = CBitcoinAddress(view.GetMalleablePubKey()).ToString();
+ addressRet = CBitcoinAddress(view.GetMalleablePubKey());
return true;
}
else if (whichType == TX_PUBKEYHASH)
{
- addressRet = CBitcoinAddress(CKeyID(uint160(vSolutions[0]))).ToString();
+ addressRet = CBitcoinAddress(CKeyID(uint160(vSolutions[0])));
return true;
}
else if (whichType == TX_SCRIPTHASH)
{
- addressRet = CBitcoinAddress(CScriptID(uint160(vSolutions[0]))).ToString();
+ addressRet = CBitcoinAddress(CScriptID(uint160(vSolutions[0])));
return true;
}
// Multisig txns have more than one address...
#include "ui_interface.h"
#include "util.h"
#include "walletdb.h"
+#include "base58.h"
extern unsigned int nStakeMaxAge;
extern bool fWalletUnlockMintOnly;
bool GetTransaction(const uint256 &hashTx, CWalletTx& wtx);
- bool ExtractAddress(const CScript& scriptPubKey, std::string& addressRet);
+ bool ExtractAddress(const CScript& scriptPubKey, CBitcoinAddress& addressRet);
bool SetDefaultKey(const CPubKey &vchPubKey);