3
0
mirror of https://github.com/Qortal/altcoinj.git synced 2025-02-14 19:25:51 +00:00

Script.toAddress now can cast to P2SH addresses.

This commit is contained in:
Mike Hearn 2013-12-10 11:45:29 -08:00
parent ea6f2a0fc3
commit 81f8b230e3

View File

@ -281,11 +281,14 @@ public class Script {
/**
* Gets the destination address from this script, if it's in the required form (see getPubKey).
*
* @throws ScriptException
*/
public Address getToAddress(NetworkParameters params) throws ScriptException {
return new Address(params, getPubKeyHash());
if (isSentToAddress())
return new Address(params, getPubKeyHash());
else if (isSentToP2SH())
return Address.fromP2SHScript(params, this);
else
throw new ScriptException("Cannot cast this script to a pay-to-address type");
}
////////////////////// Interface for writing scripts from scratch ////////////////////////////////