docs: public void correctlySpends(Transaction txContainingThis, int scriptSigIndex, @Nullable TransactionWitness witness, @Nullable Coin value,
              Script scriptPubKey, Set<VerifyFlag> verifyFlags) throws ScriptException {
          if (ScriptPattern.isP2WPKH(scriptPubKey)) {
              // For SegWit, full validation isn't implemented. So we simply check the signature. P2SH_P2WPKH is handled
              // by the P2SH code for now.
              if (witness.getPushCount() < 2)
                  throw new ScriptException(ScriptError.SCRIPT_ERR_WITNESS_PROGRAM_WITNESS_EMPTY, witness.toString());
              TransactionSignature signature;
              try {
                  signature = TransactionSignature.decodeFromBitcoin(witness.getPush(0), true, true);
              } catch (SignatureDecodeException x) {
                  throw new ScriptException(ScriptError.SCRIPT_ERR_SIG_DER, "Cannot decode", x);
              }
              ECKey pubkey = ECKey.fromPublicOnly(witness.getPush(1));
              Script scriptCode = new ScriptBuilder().data(ScriptBuilder.createP2PKHOutputScript(pubkey).getProgram())
                      .build();
              Sha256Hash sigHash = txContainingThis.hashForWitnessSignature(scriptSigIndex, scriptCode, value,
                      signature.sigHashMode(), false);
              boolean validSig = pubkey.verify(sigHash, signature);
              if (!validSig)
                  throw new ScriptException(ScriptError.SCRIPT_ERR_CHECKSIGVERIFY, "Invalid signature");
          } else {
              correctlySpends(txContainingThis, scriptSigIndex, scriptPubKey, verifyFlags);
          }
      }