Fixed a bug in the spending API.