* Sign scriptPubKey using signature made with creator. * Signatures are returned in scriptSigRet (or returns false if scriptPubKey can't be signed), * unless whichTypeRet is TX_SCRIPTHASH, in which case scriptSigRet is the redemption script. * Returns false if scriptPubKey could not be completely satisfied. */
| 62 | * Returns false if scriptPubKey could not be completely satisfied. |
| 63 | */ |
| 64 | static bool SignStep(const BaseSignatureCreator& creator, const CScript& scriptPubKey, |
| 65 | CScript& scriptSigRet, txnouttype& whichTypeRet) |
| 66 | { |
| 67 | scriptSigRet.clear(); |
| 68 | |
| 69 | vector<valtype> vSolutions; |
| 70 | if (!Solver(scriptPubKey, whichTypeRet, vSolutions)) |
| 71 | return false; |
| 72 | |
| 73 | CKeyID keyID; |
| 74 | switch (whichTypeRet) |
| 75 | { |
| 76 | case TX_NONSTANDARD: |
| 77 | case TX_NULL_DATA: |
| 78 | return false; |
| 79 | case TX_PUBKEY: |
| 80 | keyID = CPubKey(vSolutions[0]).GetID(); |
| 81 | return Sign1(keyID, creator, scriptPubKey, scriptSigRet); |
| 82 | case TX_PUBKEYHASH: |
| 83 | keyID = CKeyID(uint160(vSolutions[0])); |
| 84 | if (!Sign1(keyID, creator, scriptPubKey, scriptSigRet)) |
| 85 | return false; |
| 86 | else |
| 87 | { |
| 88 | CPubKey vch; |
| 89 | creator.KeyStore().GetPubKey(keyID, vch); |
| 90 | scriptSigRet << ToByteVector(vch); |
| 91 | } |
| 92 | return true; |
| 93 | case TX_SCRIPTHASH: |
| 94 | return creator.KeyStore().GetCScript(uint160(vSolutions[0]), scriptSigRet); |
| 95 | |
| 96 | case TX_MULTISIG: |
| 97 | scriptSigRet << OP_0; // workaround CHECKMULTISIG bug |
| 98 | return (SignN(vSolutions, creator, scriptPubKey, scriptSigRet)); |
| 99 | } |
| 100 | return false; |
| 101 | } |
| 102 | |
| 103 | bool ProduceSignature(const BaseSignatureCreator& creator, const CScript& fromPubKey, CScript& scriptSig) |
| 104 | { |
no test coverage detected