To simulate traveling-wave tubes (TWTs) in time domain and more generally the wave-particle interaction in vacuum devices, we developed the DIscrete MOdel with HAmiltonian approach (dimoha) as an alternative to current particle-in-cell (PIC) and frequency approaches. Indeed, it is based on a longitudinal N -body Hamiltonian approach satisfying Maxwell's equations. Advantages of dimoha comprise: (i) it allows arbitrary waveform (not just field envelope), including continuous waveform (CW), multiple carriers or digital modulations (shift keying); (ii) the algorithm is much faster than PIC codes thanks to a field discretization allowing a drastic degree-of-freedom reduction, along with a robust symplectic integrator; (iii) it supports any periodic slow-wave structure design such as helix or folded waveguides; (iv) it reproduces harmonic generation, reflection, oscillation and distortion phenomena; (v) it handles nonlinear dynamics, including intermodulations, trapping and chaos. dimoha accuracy is assessed by comparing it against measurements from a commercial Ku-band tapered helix TWT and against simulations from a sub-THz folded waveguide TWT with a staggered double-grating slow-wave structure. The algorithm is also tested for multiple-carriers simulations with success. PACS numbers: 45.20.Jj (Lagrangian and hamiltonian mechanics), 52.40.Mj (Particle beam interaction in plasmas), 84.40.Fe (Microwave tubes)