itemOutput->setCheckState(COLUMN_CHECKBOX,Qt::Unchecked);
// address
+/*
CTxDestination outputAddress;
QString sAddress = "";
if(ExtractDestination(out.tx->vout[out.i].scriptPubKey, outputAddress))
if (keyid && model->getPubKey(*keyid, pubkey) && !pubkey.IsCompressed())
nInputSize = 180;
}
+*/
+ QString sAddress = "";
+ txnouttype whichType;
+ std::vector<valtype> vSolutions;
+ if (Solver(out.tx->vout[out.i].scriptPubKey, whichType, vSolutions))
+ {
+ CTxDestination address;
+ if (whichType == TX_PUBKEY)
+ {
+ // Pay-to-Pubkey
+ CPubKey pubKey = CPubKey(vSolutions[0]);
+ address = pubKey.GetID();
+ sAddress = CBitcoinAddress(address).ToString().c_str();
+
+ if (!pubKey.IsCompressed())
+ nInputSize = 180;
+ }
+ else if (whichType == TX_PUBKEYHASH)
+ {
+ // Pay-to-PubkeyHash
+ address = CKeyID(uint160(vSolutions[0]));
+ sAddress = CBitcoinAddress(address).ToString().c_str();
+
+ CPubKey pubkey;
+ CKeyID *keyid = boost::get< CKeyID >(&address);
+ if (keyid && model->getPubKey(*keyid, pubkey) && !pubkey.IsCompressed())
+ nInputSize = 180;
+ }
+ else if (whichType == TX_SCRIPTHASH)
+ {
+ // Pay-to-ScriptHash
+ address = CScriptID(uint160(vSolutions[0]));
+ sAddress = CBitcoinAddress(address).ToString().c_str();
+ }
+ else if (whichType == TX_PUBKEY_DROP)
+ {
+ // Pay-to-Pubkey-R
+ CMalleableKeyView view;
+ pwalletMain->CheckOwnership(CPubKey(vSolutions[0]), CPubKey(vSolutions[1]), view);
+ sAddress = view.GetMalleablePubKey().ToString().c_str();
+ }
+
+ // if listMode or change => show bitcoin address. In tree mode, address is not shown again for direct wallet address outputs
+ if (!treeMode || (!(sAddress == sWalletAddress)))
+ itemOutput->setText(COLUMN_ADDRESS, sAddress);
+ }
// label
if (!(sAddress == sWalletAddress)) // change
sub.idx = parts.size(); // sequence number
sub.credit = txout.nValue;
- txnouttype whichType;
- std::vector<valtype> vSolutions;
- if (Solver(txout.scriptPubKey, whichType, vSolutions))
+ std::string address;
+ if (pwalletMain->ExtractAddress(txout.scriptPubKey, address))
{
- CTxDestination address;
- if (whichType == TX_PUBKEY)
- {
- // Pay-to-Pubkey
- address = CPubKey(vSolutions[0]).GetID();
- sub.type = TransactionRecord::RecvWithAddress;
- sub.address = CBitcoinAddress(address).ToString();
- }
- else if (whichType == TX_PUBKEYHASH)
- {
- // Pay-to-PubkeyHash
- address = CKeyID(uint160(vSolutions[0]));
- sub.type = TransactionRecord::RecvWithAddress;
- sub.address = CBitcoinAddress(address).ToString();
- }
- else if (whichType == TX_SCRIPTHASH)
- {
- // Pay-to-ScriptHash
- address = CScriptID(uint160(vSolutions[0]));
- sub.type = TransactionRecord::RecvWithAddress;
- sub.address = CBitcoinAddress(address).ToString();
- }
- else if (whichType == TX_PUBKEY_DROP)
- {
- // Pay-to-Pubkey-R
- sub.type = TransactionRecord::RecvWithAddress;
-
- CMalleableKeyView view;
- pwalletMain->CheckOwnership(CPubKey(vSolutions[0]), CPubKey(vSolutions[1]), view);
- sub.address = view.GetMalleablePubKey().ToString();
- }
- else
- {
- // Received by IP connection (deprecated features), or a multisignature or other non-simple transaction
- sub.type = TransactionRecord::RecvFromOther;
- sub.address = mapValue["from"];
- }
+ sub.type = TransactionRecord::RecvWithAddress;
+ sub.address = address;
}
+ else
+ {
+ // Received by IP connection (deprecated features), or a multisignature or other non-simple transaction
+ sub.type = TransactionRecord::RecvFromOther;
+ sub.address = mapValue["from"];
+ }
+
if (wtx.IsCoinBase())
{
// Generated (proof-of-work)
cout = COutput(&wallet->mapWallet[cout.tx->vin[0].prevout.hash], cout.tx->vin[0].prevout.n, 0, true);
}
- CTxDestination address;
- if(!out.fSpendable || !ExtractDestination(cout.tx->vout[cout.i].scriptPubKey, address))
+ std::string address;
+ if(!out.fSpendable || !wallet->ExtractAddress(cout.tx->vout[cout.i].scriptPubKey, address))
continue;
- mapCoins[CBitcoinAddress(address).ToString().c_str()].push_back(out);
+
+ mapCoins[address.c_str()].push_back(out);
}
}
for(list<uint256>::const_iterator it = orphans.begin(); it != orphans.end(); ++it)
EraseFromWallet(*it);
}
+
+bool CWallet::ExtractAddress(const CScript& scriptPubKey, std::string& addressRet)
+{
+ vector<valtype> vSolutions;
+ txnouttype whichType;
+ if (!Solver(scriptPubKey, whichType, vSolutions))
+ return false;
+
+ if (whichType == TX_PUBKEY)
+ {
+ addressRet = CBitcoinAddress(CPubKey(vSolutions[0]).GetID()).ToString();
+ return true;
+ }
+ if (whichType == TX_PUBKEY_DROP)
+ {
+ // Pay-to-Pubkey-R
+ CMalleableKeyView view;
+ if (!CheckOwnership(CPubKey(vSolutions[0]), CPubKey(vSolutions[1]), view))
+ return false;
+
+ addressRet = view.GetMalleablePubKey().ToString();
+ return true;
+ }
+ else if (whichType == TX_PUBKEYHASH)
+ {
+ addressRet = CBitcoinAddress(CKeyID(uint160(vSolutions[0]))).ToString();
+ return true;
+ }
+ else if (whichType == TX_SCRIPTHASH)
+ {
+ addressRet = CBitcoinAddress(CScriptID(uint160(vSolutions[0]))).ToString();
+ return true;
+ }
+ // Multisig txns have more than one address...
+ return false;
+}
bool GetTransaction(const uint256 &hashTx, CWalletTx& wtx);
+ bool ExtractAddress(const CScript& scriptPubKey, std::string& addressRet);
+
bool SetDefaultKey(const CPubKey &vchPubKey);
// signify that a particular wallet feature is now used. this may change nWalletVersion and nWalletMaxVersion if those are lower