src/tx.js
// Calculate the sighash for the 0th input of a 1-input 1-output tx.
Calculate the sighash for the 0th input of a 1-input 1-output tx.
Calculate the sighash for the 0th input of a 1 - input 1 - output tx .
function wpkhToWpkhSighashAll(
  outpoint,
  inputPKH,
  inputValue, 
  outputValue, 
  outputPKH
) {
  const scriptCode = utils.concatUint8Arrays(
    new Uint8Array([0x19, 0x76, 0xa9, 0x14]), 
    inputPKH,
    new Uint8Array([0x88, 0xac]) 
  );
  const outputScript = utils.concatUint8Arrays(
    new Uint8Array([0x16, 0x00, 0x14]), 
    outputPKH
  );
  const hashOutputs = hash256(utils.concatUint8Arrays(
    outputValue,
    outputScript
  ));
  const sighashPreimage = utils.concatUint8Arrays(
    new Uint8Array([0x01, 0x00, 0x00, 0x00]), 
    hash256(outpoint),
    utils.deserializeHex('8cb9012517c817fead650287d61bdd9c68803b6bf9c64133dcab3e65b5a50cb9'), 
    outpoint,
    scriptCode,
    inputValue,
    new Uint8Array([0x00, 0x00, 0x00, 0x00]), 
    hashOutputs,
    new Uint8Array([0x00, 0x00, 0x00, 0x00]), 
    new Uint8Array([0x01, 0x00, 0x00, 0x00]) 
  );
  return hash256(sighashPreimage);
}
function wpkhToWpkhSighashAll ( outpoint , inputPKH , inputValue , outputValue , outputPKH ) { const scriptCode = utils . concatUint8Arrays ( new Uint8Array ( [ 0x19 , 0x76 , 0xa9 , 0x14 ] ) , inputPKH , new Uint8Array ( [ 0x88 , 0xac ] ) ) ; const outputScript = utils . concatUint8Arrays ( new Uint8Array ( [ 0x16 , 0x00 , 0x14 ] ) , outputPKH ) ; const hashOutputs = hash256 ( utils . concatUint8Arrays ( outputValue , outputScript ) ) ; const sighashPreimage = utils . concatUint8Arrays ( new Uint8Array ( [ 0x01 , 0x00 , 0x00 , 0x00 ] ) , hash256 ( outpoint ) , utils . deserializeHex ( '8cb9012517c817fead650287d61bdd9c68803b6bf9c64133dcab3e65b5a50cb9' ) , outpoint , scriptCode , inputValue , new Uint8Array ( [ 0x00 , 0x00 , 0x00 , 0x00 ] ) , hashOutputs , new Uint8Array ( [ 0x00 , 0x00 , 0x00 , 0x00 ] ) , new Uint8Array ( [ 0x01 , 0x00 , 0x00 , 0x00 ] ) ) ; return hash256 ( sighashPreimage ) ; }
Calculate the sighash for the 0th input of a 1-input 1-output tx.
Calculate the sighash for the 0th input of a 1 - input 1 - output tx .
// 8-byte LE // 8-byte LE // length, dup, hash160, pkh_length // equal, checksig // wpkh prefix // version // hashSequence(00000000) // input nSequence // nLockTime // SIGHASH_ALL