Move the last remaining script-related things out of the rpcclient.
RPC client shouldn't build scripts and this function can be useful as a reusable building block.