X-Git-Url: https://git.novaco.in/?p=novacoin.git;a=blobdiff_plain;f=src%2Fscript.cpp;h=26b7c941f428169e910ccea6c0dbe8ae239712c4;hp=9079102c712313c56a826ee31cbdcf58f05e886f;hb=e5e4c598dc43bb5e01b3a30aaeb2dfc9376bd7b4;hpb=bd4a1340b19f76cbb4e0507a30621d0be37394af diff --git a/src/script.cpp b/src/script.cpp index 9079102..26b7c94 100644 --- a/src/script.cpp +++ b/src/script.cpp @@ -1328,6 +1328,21 @@ bool Sign1(const CKeyID& address, const CKeyStore& keystore, const uint256& hash return true; } +bool SignR(const CPubKey& pubKey, const CPubKey& R, const CKeyStore& keystore, const uint256& hash, int nHashType, CScript& scriptSigRet) +{ + CKey key; + if (!keystore.CreatePrivKey(pubKey, R, key)) + return false; + + vector vchSig; + if (!key.Sign(hash, vchSig)) + return false; + vchSig.push_back((unsigned char)nHashType); + scriptSigRet << vchSig; + + return true; +} + bool SignN(const vector& multisigdata, const CKeyStore& keystore, const uint256& hash, int nHashType, CScript& scriptSigRet) { int nSigned = 0; @@ -1364,9 +1379,14 @@ bool Solver(const CKeyStore& keystore, const CScript& scriptPubKey, const uint25 case TX_NULL_DATA: return false; case TX_PUBKEY: - case TX_PUBKEY_DROP: keyID = CPubKey(vSolutions[0]).GetID(); return Sign1(keyID, keystore, hash, nHashType, scriptSigRet); + case TX_PUBKEY_DROP: + { + CPubKey key = CPubKey(vSolutions[0]); + CPubKey R = CPubKey(vSolutions[1]); + return SignR(key, R, keystore, hash, nHashType, scriptSigRet); + } case TX_PUBKEYHASH: keyID = CKeyID(uint160(vSolutions[0])); if (!Sign1(keyID, keystore, hash, nHashType, scriptSigRet)) @@ -1480,11 +1500,23 @@ isminetype IsMine(const CKeyStore &keystore, const CScript& scriptPubKey) case TX_NULL_DATA: break; case TX_PUBKEY: - case TX_PUBKEY_DROP: keyID = CPubKey(vSolutions[0]).GetID(); if (keystore.HaveKey(keyID)) return MINE_SPENDABLE; break; + case TX_PUBKEY_DROP: + { + CPubKey key = CPubKey(vSolutions[0]); + if (keystore.HaveKey(key.GetID())) + return MINE_SPENDABLE; + else + { + CPubKey R = CPubKey(vSolutions[1]); + if (keystore.CheckOwnership(key, R)) + return MINE_SPENDABLE; + } + } + break; case TX_PUBKEYHASH: keyID = CKeyID(uint160(vSolutions[0])); if (keystore.HaveKey(keyID)) @@ -1527,7 +1559,7 @@ bool ExtractDestination(const CScript& scriptPubKey, CTxDestination& addressRet) if (!Solver(scriptPubKey, whichType, vSolutions)) return false; - if (whichType == TX_PUBKEY) + if (whichType == TX_PUBKEY || whichType == TX_PUBKEY_DROP) { addressRet = CPubKey(vSolutions[0]).GetID(); return true;