docs: public static Script createOutputScript(Address to) {
          if (to instanceof LegacyAddress) {
              ScriptType scriptType = to.getOutputScriptType();
              if (scriptType == ScriptType.P2PKH)
                  return createP2PKHOutputScript(to.getHash());
              else if (scriptType == ScriptType.P2SH)
                  return createP2SHOutputScript(to.getHash());
              else
                  throw new IllegalStateException("Cannot handle " + scriptType);
          } else if (to instanceof SegwitAddress) {
              ScriptBuilder builder = new ScriptBuilder();
              // OP_0 <pubKeyHash|scriptHash>
              SegwitAddress toSegwit = (SegwitAddress) to;
              builder.smallNum(toSegwit.getWitnessVersion());
              builder.data(toSegwit.getWitnessProgram());
              return builder.build();
          } else {
              throw new IllegalStateException("Cannot handle " + to);
          }
      }