public void UntrustedHashTransactionInputStart(bool newTransaction, IndexedTxIn txIn, TrustedInput[] trustedInputs)
 {
     using(Transport.Lock())
     {
         trustedInputs = trustedInputs ?? new TrustedInput[0];
         // Start building a fake transaction with the passed inputs
         MemoryStream data = new MemoryStream();
         BufferUtils.WriteBuffer(data, txIn.Transaction.Version);
         VarintUtils.write(data, txIn.Transaction.Inputs.Count);
         ExchangeApdu(LedgerWalletConstants.LedgerWallet_CLA, LedgerWalletConstants.LedgerWallet_INS_HASH_INPUT_START, (byte)0x00, (newTransaction ? (byte)0x00 : (byte)0x80), data.ToArray(), OK);
         // Loop for each input
         long currentIndex = 0;
         foreach(var input in txIn.Transaction.Inputs)
         {
             var trustedInput = trustedInputs.FirstOrDefault(i => i.OutPoint == input.PrevOut);
             byte[] script = (currentIndex == txIn.Index ? txIn.TxIn.ScriptSig.ToBytes() : new byte[0]);
             data = new MemoryStream();
             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);
             ExchangeApdu(LedgerWalletConstants.LedgerWallet_CLA, LedgerWalletConstants.LedgerWallet_INS_HASH_INPUT_START, (byte)0x80, (byte)0x00, data.ToArray(), OK);
             data = new MemoryStream();
             BufferUtils.WriteBuffer(data, script);
             BufferUtils.WriteBuffer(data, input.Sequence);
             ExchangeApduSplit(LedgerWalletConstants.LedgerWallet_CLA, LedgerWalletConstants.LedgerWallet_INS_HASH_INPUT_START, (byte)0x80, (byte)0x00, data.ToArray(), OK);
             currentIndex++;
         }
     }
 }
 public void UntrustedHashTransactionInputStart(bool newTransaction, Transaction tx, int index, TrustedInput[] trustedInputs)
 {
     UntrustedHashTransactionInputStart(newTransaction, tx.Inputs.AsIndexedInputs().Skip(index).First(), trustedInputs);
 }