Last active
November 29, 2018 18:46
Revisions
-
jl2012 revised this gist
Nov 29, 2018 . 1 changed file with 2 additions and 1 deletion.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -2,6 +2,8 @@ const int inputtype = nHashType & SIGHASH2_INPUT_MASK; const int outputtype = nHashType & SIGHASH2_OUTPUT_MASK; CHashWriter ss(); ss << static_cast<uint8_t>(nHashType); // tx-level data ss << txTo.nVersion; @@ -58,6 +60,5 @@ else { ss << static_cast<uint8_t>(codeseparator_position); } return ss.GetSingleSHA256(); -
jl2012 revised this gist
Nov 29, 2018 . 1 changed file with 8 additions and 3 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -37,22 +37,27 @@ else { ss << txTo.vin[nIn].nSequence; } if (inputtype == SIGHASH2_NOINPUT_MASKEDSCRIPT) { ss << static_cast<uint8_t>(scriptPubKey.IsPayToScriptHash()); } else { ss << scriptPubKey; } // script-level data if (is_direct_spending) { assert(inputtype != SIGHASH2_NOINPUT_MASKEDSCRIPT); } else { if (inputtype == SIGHASH2_NOINPUT_MASKEDSCRIPT) { ss << single_sha256_masked_scriptcode; } else { ss << single_sha256_scriptcode; } ss << static_cast<uint8_t>(codeseparator_position); } ss << static_cast<uint8_t>(nHashType); return ss.GetSingleSHA256(); -
jl2012 revised this gist
Nov 29, 2018 . 1 changed file with 2 additions and 7 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -37,22 +37,17 @@ else { ss << txTo.vin[nIn].nSequence; } // script-level data if (is_direct_spending) { assert(inputtype != SIGHASH2_NOINPUT_MASKEDSCRIPT); } else { if (inputtype == SIGHASH2_NOINPUT_MASKEDSCRIPT) { ss << static_cast<uint8_t>(scriptPubKey.IsPayToScriptHash()); ss << single_sha256_masked_scriptcode; } else { ss << scriptPubKey; ss << single_sha256_scriptcode; } ss << static_cast<uint8_t>(codeseparator_position); -
jl2012 created this gist
Nov 29, 2018 .There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,63 @@ const int inputtype = nHashType & SIGHASH2_INPUT_MASK; const int outputtype = nHashType & SIGHASH2_OUTPUT_MASK; CHashWriter ss(); // tx-level data ss << txTo.nVersion; if (inputtype == SIGHASH2_ALL) { ss << single_sha256_prevouts; ss << single_sha256_amounts; ss << single_sha256_sequence; } // else { do nothing } if (outputtype == SIGHASH2_ALLOUTPUT) { ss << single_sha256_outputs; } else if (outputtype == SIGHASH2_SINGLEOUTPUT) { assert(nIn < txTo.vout.size()); ss << txTo.vout[nIn]; } // else if (outputtype == SIGHASH2_NOOUTPUT) { do nothing } else if (outputtype != SIGHASH2_NOOUTPUT) { assert(!"invalid SIGHASH2"); } ss << txTo.nLockTime; // input-level data if (inputtype == SIGHASH2_ALL) { ss << static_cast<uint16_t>(nIn); } else { if (inputtype == SIGHASH2_SINGLEINPUT) { ss << txTo.vin[nIn].prevout; } ss << amount; ss << txTo.vin[nIn].nSequence; } if (inputtype == SIGHASH2_NOINPUT_MASKEDSCRIPT) { ss << static_cast<uint8_t>(scriptPubKey.IsPayToScriptHash()); } else { ss << scriptPubKey; } // script-level data if (is_direct_spending) { assert(inputtype != SIGHASH2_NOINPUT_MASKEDSCRIPT); } else { if (inputtype == SIGHASH2_NOINPUT_MASKEDSCRIPT) { ss << single_sha256_masked_scriptcode; } else { ss << single_sha256_scriptcode; } ss << static_cast<uint8_t>(codeseparator_position); } ss << static_cast<uint8_t>(nHashType); return ss.GetSingleSHA256();