public byte[][] UntrustedHashTransactionInputStart(
            InputStartType startType,
            IndexedTxIn txIn,
            Dictionary <OutPoint, TrustedInput> trustedInputs,
            Dictionary <OutPoint, ICoin> coins,
            bool segwitMode, bool segwitParsedOnce)
        {
            List <byte[]> apdus = new List <byte[]>();

            trustedInputs = trustedInputs ?? new Dictionary <OutPoint, TrustedInput>();
            // Start building a fake transaction with the passed inputs
            MemoryStream data = new MemoryStream();

            BufferUtils.WriteBuffer(data, txIn.Transaction.Version);

            if (segwitMode && segwitParsedOnce)
            {
                VarintUtils.write(data, 1);
            }
            else
            {
                VarintUtils.write(data, txIn.Transaction.Inputs.Count);
            }

            apdus.Add(CreateAPDU(LedgerWalletConstants.LedgerWallet_CLA, LedgerWalletConstants.LedgerWallet_INS_HASH_INPUT_START, (byte)0x00, (byte)startType, data.ToArray()));
            // Loop for each input
            long currentIndex = 0;

            foreach (var input in txIn.Transaction.Inputs)
            {
                if (segwitMode && segwitParsedOnce && currentIndex != txIn.Index)
                {
                    currentIndex++;
                    continue;
                }
                byte[] script = new byte[0];
                if (currentIndex == txIn.Index || segwitMode && !segwitParsedOnce)
                {
                    script = coins[input.PrevOut].GetScriptCode().ToBytes();
                }

                data = new MemoryStream();
                if (segwitMode)
                {
                    data.WriteByte(0x02);
                    BufferUtils.WriteBuffer(data, input.PrevOut);
                    BufferUtils.WriteBuffer(data, Utils.ToBytes((ulong)coins[input.PrevOut].TxOut.Value.Satoshi, true));
                }
                else
                {
                    var trustedInput = trustedInputs[input.PrevOut];
                    if (trustedInput != null)
                    {
                        data.WriteByte(0x01);
                        var b = trustedInput.ToBytes();
                        // untrusted inputs have constant length
                        data.WriteByte((byte)b.Length);
                        BufferUtils.WriteBuffer(data, b);
                    }
                    else
                    {
                        data.WriteByte(0x00);
                        BufferUtils.WriteBuffer(data, input.PrevOut);
                    }
                }
                VarintUtils.write(data, script.Length);
                apdus.Add(CreateAPDU(LedgerWalletConstants.LedgerWallet_CLA, LedgerWalletConstants.LedgerWallet_INS_HASH_INPUT_START, (byte)0x80, (byte)0x00, data.ToArray()));
                data = new MemoryStream();
                BufferUtils.WriteBuffer(data, script);
                BufferUtils.WriteBuffer(data, input.Sequence);
                apdus.AddRange(CreateAPDUSplit(LedgerWalletConstants.LedgerWallet_CLA, LedgerWalletConstants.LedgerWallet_INS_HASH_INPUT_START, (byte)0x80, (byte)0x00, data.ToArray()));
                currentIndex++;
            }
            return(apdus.ToArray());
        }