According to BIP143, there is no such length. So I assume 0.15.1 is the correct implementation.
https://github.com/bitcoin/bips/blob/master/bip-0143.mediawiki On 29/04/2019 09.31, jingi.jay.j...@gmail.com wrote: > Hi all, > > I have a question for the hashForWitnessSignature funciton. > There is a different between 0.15.1 and Segwit branch at > hashForWitnessSignature function. > There is no code to write the length of script code in case of 0.15.1. > > In 0.15.1, is it supposed the length of script already included in > scriptCode? > > > In 0.15.1 TAG > > uint32ToByteStreamLE(version, bos); > bos.write(hashPrevouts); > bos.write(hashSequence); > bos.write(inputs.get(inputIndex).getOutpoint().getHash().getReversedBytes()); > uint32ToByteStreamLE(inputs.get(inputIndex).getOutpoint().getIndex(), bos); > bos.write(scriptCode); > uint64ToByteStreamLE(BigInteger.valueOf(prevValue.getValue()), bos); > uint32ToByteStreamLE(inputs.get(inputIndex).getSequenceNumber(), bos); > bos.write(hashOutputs); > uint32ToByteStreamLE(this.lockTime, bos); > uint32ToByteStreamLE(0x000000ff & sigHashType, bos); > > > > In Segwit Branch > > > uint32ToByteStreamLE(version, bos); > bos.write(hashPrevouts); > bos.write(hashSequence); > bos.write(inputs.get(inputIndex).getOutpoint().getHash().getReversedBytes()); > uint32ToByteStreamLE(inputs.get(inputIndex).getOutpoint().getIndex(), bos); > bos.write(new VarInt(connectedScript.length).encode()); > bos.write(connectedScript); > uint64ToByteStreamLE(BigInteger.valueOf(prevValue.getValue()), bos); > uint32ToByteStreamLE(inputs.get(inputIndex).getSequenceNumber(), bos); > bos.write(hashOutputs); > uint32ToByteStreamLE(this.lockTime, bos); > uint32ToByteStreamLE(0x000000ff & sigHashType, bos); > > > Best regards > Jingi > > -- > You received this message because you are subscribed to the Google > Groups "bitcoinj" group. > To unsubscribe from this group and stop receiving emails from it, send > an email to bitcoinj+unsubscr...@googlegroups.com > <mailto:bitcoinj+unsubscr...@googlegroups.com>. > For more options, visit https://groups.google.com/d/optout. -- You received this message because you are subscribed to the Google Groups "bitcoinj" group. To unsubscribe from this group and stop receiving emails from it, send an email to bitcoinj+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/d/optout.