An easy way is:
select ('x'||lpad(the_hex_value,16,'0'))::bit(64)::bigint;
The left padding with 0 is necessary because the leftmost bit is always going to be interpreted as the sign bit.
Also keep in mind that bigint
is signed, postgres doesn't have built-in unsigned types.