public static RedeemData of(List<ECKey> keys, Script redeemScript) { return of(keys, redeemScript, false); }
public static RedeemData of(ECKey key, Script program) { return of(key, program, false); }
private RedeemData maybeDecrypt(RedeemData redeemData) { List<ECKey> decryptedKeys = new ArrayList<>(); for (ECKey key : redeemData.keys) { decryptedKeys.add(maybeDecrypt(key)); } return RedeemData.of(decryptedKeys, redeemData.redeemScript, redeemData.isP2SHofP2WPKH); }
private RedeemData maybeDecrypt(RedeemData redeemData) { List<ECKey> decryptedKeys = new ArrayList<ECKey>(); for (ECKey key : redeemData.keys) { decryptedKeys.add(maybeDecrypt(key)); } return RedeemData.of(decryptedKeys, redeemData.redeemScript); }
private RedeemData maybeDecrypt(RedeemData redeemData) { List<ECKey> decryptedKeys = new ArrayList<ECKey>(); for (ECKey key : redeemData.keys) { decryptedKeys.add(maybeDecrypt(key)); } return RedeemData.of(decryptedKeys, redeemData.redeemScript); }
private RedeemData maybeDecrypt(RedeemData redeemData) { List<ECKey> decryptedKeys = new ArrayList<>(); for (ECKey key : redeemData.keys) { decryptedKeys.add(maybeDecrypt(key)); } return RedeemData.of(decryptedKeys, redeemData.redeemScript); }
/** Get the redeem data for a key in this married chain */ @Override public RedeemData getRedeemData(DeterministicKey followedKey) { List<ECKey> marriedKeys = getMarriedKeysWithFollowed(followedKey); Script redeemScript = ScriptBuilder.createRedeemScript(sigsRequiredToSpend, marriedKeys); return RedeemData.of(marriedKeys, redeemScript); }
/** Get the redeem data for a key in this married chain */ @Override public RedeemData getRedeemData(DeterministicKey followedKey) { List<ECKey> marriedKeys = getMarriedKeysWithFollowed(followedKey); Script redeemScript = ScriptBuilder.createRedeemScript(sigsRequiredToSpend, marriedKeys); return RedeemData.of(marriedKeys, redeemScript); }
/** Get the redeem data for a key in this married chain */ @Override public RedeemData getRedeemData(DeterministicKey followedKey) { List<ECKey> marriedKeys = getMarriedKeysWithFollowed(followedKey); Script redeemScript = ScriptBuilder.createRedeemScript(sigsRequiredToSpend, marriedKeys); return RedeemData.of(marriedKeys, redeemScript); }
/** Get the redeem data for a key in this married chain */ @Override public RedeemData getRedeemData(DeterministicKey followedKey) { List<ECKey> marriedKeys = getMarriedKeysWithFollowed(followedKey); Script redeemScript = ScriptBuilder.createRedeemScript(sigsRequiredToSpend, marriedKeys); return RedeemData.of(marriedKeys, redeemScript); }
/** Returns the redeem script by its hash or null if this keychain did not generate the script. */ @Nullable public RedeemData findRedeemDataByScriptHash(ByteString bytes) { if (this.useSegwit) { for(ECKey key: getKeys(false, true)) { // see if this is a P2SH-of-P2WPKH for one of our keys Script pay2wpkh = ScriptBuilder.createP2WPKHOutputScript(key); Script pay2sh = ScriptBuilder.createP2SHOutputScript(pay2wpkh); if (Arrays.equals(pay2sh.getPubKeyHash(), bytes.toByteArray())) { return RedeemData.of(key, pay2wpkh, true); } } } return null; } }
/** * Returns the RedeemData identified in the connected output, for either pay-to-address scripts, pay-to-key * or P2SH scripts. * If the script forms cannot be understood, throws ScriptException. * * @return a RedeemData or null if the connected data cannot be found in the wallet. */ @Nullable public RedeemData getConnectedRedeemData(KeyBag keyBag) throws ScriptException { TransactionOutput connectedOutput = getConnectedOutput(); checkNotNull(connectedOutput, "Input is not connected so cannot retrieve key"); Script connectedScript = connectedOutput.getScriptPubKey(); if (connectedScript.isSentToAddress()) { byte[] addressBytes = connectedScript.getPubKeyHash(); return RedeemData.of(keyBag.findKeyFromPubHash(addressBytes), connectedScript); } else if (connectedScript.isSentToRawPubKey()) { byte[] pubkeyBytes = connectedScript.getPubKey(); return RedeemData.of(keyBag.findKeyFromPubKey(pubkeyBytes), connectedScript); } else if (connectedScript.isPayToScriptHash()) { byte[] scriptHash = connectedScript.getPubKeyHash(); return keyBag.findRedeemDataFromScriptHash(scriptHash); } else { throw new ScriptException("Could not understand form of connected output script: " + connectedScript); } }
/** * Returns the RedeemData identified in the connected output, for either pay-to-address scripts, pay-to-key * or P2SH scripts. * If the script forms cannot be understood, throws ScriptException. * * @return a RedeemData or null if the connected data cannot be found in the wallet. */ @Nullable public RedeemData getConnectedRedeemData(KeyBag keyBag) throws ScriptException { TransactionOutput connectedOutput = getConnectedOutput(); checkNotNull(connectedOutput, "Input is not connected so cannot retrieve key"); Script connectedScript = connectedOutput.getScriptPubKey(); if (connectedScript.isSentToAddress()) { byte[] addressBytes = connectedScript.getPubKeyHash(); return RedeemData.of(keyBag.findKeyFromPubHash(addressBytes), connectedScript); } else if (connectedScript.isSentToRawPubKey()) { byte[] pubkeyBytes = connectedScript.getPubKey(); return RedeemData.of(keyBag.findKeyFromPubKey(pubkeyBytes), connectedScript); } else if (connectedScript.isPayToScriptHash()) { byte[] scriptHash = connectedScript.getPubKeyHash(); return keyBag.findRedeemDataFromScriptHash(scriptHash); } else { throw new ScriptException(ScriptError.SCRIPT_ERR_UNKNOWN_ERROR, "Could not understand form of connected output script: " + connectedScript); } }
/** * Returns the RedeemData identified in the connected output, for either pay-to-address scripts, pay-to-key * or P2SH scripts. * If the script forms cannot be understood, throws ScriptException. * * @return a RedeemData or null if the connected data cannot be found in the wallet. */ @Nullable public RedeemData getConnectedRedeemData(KeyBag keyBag) throws ScriptException { TransactionOutput connectedOutput = getConnectedOutput(); checkNotNull(connectedOutput, "Input is not connected so cannot retrieve key"); Script connectedScript = connectedOutput.getScriptPubKey(); if (connectedScript.isSentToAddress()) { byte[] addressBytes = connectedScript.getPubKeyHash(); return RedeemData.of(keyBag.findKeyFromPubHash(addressBytes), connectedScript); } else if (connectedScript.isSentToRawPubKey()) { byte[] pubkeyBytes = connectedScript.getPubKey(); return RedeemData.of(keyBag.findKeyFromPubKey(pubkeyBytes), connectedScript); } else if (connectedScript.isPayToScriptHash()) { byte[] scriptHash = connectedScript.getPubKeyHash(); return keyBag.findRedeemDataFromScriptHash(scriptHash); } else { throw new ScriptException("Could not understand form of connected output script: " + connectedScript); } }
/** * Returns the RedeemData identified in the connected output, for either pay-to-address scripts, pay-to-key * or P2SH scripts. * If the script forms cannot be understood, throws ScriptException. * * @return a RedeemData or null if the connected data cannot be found in the wallet. */ @Nullable public RedeemData getConnectedRedeemData(KeyBag keyBag) throws ScriptException { TransactionOutput connectedOutput = getConnectedOutput(); checkNotNull(connectedOutput, "Input is not connected so cannot retrieve key"); Script connectedScript = connectedOutput.getScriptPubKey(); if (connectedScript.isSentToAddress()) { byte[] addressBytes = connectedScript.getPubKeyHash(); return RedeemData.of(keyBag.findKeyFromPubHash(addressBytes), connectedScript); } else if (connectedScript.isSentToRawPubKey()) { byte[] pubkeyBytes = connectedScript.getPubKey(); return RedeemData.of(keyBag.findKeyFromPubKey(pubkeyBytes), connectedScript); } else if (connectedScript.isPayToScriptHash()) { byte[] scriptHash = connectedScript.getPubKeyHash(); return keyBag.findRedeemDataFromScriptHash(scriptHash); } else { throw new ScriptException("Could not understand form of connected output script: " + connectedScript); } }