Closed GoogleCodeExporter closed 9 years ago
I think this can be caused if the Bitcoin value encoded into a URI has more
decimal places than the protocol can support. I wish the URI spec required
values to be specified in Satoshis, then this mistake couldn't happen. Anyway
yes. It should be fixed. One question is should we round off the price if such
a URI exists, or should we refuse to process it? My inclination is to reject
and hope the creators of these URIs fix things.
Original comment by hearn@google.com
on 17 May 2013 at 4:52
I think we should rethrow the exception as BitcoinURIParseException now,
because that's an obvious bug. Wether we relax the parsing in this case is
another issue that can be decided later.
Original comment by andreas....@gmail.com
on 17 May 2013 at 7:07
Just reproduced the exception. Indeed, it happens if you have too many decimal
places:
bitcoin:15P7W9X5xWVLewpnSk5gjLWVakvZ3NRUGN?amount=0.99999999999
Original comment by andreas....@gmail.com
on 17 May 2013 at 8:06
I've written a bunch of test cases for this and some related bugs:
@Test(expected = BitcoinURIParseException.class)
public void testBad_AmountTooPrecise() throws BitcoinURIParseException {
new BitcoinURI(MainNetParams.get(), BitcoinURI.BITCOIN_SCHEME + ":" + MAINNET_GOOD_ADDRESS
+ "?amount=0.123456789");
}
@Test(expected = BitcoinURIParseException.class)
public void testBad_NegativeAmount() throws BitcoinURIParseException {
new BitcoinURI(MainNetParams.get(), BitcoinURI.BITCOIN_SCHEME + ":" + MAINNET_GOOD_ADDRESS
+ "?amount=-1");
}
@Test(expected = BitcoinURIParseException.class)
public void testBad_TooLargeAmount() throws BitcoinURIParseException {
new BitcoinURI(MainNetParams.get(), BitcoinURI.BITCOIN_SCHEME + ":" + MAINNET_GOOD_ADDRESS
+ "?amount=100000000");
}
Original comment by andreas....@gmail.com
on 18 May 2013 at 7:10
I've rebased my bitcoin-uri-tests branch on current master.
Original comment by andreas....@gmail.com
on 18 Jun 2013 at 10:47
Original comment by hearn@google.com
on 11 Jul 2013 at 2:53
The last two testcases in this issue are not fixed.
Original comment by andreas....@gmail.com
on 11 Jul 2013 at 3:16
And can we have a testcase for the "too precise" case so it is clear what
result to expect?
Original comment by andreas....@gmail.com
on 11 Jul 2013 at 3:23
This issue was closed by revision 719a786db148.
Original comment by hearn@google.com
on 11 Jul 2013 at 3:33
Original issue reported on code.google.com by
andreas....@gmail.com
on 17 May 2013 at 11:23