Nope, not illegal at all. Happened in the Compromise of 1877, although there was a wink and nod. And, yes, Trump would uphold his end or he would get NO senate confirmation of any justice. That’s why it’s a good deal for all.
What makes you so sure he wouldn’t get any confirmation if he reneged on the deal?