JSR 354 - Java Money and Currency API

177 views
Skip to first unread message

Sean Gilligan

unread,
Jan 28, 2015, 6:05:01 PM1/28/15
to bitc...@googlegroups.com
I've been researching issues of monetary precision and strong JVM types
for currencies and currency amounts. I want to create classes that can
store values and units of multiple currencies.

So naturally, I've been looking at the bitcoinj Coin class. I've also
read "JSR 354: Java Money and Currency API" and looked at the current
reference implementation.

The website for "Java Money" is here:
http://javamoney.github.io

The spec itself is here:
https://github.com/JavaMoney/jsr354-api/blob/master/src/main/asciidoc/JavaMoneySpecification.adoc

There's some interesting discussion of currency issues in the spec and
the "Bibliography" and "Links" sections contain a lot of
information.Note that bitcoinj is mentioned in the "Related Initiatives"
section of the Appendix.

Has anyone on this project looked at JSR 354? Are there any plans or
projects to implement the SPI for BTC using bitcoinj?

Thanks,

Sean









Mike Hearn

unread,
Jan 28, 2015, 6:38:24 PM1/28/15
to bitc...@googlegroups.com
I haven't looked at it and have no plans to do so right now. Coin works well enough for us and there are higher priorities. It might be useful to migrate to some standard JVM type eventually though.

Sean Gilligan

unread,
Jan 28, 2015, 6:53:19 PM1/28/15
to bitc...@googlegroups.com
I think those are good priorities. I think it's worthwhile to keep an
eye on the spec and reference implementation as they evolve and to learn
from them where possible. I also think there should eventually be an
add-on adapter module for bitcoinj that supports them. And eventually,
as you say, a migration to the new JVM standard types.

I haven't decided whether to try JavaMoney API for my project, but am
evaluating it. Another possibility is implementing the bitcoinj
'Monetary' interface. I may have some questions about that later.

Thanks,

Sean
> --
> You received this message because you are subscribed to the Google
> Groups "bitcoinj" group.
> To unsubscribe from this group and stop receiving emails from it, send
> an email to bitcoinj+u...@googlegroups.com
> <mailto:bitcoinj+u...@googlegroups.com>.
> For more options, visit https://groups.google.com/d/optout.

Chris Beams

unread,
Jan 29, 2015, 7:38:28 AM1/29/15
to bitc...@googlegroups.com
Hey Sean,

I recall seeing a few specific nods to bitcoin in the JSR-354 spec (or it might have been in the reference implementation). Seems like the team there is keeping BTC in mind in any case. Will be interested to hear what you find if you do any more exploration there.

- Chris
> To unsubscribe from this group and stop receiving emails from it, send an email to bitcoinj+u...@googlegroups.com.

Sean Gilligan

unread,
Jan 29, 2015, 1:59:04 PM1/29/15
to bitc...@googlegroups.com
Hi Chris, et al.,

There are definitely nods to cryptocurrency and specifically Bitcoin and
bitcoinj in the spec.

I've looked through the repos and communicated with Werner Keil (one of
the JSR "experts") about it. Here's what I've found so far.

1. Two main projects, the API (javax.money:money-api jar/artifact) and
RI (Reference Implementation, org.javamoney:moneta jar/artifact) The API
has a JSR license, the RI is Apache licensed. The Spec and API (and RI?)
are currently slated to be released as part of Java 9. The API and RI
implementations are built for Java 8 and later.

2. Example code for a BitcoinProvider that implements their
CurrencyProviderSpi (for adding a Bitcoin CurrencyUnit). As far as I can
tell this code only exists in a source code block in the User Guide, here:
https://github.com/JavaMoney/jsr354-ri/blob/master/src/main/asciidoc/userguide.adoc#214-registering-additional-currency-units

3. They have a Java Money Shelter project that is a "sandbox or
'sanctuary' for new ideas and modules" and are eager to have
contributors there:
https://github.com/JavaMoney/javamoney-shelter

4. In the Shelter project they have two Bitcoin ExchangeRateProvider
classes one for Mt. Gox (LOL!) and one for the Bitcoin.de service. (I'm
not familiar with the Bitcoin.de service or the status of the
ExchangeRateProvider class.) The source code is here:
https://github.com/msgilligan/javamoney-shelter/tree/master/digital-currency/bitcoin/src/main/java/org/javamoney/shelter/bitcoin/provider

Given the Java 8 dependency, I'm not sure how useful this stuff will be
for Android at the current time. I'm currently working on designing some
coin/currency JVM classes for the Omni Protocol (formerly Mastercoin)
which supports smart properties (aka user currencies) and am also
building on top of bitcoinj (using Address class, etc) and would like
the classes I'm building to be useful in Android wallets.

So it seems the right near-term approach for Omni Protocol (and perhaps
future versions of bitcoinj that support Java 6/7) are to have
coin/currency classes that can be easily mapped, extended, or wrapped to
work with JavaMoney.

I'll post an update if and when I have any further information.

Cheers,

Sean
Reply all
Reply to author
Forward
0 new messages