X-Git-Url: https://git.novaco.in/?p=novacoin.git;a=blobdiff_plain;f=src%2Fwallet.cpp;h=780c7f4e37b74d4a2aa81eae9ab59bec00137891;hp=d5e3285749483c003ba0cc8e103ec70b7a8a1cb0;hb=9c9ba366ebc85b0d8eef6d962a9fa84cffe0cae7;hpb=9179b06d4a286cd2555df1d94cf8772c918e81d3 diff --git a/src/wallet.cpp b/src/wallet.cpp index d5e3285..780c7f4 100644 --- a/src/wallet.cpp +++ b/src/wallet.cpp @@ -2780,3 +2780,39 @@ void CWallet::ClearOrphans() for(list::const_iterator it = orphans.begin(); it != orphans.end(); ++it) EraseFromWallet(*it); } + +bool CWallet::ExtractAddress(const CScript& scriptPubKey, std::string& addressRet) +{ + vector 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; +}