docs: public ConnectionResult connect(Transaction transaction, ConnectMode mode) {
          if (!transaction.getTxId().equals(outpoint.getHash()))
              return ConnectionResult.NO_SUCH_TX;
          checkElementIndex((int) outpoint.getIndex(), transaction.getOutputs().size(), "Corrupt transaction");
          TransactionOutput out = transaction.getOutput((int) outpoint.getIndex());
          if (!out.isAvailableForSpending()) {
              if (getParentTransaction().equals(outpoint.fromTx)) {
                  // Already connected.
                  return ConnectionResult.SUCCESS;
              } else if (mode == ConnectMode.DISCONNECT_ON_CONFLICT) {
                  out.markAsUnspent();
              } else if (mode == ConnectMode.ABORT_ON_CONFLICT) {
                  outpoint.fromTx = out.getParentTransaction();
                  return TransactionInput.ConnectionResult.ALREADY_SPENT;
              }
          }
          connect(out);
          return TransactionInput.ConnectionResult.SUCCESS;
      }