docs: public TransactionInput addSignedInput(TransactionOutPoint prevOut, Script scriptPubKey, ECKey sigKey,
                                             SigHash sigHash, boolean anyoneCanPay) throws ScriptException {
          // Verify the API user didn't try to do operations out of order.
          checkState(!outputs.isEmpty(), "Attempting to sign tx without outputs.");
          TransactionInput input = new TransactionInput(params, this, new byte[] {}, prevOut);
          addInput(input);
          int inputIndex = inputs.size() - 1;
          if (ScriptPattern.isP2PK(scriptPubKey)) {
              TransactionSignature signature = calculateSignature(inputIndex, sigKey, scriptPubKey, sigHash,
                      anyoneCanPay);
              input.setScriptSig(ScriptBuilder.createInputScript(signature));
              input.setWitness(null);
          } else if (ScriptPattern.isP2PKH(scriptPubKey)) {
              TransactionSignature signature = calculateSignature(inputIndex, sigKey, scriptPubKey, sigHash,
                      anyoneCanPay);
              input.setScriptSig(ScriptBuilder.createInputScript(signature, sigKey));
              input.setWitness(null);
          } else if (ScriptPattern.isP2WPKH(scriptPubKey)) {
              Script scriptCode = new ScriptBuilder()
                      .data(ScriptBuilder.createOutputScript(LegacyAddress.fromKey(params, sigKey)).getProgram()).build();
              TransactionSignature signature = calculateWitnessSignature(inputIndex, sigKey, scriptCode, input.getValue(),
                      sigHash, anyoneCanPay);
              input.setScriptSig(ScriptBuilder.createEmpty());
              input.setWitness(TransactionWitness.redeemP2WPKH(signature, sigKey));
          } else {
              throw new ScriptException(ScriptError.SCRIPT_ERR_UNKNOWN_ERROR, "Don't know how to sign for this kind of scriptPubKey: " + scriptPubKey);
          }
          return input;
      }