Android App

342 views
Skip to first unread message

powwow

unread,
Mar 7, 2011, 4:22:50 PM3/7/11
to bitcoinj
Awesome work! What kind of projects do you envision with BitcoinJ?
Is this what we are looking for when it comes to Android Bitcoin apps
and payment system? Someone just needs to build a client off of this,
right?

Mike Hearn

unread,
Mar 7, 2011, 5:49:33 PM3/7/11
to bitc...@googlegroups.com, powwow

Right. I created this as the first step in building an Android client
actually, but for various reasons will probably focus on the library
aspect for now. I don't have any Android code, but the inclusion of
the Bouncy Castle lightweight API should make it easier to run there.

--
GMail Engineering
Google Switzerland GmbH

Andreas Schildbach

unread,
Mar 8, 2011, 3:45:22 AM3/8/11
to bitcoinj
> > Awesome work!  What kind of projects do you envision with BitcoinJ?
> > Is this what we are looking for when it comes to Android Bitcoin apps
> > and payment system?  Someone just needs to build a client off of this,
> > right?
>
> Right. I created this as the first step in building an Android client
> actually, but for various reasons will probably focus on the library
> aspect for now. I don't have any Android code, but the inclusion of
> the Bouncy Castle lightweight API should make it easier to run there.

I'll go ahead and start an Android client right now. I'll keep you
updated.

Andreas Schildbach

unread,
Mar 8, 2011, 6:40:26 AM3/8/11
to bitc...@googlegroups.com
> I'll go ahead and start an Android client right now. I'll keep you
> updated.

I just uploaded a first (non-functional) version to Google Code:

http://code.google.com/p/bitcoin-wallet/

I have some problems:

1) As there is no bitcoin node running on localhost on Android devices,
I need at least one peer somewhere else. Currently I have hardcoded a
machine from my local network, but ideally the App should be able to
discover peers on its own. Is there any support present or planned for
this in bincoinj?

2) If I invoke peer.startBlockChainDownload(), Android runs out of
memory quite quickly. There is only 4 MB of heap availble per app on
some devices. Is there any way to limit the download process? Can I
detect receiving Bitcoins without downloading the block chain somehow?

3) Also, I think some listeners/callbacks are missing to get some status
about the download. For starters, I'd like to display the number of
received blocks like in the desktop client.

4) [not related to bitcoinj] I'm not sure where to store the wallet.
"filesDir" is probably the safest and most secure place on an Android
device but still if the user clears all data for an app, the wallet is
gone. On the other hand, external storage (e.g. SD-cards) can be read by
all apps. In general, Android is an insecure platform because there are
next-to-none security updates and vulns go unpatched for months (even if
you own a Google Phone). So a client-based wallet would only be good for
small amounts of money.

Best regards,

Andreas

Mike Hearn

unread,
Mar 8, 2011, 7:04:18 AM3/8/11
to bitc...@googlegroups.com, Andreas Schildbach
That was fast!

As you have discovered, this is a v0.1 release for a reason :-)

On Tue, Mar 8, 2011 at 12:40 PM, Andreas Schildbach
<and...@schildbach.de> wrote:
> 1) As there is no bitcoin node running on localhost on Android devices,
> I need at least one peer somewhere else.

Yes. I'll probably check in a list of seed nodes at some point.

> 2) If I invoke peer.startBlockChainDownload(), Android runs out of
> memory quite quickly.

That's because we keep every block header around in expanded form even
when we no longer really need them. Even keeping them in serialized
form would be insufficient as the headers alone are around 5mb per
year.

The handling of the block chain will be changing a lot in future. This
is one of the problems that'll get fixed.

> 3) Also, I think some listeners/callbacks are missing to get some status
> about the download. For starters, I'd like to display the number of
> received blocks like in the desktop client.

It's probably not necessary. The only reason the client shows the
number of blocks is because the download is so slow. But we can make
the initial download much faster by using getheaders and checkpoints.
An Android app should wake up occasionally and catch up with the block
chain when the phone is in your pocket so it never has far to go when
you need it.

> 4) [not related to bitcoinj] I'm not sure where to store the wallet.

Internal storage is the right place. In the longer run, using the
backup framework to store an encrypted version server side is the way
to go. See the notes I put in this thread:

http://www.bitcoin.org/smf/index.php?topic=3017.msg42069#msg42069

For security, we'll see how this plays out in the longer term. The
alternative is desktop operating systems which don't even try to stop
apps stealing your wallet. At least on Android (and other mobile
platforms) such an ability is unquestionably a bug.

Andreas Schildbach

unread,
Mar 8, 2011, 10:02:09 AM3/8/11
to bitc...@googlegroups.com
>> 1) As there is no bitcoin node running on localhost on Android devices,
>> I need at least one peer somewhere else.
>
> Yes. I'll probably check in a list of seed nodes at some point.

I just imported the seed nodes from the official client, so there is a
starting point.

