diff --git a/core/src/main/java/com/google/bitcoin/core/Transaction.java b/core/src/main/java/com/google/bitcoin/core/Transaction.java index 86b93eb6..fe2727c9 100644 --- a/core/src/main/java/com/google/bitcoin/core/Transaction.java +++ b/core/src/main/java/com/google/bitcoin/core/Transaction.java @@ -345,7 +345,7 @@ public class Transaction extends ChildMessage implements Serializable { * transactions sending coins to those keys to be in the wallet. This method will not attempt to download the * blocks containing the input transactions if the key is in the wallet but the transactions are not. * - * @return sum in nanocoins. + * @return sum of the inputs that are spending coins with keys in the wallet */ public Coin getValueSentFromMe(Wallet wallet) throws ScriptException { maybeParse(); diff --git a/core/src/main/java/com/google/bitcoin/core/TransactionOutput.java b/core/src/main/java/com/google/bitcoin/core/TransactionOutput.java index 77dd7873..86dc2e5b 100644 --- a/core/src/main/java/com/google/bitcoin/core/TransactionOutput.java +++ b/core/src/main/java/com/google/bitcoin/core/TransactionOutput.java @@ -160,7 +160,7 @@ public class TransactionOutput extends ChildMessage implements Serializable { } /** - * Returns the value of this output in nanocoins. This is the amount of currency that the destination address + * Returns the value of this output. This is the amount of currency that the destination address * receives. */ public Coin getValue() { @@ -169,7 +169,7 @@ public class TransactionOutput extends ChildMessage implements Serializable { } /** - * Sets the value of this output in nanocoins. + * Sets the value of this output. */ public void setValue(Coin value) { checkNotNull(value); diff --git a/core/src/main/java/com/google/bitcoin/core/Wallet.java b/core/src/main/java/com/google/bitcoin/core/Wallet.java index edeedab0..efe5447b 100644 --- a/core/src/main/java/com/google/bitcoin/core/Wallet.java +++ b/core/src/main/java/com/google/bitcoin/core/Wallet.java @@ -2188,17 +2188,17 @@ public class Wallet extends BaseTaggableObject implements Serializable, BlockCha * prevent this, but that should only occur once the transaction has been accepted by the network. This implies * you cannot have more than one outstanding sending tx at once.

* - *

You MUST ensure that nanocoins is not smaller than {@link Transaction#MIN_NONDUST_OUTPUT} or the transaction + *

You MUST ensure that the value is not smaller than {@link Transaction#MIN_NONDUST_OUTPUT} or the transaction * will almost certainly be rejected by the network as dust.

* - * @param address The Bitcoin address to send the money to. - * @param nanocoins How much currency to send, in nanocoins. + * @param address The Bitcoin address to send the money to. + * @param value How much currency to send. * @return either the created Transaction or null if there are insufficient coins. * coins as spent until commitTx is called on the result. * @throws InsufficientMoneyException if the request could not be completed due to not enough balance. */ - public Transaction createSend(Address address, Coin nanocoins) throws InsufficientMoneyException { - SendRequest req = SendRequest.to(address, nanocoins); + public Transaction createSend(Address address, Coin value) throws InsufficientMoneyException { + SendRequest req = SendRequest.to(address, value); if (params == UnitTestParams.get()) req.shuffleOutputs = false; completeTx(req); @@ -2242,8 +2242,8 @@ public class Wallet extends BaseTaggableObject implements Serializable, BlockCha * almost certainly be rejected by the network as dust.

* * @param broadcaster a {@link TransactionBroadcaster} to use to send the transactions out. - * @param to Which address to send coins to. - * @param value How much value to send. You can use Utils.toNanoCoins() to calculate this. + * @param to Which address to send coins to. + * @param value How much value to send. * @return An object containing the transaction that was created, and a future for the broadcast of it. * @throws InsufficientMoneyException if the request could not be completed due to not enough balance. */ diff --git a/core/src/main/java/com/google/bitcoin/testing/FakeTxBuilder.java b/core/src/main/java/com/google/bitcoin/testing/FakeTxBuilder.java index d21817f1..3f1a5f88 100644 --- a/core/src/main/java/com/google/bitcoin/testing/FakeTxBuilder.java +++ b/core/src/main/java/com/google/bitcoin/testing/FakeTxBuilder.java @@ -31,16 +31,16 @@ public class FakeTxBuilder { * Create a fake TX of sufficient realism to exercise the unit tests. Two outputs, one to us, one to somewhere * else to simulate change. There is one random input. */ - public static Transaction createFakeTxWithChangeAddress(NetworkParameters params, Coin nanocoins, Address to, Address changeOutput) { + public static Transaction createFakeTxWithChangeAddress(NetworkParameters params, Coin value, Address to, Address changeOutput) { Transaction t = new Transaction(params); - TransactionOutput outputToMe = new TransactionOutput(params, t, nanocoins, to); + TransactionOutput outputToMe = new TransactionOutput(params, t, value, to); t.addOutput(outputToMe); TransactionOutput change = new TransactionOutput(params, t, valueOf(1, 11), changeOutput); t.addOutput(change); // Make a previous tx simply to send us sufficient coins. This prev tx is not really valid but it doesn't // matter for our purposes. Transaction prevTx = new Transaction(params); - TransactionOutput prevOut = new TransactionOutput(params, prevTx, nanocoins, to); + TransactionOutput prevOut = new TransactionOutput(params, prevTx, value, to); prevTx.addOutput(prevOut); // Connect it. t.addInput(prevOut); @@ -52,24 +52,24 @@ public class FakeTxBuilder { * Create a fake TX of sufficient realism to exercise the unit tests. Two outputs, one to us, one to somewhere * else to simulate change. There is one random input. */ - public static Transaction createFakeTx(NetworkParameters params, Coin nanocoins, Address to) { - return createFakeTxWithChangeAddress(params, nanocoins, to, new ECKey().toAddress(params)); + public static Transaction createFakeTx(NetworkParameters params, Coin value, Address to) { + return createFakeTxWithChangeAddress(params, value, to, new ECKey().toAddress(params)); } /** * Create a fake TX of sufficient realism to exercise the unit tests. Two outputs, one to us, one to somewhere * else to simulate change. There is one random input. */ - public static Transaction createFakeTx(NetworkParameters params, Coin nanocoins, ECKey to) { + public static Transaction createFakeTx(NetworkParameters params, Coin value, ECKey to) { Transaction t = new Transaction(params); - TransactionOutput outputToMe = new TransactionOutput(params, t, nanocoins, to); + TransactionOutput outputToMe = new TransactionOutput(params, t, value, to); t.addOutput(outputToMe); TransactionOutput change = new TransactionOutput(params, t, valueOf(1, 11), new ECKey()); t.addOutput(change); // Make a previous tx simply to send us sufficient coins. This prev tx is not really valid but it doesn't // matter for our purposes. Transaction prevTx = new Transaction(params); - TransactionOutput prevOut = new TransactionOutput(params, prevTx, nanocoins, to); + TransactionOutput prevOut = new TransactionOutput(params, prevTx, value, to); prevTx.addOutput(prevOut); // Connect it. t.addInput(prevOut); @@ -80,24 +80,24 @@ public class FakeTxBuilder { /** * Transaction[0] is a feeder transaction, supplying BTC to Transaction[1] */ - public static Transaction[] createFakeTx(NetworkParameters params, Coin nanocoins, + public static Transaction[] createFakeTx(NetworkParameters params, Coin value, Address to, Address from) { // Create fake TXes of sufficient realism to exercise the unit tests. This transaction send BTC from the // from address, to the to address with to one to somewhere else to simulate change. Transaction t = new Transaction(params); - TransactionOutput outputToMe = new TransactionOutput(params, t, nanocoins, to); + TransactionOutput outputToMe = new TransactionOutput(params, t, value, to); t.addOutput(outputToMe); TransactionOutput change = new TransactionOutput(params, t, valueOf(1, 11), new ECKey().toAddress(params)); t.addOutput(change); // Make a feeder tx that sends to the from address specified. This feeder tx is not really valid but it doesn't // matter for our purposes. Transaction feederTx = new Transaction(params); - TransactionOutput feederOut = new TransactionOutput(params, feederTx, nanocoins, from); + TransactionOutput feederOut = new TransactionOutput(params, feederTx, value, from); feederTx.addOutput(feederOut); // make a previous tx that sends from the feeder to the from address Transaction prevTx = new Transaction(params); - TransactionOutput prevOut = new TransactionOutput(params, prevTx, nanocoins, to); + TransactionOutput prevOut = new TransactionOutput(params, prevTx, value, to); prevTx.addOutput(prevOut); // Connect up the txes diff --git a/core/src/main/java/com/google/bitcoin/uri/BitcoinURI.java b/core/src/main/java/com/google/bitcoin/uri/BitcoinURI.java index 602ba2f0..dba57847 100644 --- a/core/src/main/java/com/google/bitcoin/uri/BitcoinURI.java +++ b/core/src/main/java/com/google/bitcoin/uri/BitcoinURI.java @@ -322,7 +322,7 @@ public class BitcoinURI { * Simple Bitcoin URI builder using known good fields. * * @param address The Bitcoin address - * @param amount The amount in nanocoins (decimal) + * @param amount The amount * @param label A label * @param message A message * @return A String containing the Bitcoin URI diff --git a/core/src/test/java/com/google/bitcoin/core/CoinTest.java b/core/src/test/java/com/google/bitcoin/core/CoinTest.java index 00cff646..66212530 100644 --- a/core/src/test/java/com/google/bitcoin/core/CoinTest.java +++ b/core/src/test/java/com/google/bitcoin/core/CoinTest.java @@ -33,7 +33,7 @@ public class CoinTest { assertEquals(COIN.add(CENT), parseCoin("1.01")); try { parseCoin("2E-20"); - org.junit.Assert.fail("should not have accepted fractional nanocoins"); + org.junit.Assert.fail("should not have accepted fractional satoshis"); } catch (ArithmeticException e) { } diff --git a/core/src/test/java/com/google/bitcoin/core/WalletTest.java b/core/src/test/java/com/google/bitcoin/core/WalletTest.java index c6adc4e4..3d39e593 100644 --- a/core/src/test/java/com/google/bitcoin/core/WalletTest.java +++ b/core/src/test/java/com/google/bitcoin/core/WalletTest.java @@ -1572,7 +1572,7 @@ public class WalletTest extends TestWithWallet { wallet.completeTx(request7); assertEquals(Transaction.REFERENCE_DEFAULT_MIN_TX_FEE, request7.fee); Transaction spend7 = request7.tx; - // If change is 0.1-nanocoin and we already have a 0.1-nanocoin output, fee should be reference fee + // If change is 0.1-satoshi and we already have a 0.1-satoshi output, fee should be reference fee assertEquals(3, spend7.getOutputs().size()); // We optimize for priority, so the output selected should be the largest one. assertEquals(spend7.getOutput(0).getValue().add(spend7.getOutput(1).getValue()).add(spend7.getOutput(2).getValue()), diff --git a/core/src/test/java/com/google/bitcoin/protocols/payments/PaymentSessionTest.java b/core/src/test/java/com/google/bitcoin/protocols/payments/PaymentSessionTest.java index 1c276e44..49831c5d 100644 --- a/core/src/test/java/com/google/bitcoin/protocols/payments/PaymentSessionTest.java +++ b/core/src/test/java/com/google/bitcoin/protocols/payments/PaymentSessionTest.java @@ -45,13 +45,13 @@ public class PaymentSessionTest { private ECKey serverKey; private Transaction tx; private TransactionOutput outputToMe; - private Coin nanoCoins = COIN; + private Coin coin = COIN; @Before public void setUp() throws Exception { serverKey = new ECKey(); tx = new Transaction(params); - outputToMe = new TransactionOutput(params, tx, nanoCoins, serverKey); + outputToMe = new TransactionOutput(params, tx, coin, serverKey); tx.addOutput(outputToMe); } @@ -60,7 +60,7 @@ public class PaymentSessionTest { // Create a PaymentRequest and make sure the correct values are parsed by the PaymentSession. MockPaymentSession paymentSession = new MockPaymentSession(newSimplePaymentRequest("test")); assertEquals(paymentRequestMemo, paymentSession.getMemo()); - assertEquals(nanoCoins, paymentSession.getValue()); + assertEquals(coin, paymentSession.getValue()); assertEquals(simplePaymentUrl, paymentSession.getPaymentUrl()); assertTrue(new Date(time * 1000L).equals(paymentSession.getDate())); assertTrue(paymentSession.getSendRequest().tx.equals(tx)); @@ -79,8 +79,8 @@ public class PaymentSessionTest { assertEquals(paymentMemo, payment.getMemo()); assertEquals(merchantData, payment.getMerchantData()); assertEquals(1, payment.getRefundToCount()); - assertEquals(nanoCoins.value, payment.getRefundTo(0).getAmount()); - TransactionOutput refundOutput = new TransactionOutput(params, null, nanoCoins, refundAddr); + assertEquals(coin.value, payment.getRefundTo(0).getAmount()); + TransactionOutput refundOutput = new TransactionOutput(params, null, coin, refundAddr); ByteString refundScript = ByteString.copyFrom(refundOutput.getScriptBytes()); assertTrue(refundScript.equals(payment.getRefundTo(0).getScript())); } @@ -149,7 +149,7 @@ public class PaymentSessionTest { private Protos.PaymentRequest newSimplePaymentRequest(String netID) { Protos.Output.Builder outputBuilder = Protos.Output.newBuilder() - .setAmount(nanoCoins.value) + .setAmount(coin.value) .setScript(ByteString.copyFrom(outputToMe.getScriptBytes())); Protos.PaymentDetails paymentDetails = Protos.PaymentDetails.newBuilder() .setNetwork(netID) @@ -168,7 +168,7 @@ public class PaymentSessionTest { private Protos.PaymentRequest newExpiredPaymentRequest() { Protos.Output.Builder outputBuilder = Protos.Output.newBuilder() - .setAmount(nanoCoins.value) + .setAmount(coin.value) .setScript(ByteString.copyFrom(outputToMe.getScriptBytes())); Protos.PaymentDetails paymentDetails = Protos.PaymentDetails.newBuilder() .setNetwork("test")