Add Script.getCastedToAddress()…

…which tries harder than .getToAddress() to determine a destination address.

I ended up duplicating this piece of code several times, so I thought it may be useful to have it in the framework.