Previously, returned null if a scriptpubkey was not Segwit; now handles encoding to Base58 for other types.
We're going to need this for P2WSH scripts. pull it out into a common file plus adopt the sanity checks so that it will allow for either P2WSH or P2WPKH (previously only encoded P2WPKH scripts)