Fix giving and receiving amounts

Fixes #1127, and a few other bugs (including the 4th item of #2630).
What's the meaning of `is_funded=NULL`? Can `is_funded` be a two-state boolean, `NOT NULL`?