> The handling of the block chain will be changing a lot in future. This
> is one of the problems that'll get fixed.

Great to hear. I'm happy to adapt to any API changes this might involve.

>> 3) Also, I think some listeners/callbacks are missing to get some status
>> about the download. For starters, I'd like to display the number of
>> received blocks like in the desktop client.
>
> It's probably not necessary. The only reason the client shows the
> number of blocks is because the download is so slow.

Well ok for debugging it would be nice but on the other hand I can just
put some debug statements into bitjoinj myself (-:

> Internal storage is the right place. In the longer run, using the
> backup framework to store an encrypted version server side is the way
> to go.

This is a good idea.

I just discovered that you (accidently?) used some Java6 API, e.g.
usage of peekLast() on LinkedList in
BlockChain.getTopBlock(BlockChain.java:235) and other places.

This makes your library incompatible to at least Android 2.2 and below.
Strangely, I did not have any problems on my Android 2.3.3-upgraded
Nexus One, is it possible that Android 2.3 contains Java6 API now?

Regards,

Andreas

Mike Hearn

unread,
Mar 8, 2011, 10:16:02 AM3/8/11
to bitc...@googlegroups.com, Andreas Schildbach
> Well ok for debugging it would be nice but on the other hand I can just
> put some debug statements into bitjoinj myself (-:

That's true. I don't mind adding some kind of listener interface on
the block chain. The version message contains the peers chain height
too, so we can also calculate a completion percentage.

> This makes your library incompatible to at least Android 2.2 and below.
> Strangely, I did not have any problems on my Android 2.3.3-upgraded
> Nexus One, is it possible that Android 2.3 contains Java6 API now?

Probably. I'll see if I can make IntelliJ warn me about that and fix them.

Leo Wandersleb

unread,
Jun 10, 2011, 10:10:25 AM6/10/11
to bitc...@googlegroups.com
Hallo Andreas,

just downloaded your app from the market and started reading here on this group.
Are you intending to spend more time on Bitcoin Wallet? Does it have its own forum/group already? Do you need help? Is there a mercurial or git repository somewhere, too?

I've been trying your app and got aware of how incredibly simple payment could be. I'm now evem more enthusiastic about bitcoin than ever.

Regards,

Leo

P.S.: Test faucet is down. Would you mind sending me some test coins to muSzrNRMGLpVHN2sgDYHbRGTBZc18GAWdr ?

Andreas Schildbach

unread,
Jun 10, 2011, 10:54:54 AM6/10/11
to bitc...@googlegroups.com
I am definately continuing the app (in fact I am just working on it).
Problem is the underlying framework bitcoinj is only evolving slowly.
Maybe you can help there?

http://code.google.com/p/bitcoinj/

http://code.google.com/p/bitcoin-wallet/

I just sent you some testnet bitcoins.

Leo Wandersleb

unread,
Jun 10, 2011, 11:08:31 AM6/10/11
to bitc...@googlegroups.com
thanks for the btc although they don't show up in the app :(
ok so if i have time, i will see what i can do at bitcoinj.

why are you both doing svn instead of git or hg? contributions are so much easier for both sides. also i feel like attribution is more likely to be correct if it is my commit and not just my patch.

wallet starts up all white. some splash screen would ... oh and now it crashed while in white screen. I had left the wallet using back, then killed it using my task manager and started it again. there it went white like last time and after 30s it crashed. now it just keeps crashing with the same output.

logcat has this to tell:
E/AndroidRuntime(14118): FATAL EXCEPTION: main
E/AndroidRuntime(14118): java.lang.Error: blockstore cannot be created
E/AndroidRuntime(14118):        at de.schildbach.wallet.Application.onCreate(Application.java:57)
E/AndroidRuntime(14118):        at android.app.Instrumentation.callApplicationOnCreate(Instrumentation.java:969)
E/AndroidRuntime(14118):        at android.app.ActivityThread.handleBindApplication(ActivityThread.java:3272)
E/AndroidRuntime(14118):        at android.app.ActivityThread.access$2200(ActivityThread.java:117)
E/AndroidRuntime(14118):        at android.app.ActivityThread$H.handleMessage(ActivityThread.java:969)
E/AndroidRuntime(14118):        at android.os.Handler.dispatchMessage(Handler.java:99)
E/AndroidRuntime(14118):        at android.os.Looper.loop(Looper.java:130)
E/AndroidRuntime(14118):        at android.app.ActivityThread.main(ActivityThread.java:3683)
E/AndroidRuntime(14118):        at java.lang.reflect.Method.invokeNative(Native Method)
E/AndroidRuntime(14118):        at java.lang.reflect.Method.invoke(Method.java:507)
E/AndroidRuntime(14118):        at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:839)
E/AndroidRuntime(14118):        at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:597)
E/AndroidRuntime(14118):        at dalvik.system.NativeStart.main(Native Method)
E/AndroidRuntime(14118): Caused by: com.google.bitcoin.core.BlockStoreException: Could not connect 36dcfb099071e9eb71f5b5b55448db0e9d1677387328473ec9ce89cb7bc5af26 to 0000000191a1fef57010c1189bad65eff5e99596187d7802e24f4693800bcb02
E/AndroidRuntime(14118):        at com.google.bitcoin.core.DiskBlockStore.load(DiskBlockStore.java:112)
E/AndroidRuntime(14118):        at com.google.bitcoin.core.DiskBlockStore.<init>(DiskBlockStore.java:43)
E/AndroidRuntime(14118):        at de.schildbach.wallet.Application.onCreate(Application.java:53)
E/AndroidRuntime(14118):        ... 12 more
W/ActivityManager( 7192):   Force finishing activity de.schildbach.wallet/.WalletActivity

