MCPcopy Create free account
hub / github.com/bitcoinxt/bitcoinxt / SignStep

Function SignStep

src/script/sign.cpp:64–101  ·  view source on GitHub ↗

* 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. */

Source from the content-addressed store, hash-verified

62 * Returns false if scriptPubKey could not be completely satisfied.
63 */
64static 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
103bool ProduceSignature(const BaseSignatureCreator& creator, const CScript& fromPubKey, CScript& scriptSig)
104{

Callers 1

ProduceSignatureFunction · 0.85

Calls 11

SolverFunction · 0.85
Sign1Function · 0.85
ToByteVectorFunction · 0.85
SignNFunction · 0.85
GetIDMethod · 0.80
GetCScriptMethod · 0.80
CPubKeyClass · 0.70
CKeyIDClass · 0.70
uint160Class · 0.50
clearMethod · 0.45
GetPubKeyMethod · 0.45

Tested by

no test coverage detected