CLI voter-registration: Prelude.undefined error

voter-registration command is failing with:

voter-registration \
    --payment-signing-key payment.skey \
    --payment-address $(cat payment.addr) \
    --vote-public-key \
    --stake-signing-key stake.skey \
    --mainnet \
    --time-to-live 5000 \
    --out-file vote.signed


voter-registration: Prelude.undefined
CallStack (from HasCallStack):
  error, called at libraries/base/GHC/Err.hs:79:14 in base:GHC.Err
  undefined, called at src/Cardano/CLI/Voting.hs:123:21 in voter-registration-

From the Stake Pool Operators telegram group:

I got that error too. The problem was in the payment.addr . Because that file has the enterprise addres but not the public address

My understanding is that --time-to-live refers to a slot number until which the transaction is valid. I used the slotNo result from cardano-cli query tip --mainnet plus 2000 or so.

cardano-cli query tip --mainnet
    "blockNo": 5081332,
    "headerHash": "132cd56e3e4ddce4c10f06f0315932133e0736eacb952ba2d5372e36628262a1",
    "slotNo": 16481737 <-- add some margin to this

The payment address is just used to pay for the transaction so as long as it has funds, it should be OK. The change also goes to payment.addr.