check for yourself if this second output is actually the same but i guess so:
W/dalvikvm(14133): threadid=1: thread exiting with uncaught exception (group=0x40015560)
E/AndroidRuntime(14133): FATAL EXCEPTION: main
E/AndroidRuntime(14133): java.lang.Error: blockstore cannot be created
E/AndroidRuntime(14133):        at de.schildbach.wallet.Application.onCreate(Application.java:57)
E/AndroidRuntime(14133):        at android.app.Instrumentation.callApplicationOnCreate(Instrumentation.java:969)
E/AndroidRuntime(14133):        at android.app.ActivityThread.handleBindApplication(ActivityThread.java:3272)
E/AndroidRuntime(14133):        at android.app.ActivityThread.access$2200(ActivityThread.java:117)
E/AndroidRuntime(14133):        at android.app.ActivityThread$H.handleMessage(ActivityThread.java:969)
E/AndroidRuntime(14133):        at android.os.Handler.dispatchMessage(Handler.java:99)
E/AndroidRuntime(14133):        at android.os.Looper.loop(Looper.java:130)
E/AndroidRuntime(14133):        at android.app.ActivityThread.main(ActivityThread.java:3683)
E/AndroidRuntime(14133):        at java.lang.reflect.Method.invokeNative(Native Method)
E/AndroidRuntime(14133):        at java.lang.reflect.Method.invoke(Method.java:507)
E/AndroidRuntime(14133):        at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:839)
E/AndroidRuntime(14133):        at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:597)
E/AndroidRuntime(14133):        at dalvik.system.NativeStart.main(Native Method)
E/AndroidRuntime(14133): Caused by: com.google.bitcoin.core.BlockStoreException: Could not connect 36dcfb099071e9eb71f5b5b55448db0e9d1677387328473ec9ce89cb7bc5af26 to 0000000191a1fef57010c1189bad65eff5e99596187d7802e24f4693800bcb02
E/AndroidRuntime(14133):        at com.google.bitcoin.core.DiskBlockStore.load(DiskBlockStore.java:112)
E/AndroidRuntime(14133):        at com.google.bitcoin.core.DiskBlockStore.<init>(DiskBlockStore.java:43)
E/AndroidRuntime(14133):        at de.schildbach.wallet.Application.onCreate(Application.java:53)
E/AndroidRuntime(14133):        ... 12 more
W/ActivityManager( 7192):   Force finishing activity de.schildbach.wallet/.WalletActivity
W/ActivityManager( 7192): Activity pause timeout for HistoryRecord{40a28dc8 de.schildbach.wallet/.WalletActivity}
W/ActivityManager( 7192): Activity destroy timeout for HistoryRecord{40a28dc8 de.schildbach.wallet/.WalletActivity}

Mike Hearn

unread,
Jun 10, 2011, 11:41:28 AM6/10/11
to bitc...@googlegroups.com
DiskBlockStore won't work on Android because the chains are too big to fit in RAM. That's why I wrote BoundedOverheadBlockStore.

On Fri, Jun 10, 2011 at 5:08 PM, Leo Wandersleb <lwand...@googlemail.com> wrote:
why are you both doing svn instead of git or hg? contributions are so much easier for both sides.

Google has a policy of using Google Code for our own projects. It supports Mercurial but not git. Maybe in future we'll change what we use.

I've used distributed VCS' over the years (eg I was one of the first users of Tom Lords Arch, which invented the concept). One thing has always remained true:  they are complex and it's easy to get your trees into a state that's hard to understand. This is true of git as well. Subversion for all its faults is easy to understand and if something goes wrong it's usually easy to fix. BitCoinJ is being mirrored into github anyway, so people who want to develop that way can do so.

Leo Wandersleb

unread,
Jun 10, 2011, 1:30:24 PM6/10/11
to bitc...@googlegroups.com
i thought BoundedOverheadBlockStore was already part of bitcoin wallet. hope to see an update soon :) and hope the coins i got are there :)

[explicitly skipping the religious talk about svn vs. dvcs ... ;) ]
Reply all
Reply to author
Forward
0 new messages