[bitcoin/bitcoin] Simple refactoring: Common code for decoding of hex «objects» (#14009)

utACK b9a19f32290119f225f7769ba1432fa7904011b3