NFC initiated Bitcoin payments with Bitcoin Wallet for Android

101 views
Skip to first unread message

Andreas Schildbach

unread,
Jul 16, 2011, 5:24:56 PM7/16/11
to bitc...@googlegroups.com
Today, I've added NFC capabilities to Bitcoin Wallet for Android. You
can initiate Bitcoin payments from an NFC tag or a second NFC capable
phone having the "Receive coins" dialog open.

Instructions for how to prepare an NFC tag can be found here:
http://code.google.com/p/bitcoin-wallet/source/browse/trunk/README

For now, it is only contained in the Testnet version:
https://market.android.com/details?id=de.schildbach.wallet_test

It's very difficult to find NFC capable phones out in the wild. If you
have one, could you help me testing? Issues can be reported here:
http://code.google.com/p/bitcoin-wallet/issues/list

Cheers,

Andreas

Gary Rowe

unread,
Jul 17, 2011, 5:16:36 PM7/17/11
to bitc...@googlegroups.com
Awesome addition to the wallet. Well done!

Mike Hearn

unread,
Jul 19, 2011, 8:07:03 AM7/19/11
to bitc...@googlegroups.com
I did a test today, but it didn't work. After touching my Nexus S to another one, my phone crashed inside the Tags app. It seems from the stack trace that the bitcoin: URI ended up going to the Tags app which then failed whilst attempting to parse it. Here are some snippets from the logs:

07-19 13:54:52.289 E/AndroidRuntime( 1487): FATAL EXCEPTION: IntentService[SaveTagService]
07-19 13:54:52.289 E/AndroidRuntime( 1487): java.lang.NullPointerException
07-19 13:54:52.289 E/AndroidRuntime( 1487): at com.android.apps.tag.record.UriRecord.parseWellKnown(UriRecord.java:236)
07-19 13:54:52.289 E/AndroidRuntime( 1487): at com.android.apps.tag.record.UriRecord.parse(UriRecord.java:207)
07-19 13:54:52.289 E/AndroidRuntime( 1487): at com.android.apps.tag.record.UriRecord.isUri(UriRecord.java:246)
07-19 13:54:52.289 E/AndroidRuntime( 1487): at com.android.apps.tag.message.NdefMessageParser.getRecords(NdefMessageParser.java:54)
07-19 13:54:52.289 E/AndroidRuntime( 1487): at com.android.apps.tag.message.NdefMessageParser.getRecords(NdefMessageParser.java:48)
07-19 13:54:52.289 E/AndroidRuntime( 1487): at com.android.apps.tag.message.NdefMessageParser.parse(NdefMessageParser.java:44)
07-19 13:54:52.289 E/AndroidRuntime( 1487): at com.android.apps.tag.provider.TagContract$NdefMessages.toValues(TagContract.java:77)
07-19 13:54:52.289 E/AndroidRuntime( 1487): at com.android.apps.tag.TagService.onHandleIntent(TagService.java:72)
07-19 13:54:52.289 E/AndroidRuntime( 1487): at android.app.IntentService$ServiceHandler.handleMessage(IntentService.java:59)
07-19 13:54:52.289 E/AndroidRuntime( 1487): at android.os.Handler.dispatchMessage(Handler.java:99)
07-19 13:54:52.289 E/AndroidRuntime( 1487): at android.os.Looper.loop(Looper.java:130)
07-19 13:54:52.289 E/AndroidRuntime( 1487): at android.os.HandlerThread.run(HandlerThread.java:60)

07-19 13:55:57.093 E/NfcService(  196): failed to parse record
07-19 13:55:57.093 E/NfcService(  196): java.lang.ArrayIndexOutOfBoundsException
07-19 13:55:57.093 E/NfcService(  196): at com.android.nfc.NfcService$NfcServiceHandler.parseWellKnownUriRecord(NfcService.java:2579)
07-19 13:55:57.093 E/NfcService(  196): at com.android.nfc.NfcService$NfcServiceHandler.setTypeOrDataFromNdef(NfcService.java:2625)
07-19 13:55:57.093 E/NfcService(  196): at com.android.nfc.NfcService$NfcServiceHandler.dispatchTagInternal(NfcService.java:2722)
07-19 13:55:57.093 E/NfcService(  196): at com.android.nfc.NfcService$NfcServiceHandler.dispatchTag(NfcService.java:2682)
07-19 13:55:57.093 E/NfcService(  196): at com.android.nfc.NfcService$NfcServiceHandler.handleMessage(NfcService.java:2379)
07-19 13:55:57.093 E/NfcService(  196): at android.os.Handler.dispatchMessage(Handler.java:99)
07-19 13:55:57.093 E/NfcService(  196): at android.os.Looper.loop(Looper.java:130)
07-19 13:55:57.093 E/NfcService(  196): at android.app.ActivityThread.main(ActivityThread.java:3683)
07-19 13:55:57.093 E/NfcService(  196): at java.lang.reflect.Method.invokeNative(Native Method)
07-19 13:55:57.093 E/NfcService(  196): at java.lang.reflect.Method.invoke(Method.java:507)
07-19 13:55:57.093 E/NfcService(  196): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:839)
07-19 13:55:57.093 E/NfcService(  196): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:597)
07-19 13:55:57.093 E/NfcService(  196): at dalvik.system.NativeStart.main(Native Method)

It looks like the payload may be malformed in some way. Judging from the code, the first byte of the payload is supposed to be zero. If it isn't it's possible for these crashes to occur.

Andreas Schildbach

unread,
Jul 19, 2011, 9:49:18 AM7/19/11
to bitc...@googlegroups.com
Thanks for checking this out. I think I have to use tnf TNF_ABSOLUTE_URI
rather than TNF_WELL_KNOWN. I just uploaded version 1.13_test, can you
try again?

Did you try using a writable tag as well, instead of the second phone?

Btw. v1.13 also adds trusted peer mode, that should help with testing.

Mike Hearn

unread,
Jul 19, 2011, 10:11:26 AM7/19/11
to bitc...@googlegroups.com
That worked!

Let it go on record that at 4:05pm CET, my manager Tadek was the first person in the world to receive [testnet] Bitcoins via NFC ;)

Did you try using a writable tag as well, instead of the second phone?

I don't have any writeable tags unfortunately. If I acquire one I'll test it. But IMHO the phone to phone use case is the most interesting. You may as well just use a qrcode if you're going to have a static address, which writeable tags implies.
 
Btw. v1.13 also adds trusted peer mode, that should help with testing.

You mean it lets me specify which node to connect to? How does it work? I don't see anything about this in the UI?

Andreas Schildbach

unread,
Jul 19, 2011, 10:15:36 AM7/19/11
to bitc...@googlegroups.com
On 07/19/2011 04:11 PM, Mike Hearn wrote:

> That worked!
>
> Let it go on record that at 4:05pm CET, my manager Tadek was the first
> person in the world to receive [testnet] Bitcoins via NFC ;)

Yes! (-:

> Btw. v1.13 also adds trusted peer mode, that should help with testing.
>
> You mean it lets me specify which node to connect to? How does it work?
> I don't see anything about this in the UI?

Go to Options -> About -> Scroll down

Cheers,

Andreas

Mike Hearn

unread,
Jul 19, 2011, 10:18:52 AM7/19/11
to bitc...@googlegroups.com
> You mean it lets me specify which node to connect to? How does it work?
> I don't see anything about this in the UI?

Go to Options -> About -> Scroll down

Awesome, I'll play with it later. It might be worth clearing the block chain when this is done, as connecting to a testnet-in-a-box gives it a different chain. 
Reply all
Reply to author
Forward
0 new messages