code: public TransactionSignature calculateSignature(int inputIndex, ECKey key,
                                                                  byte[] redeemScript,
                                                                  SigHash hashType, boolean anyoneCanPay) {
          Sha256Hash hash = hashForSignature(inputIndex, redeemScript, hashType, anyoneCanPay);
          return new TransactionSignature(key.sign(hash), hashType, anyoneCanPay);
      }
docs: Calculates a signature that is valid for being inserted into the input at the given position. This is simply
  a wrapper around calling {@link Transaction#hashForSignature(int, byte[], Transaction.SigHash, boolean)}
  followed by {@link ECKey#sign(Sha256Hash)} and then returning a new {@link TransactionSignature}. The key
  must be usable for signing as-is: if the key is encrypted it must be decrypted first external to this method.
  
  @param inputIndex Which input to calculate the signature for, as an index.
  @param key The private key used to calculate the signature.
  @param redeemScript Byte-exact contents of the scriptPubKey that is being satisified, or the P2SH redeem script.
  @param hashType Signing mode, see the enum for documentation.
  @param anyoneCanPay Signing mode, see the SigHash enum for documentation.
  @return A newly calculated signature object that wraps the r, s and sighash components.