I'm surprised by the amount of interest in my experience, and after reading the comments on this blog (and elsewhere) I think I should provide some more details to clarify things.
Tell the truth
Some commenters were advising to lie to immigration(or lie better). This is BAD advice, yes you may slip through but it raises the stakes if you're caught telling porkies.
The worst thing to happen to me (and anyone else who doesn't lie) was I was refused entry THAT time, and can come back in the future after getting a visa. If you lie, and are caught then:
1) They can arrest, prosecute and imprison you, it is a crime to lie to the CBP agents, although they told me they don't like to do this as they see it as a waste of taxpayers money. But if you insist on not telling the truth, and keep it up throughout questioning, and they don't believe you, you will do time. Then when you're done they'll deport you.
2) They deport you anyway, their say is final (unless you have a visa, in which case a judges say is final if you dispute), and they make a note to never let you into the country ever again, banned, for life.
So in short don't lie, it's not worth it.
Another theme that was common in a number of comments was why they decided refuse entry. The most common guess is that it was for lack of acceptable funds. This is one of the many possible reasons(and it could have been for a combination of reasons) that they may have had, but we don't know. The words used (not exactly, but more or less these words):
At this time we are refusing to grant you admission into the USA under law XYZ, for reasons that the purpose of your journey is not covered under the Visa Waver Program, but that you may in the future apply for a visa (business visa) to enter the USA.
Extract from that what you will.
No Credit Card no entry
On why I didn't have a credit card (or more cash), $600 is all I could rustle up in the time prior to the trip, as I'd mentioned I was planning to exchange a fair amount on arrival, and had less than a week to prepare.
In China credit cards are not all that popular, with most people not having them. Online (and in store) purchases are done with debit cards that cannot be used in the US (although they work in Thailand and some other SE Asian countries). I did have some credit cards from home but have allowed them to expire as making repayments is too expensive when doing it internationally, especially on a monthly basis. Now having been living in China for some time I'm probably not elligable for a credit card at all.
Which raises an intersting point, what about people who for whatever reason cannot get a credit card (bad credit history, just moved, whatever)? When we make credit card ownership mandatory for taking part in society (paying for various government services, online purchases, entering the country, getting a hotel room etc.) a significant chunk of people are then excluded because they don't or can't qualify for a credit card.
What would have been equally bad would be to have had enough funds in cash to cover my trip, the amount would have needed to be between $3-5k, which would also have raised flags. It seems the "ideal" tactic is to have some cash (a few hunder dollars) and one or or two credit cards. Too much or too little cash raises eyebrows.
Be on guard
When you're giving them you're passport the CBP agents ask you questions, they always ask "purpose of visit, how long are you staying, where will you be traveling, how much do you have". Sometimes they ask more questions than this. They asked me if I was married "yes", then next question was "Why is your wife not coming with you?". That caught me off guard (I was tired from travelling, and had different memories of what it was like to travel to the states from 2000), which is what some of those questions are meant to do. I mumbled something about not getting a visa. A friend of mine who was traveling there for a conference had planned his stay for 8 days. The agent asked him how long was the conference? "3 days", Why are you staying for 8 then?
Don't mention bitcoin
Much was made of the fact that I had mentioned bitcoin, and looking back I certainly think I would "rephrase" how I was going to support myself. I had already been flagged down by the agent for further questioning, they(there were 3 agents around me at that time asking questions) wanted to know why I only had $600 and how I was going to support myself.
My options were:
1) Lie -"My friend is going to give me some cash when I get through." See above on why this is a bad idea.
2) Stay silent, not answer the question (not much of an option if I want them to let me in).
3) Tell them I would be exchanging bitcoin to pay for my stay.
I chose option 3
Phone and iPad copying
On the issue of when they inspected and copied my phone and iPad, prior to leaving I had wiped both devices, my phone had some person numbers (not much use as they're Chinese, DHS doesn't do much intelligence sharing with them), and a map from the airport to startpad.org's offices. They did not contain my bitcoin wallet or any other information.
I had been in questioning in the office for about 2-3 hours already before they searched me and took my devices. I guess it was a "might as well, while he's here" sort of thing. Was my privacy violated? Yes and no, I'm sure I could have objected, and maybe they would have listened, but they certainly would not have let me into the country. Because of their position of power CBP has no difficulty getting full cooperation from non-US nationals, they want in, and CBP can at any time refuse them entry.I wanted in, so I cooperated.
If you're an American citizen then the situation is different, you can't be refused entry to your own country, but it doesn't mean that they won't detain you or take your computer off you if you refuse to give them what they want, you have rights if you're willing to stand up for them.
To protect your privacy your best option is to wipe your machine and devices of any information (as you will always miss that little important detail otherwise), and restore from the internet once you're in and clear.
Also keep in mind that CBP may also bug your computer, a friend of mine told me of how they had taken his laptop to "inspect" it, returning it 10 minutes later saying that it was a mistake. In that time they had installed a rootkit that monitored keystrokes. On starting up his laptop when getting to his hotel his intrusion detection system was alerting him. This was on an internal flight.
No electronic devices
Apart from the cost, and trouble caused, the thing that really bothered me was how paranoid they were. Making sure that they were not being monitored or recorded or the people being detained were communicating with someone outside. No electronic devices. They know who you are, they have your finger prints, a high res picture of your face, your travel details, passport copies, family tree, everything. But you are not allowed to record your interaction with them, and I'm sure doing so is probably a federal offence.