backport preferred master changes from 1.7 + required dependencies

(GET_TXID, NOP, Client_main.with_connection')

Gonna run it through CI again when it's back up & running, but you can already have a look.