Rename getChangeAddress() to currentChangeAddress()

This commit is contained in:
Oscar Guindzberg
2015-09-01 17:37:56 -03:00
parent 207ef37894
commit 629e5d864d
3 changed files with 16 additions and 10 deletions

View File

@@ -597,9 +597,15 @@ public class Wallet extends BaseTaggableObject
}
/** Returns the address used for change outputs. Note: this will probably go away in future. */
public Address getChangeAddress() {
public Address currentChangeAddress() {
return currentAddress(KeyChain.KeyPurpose.CHANGE);
}
/**
* @deprecated use {@link #currentChangeAddress()} instead.
*/
public Address getChangeAddress() {
return currentChangeAddress();
}
/**
* <p>Deprecated alias for {@link #importKey(ECKey)}.</p>
@@ -3472,7 +3478,7 @@ public class Wallet extends BaseTaggableObject
/**
* <p>Statelessly creates a transaction that sends the given value to address. The change is sent to
* {@link Wallet#getChangeAddress()}, so you must have added at least one key.</p>
* {@link Wallet#currentChangeAddress()}, so you must have added at least one key.</p>
*
* <p>If you just want to send money quickly, you probably want
* {@link Wallet#sendCoins(TransactionBroadcaster, Address, Coin)} instead. That will create the sending
@@ -3535,7 +3541,7 @@ public class Wallet extends BaseTaggableObject
/**
* <p>Sends coins to the given address, via the given {@link PeerGroup}. Change is returned to
* {@link Wallet#getChangeAddress()}. Note that a fee may be automatically added if one may be required for the
* {@link Wallet#currentChangeAddress()}. Note that a fee may be automatically added if one may be required for the
* transaction to be confirmed.</p>
*
* <p>The returned object provides both the transaction, and a future that can be used to learn when the broadcast
@@ -3623,7 +3629,7 @@ public class Wallet extends BaseTaggableObject
}
/**
* Sends coins to the given address, via the given {@link Peer}. Change is returned to {@link Wallet#getChangeAddress()}.
* Sends coins to the given address, via the given {@link Peer}. Change is returned to {@link Wallet#currentChangeAddress()}.
* If an exception is thrown by {@link Peer#sendMessage(Message)} the transaction is still committed, so the
* pending transaction must be broadcast <b>by you</b> at some other time. Note that a fee may be automatically added
* if one may be required for the transaction to be confirmed.
@@ -4641,10 +4647,10 @@ public class Wallet extends BaseTaggableObject
if (change.signum() > 0) {
// The value of the inputs is greater than what we want to send. Just like in real life then,
// we need to take back some coins ... this is called "change". Add another output that sends the change
// back to us. The address comes either from the request or getChangeAddress() as a default.
// back to us. The address comes either from the request or currentChangeAddress() as a default.
Address changeAddress = req.changeAddress;
if (changeAddress == null)
changeAddress = getChangeAddress();
changeAddress = currentChangeAddress();
changeOutput = new TransactionOutput(params, req.tx, change, changeAddress);
// If the change output would result in this transaction being rejected as dust, just drop the change and make it a fee
if (req.ensureMinRequiredFee && Transaction.MIN_NONDUST_OUTPUT.compareTo(change) >= 0) {

View File

@@ -806,7 +806,7 @@ public class PeerTest extends TestWithNetworkConnections {
t1.addOutput(COIN, new ECKey().toAddress(params));
Transaction t2 = new Transaction(params);
t2.addInput(t1.getOutput(0));
t2.addOutput(COIN, wallet.getChangeAddress());
t2.addOutput(COIN, wallet.currentChangeAddress());
inbound(writeTarget, t2);
final InventoryItem inventoryItem = new InventoryItem(InventoryItem.Type.Transaction, t2.getInput(0).getOutpoint().getHash());
final NotFoundMessage nfm = new NotFoundMessage(params, Lists.newArrayList(inventoryItem));

View File

@@ -403,7 +403,7 @@ public class WalletTest extends TestWithWallet {
assertEquals("Wrong number of tx inputs", 1, t.getInputs().size());
assertEquals("Wrong number of tx outputs",2, t.getOutputs().size());
assertEquals(destination, t.getOutput(0).getScriptPubKey().getToAddress(params));
assertEquals(wallet.getChangeAddress(), t.getOutputs().get(1).getScriptPubKey().getToAddress(params));
assertEquals(wallet.currentChangeAddress(), t.getOutputs().get(1).getScriptPubKey().getToAddress(params));
assertEquals(valueOf(0, 49), t.getOutputs().get(1).getValue());
// Check the script runs and signatures verify.
t.getInputs().get(0).verify();
@@ -1509,7 +1509,7 @@ public class WalletTest extends TestWithWallet {
tx2.addInput(tx1.getOutput(0));
tx2.addOutput(valueOf(0, 9), someOtherAddress);
// Add a change address to ensure this tx is relevant.
tx2.addOutput(CENT, wallet.getChangeAddress());
tx2.addOutput(CENT, wallet.currentChangeAddress());
wallet.receivePending(tx2, null);
BlockPair bp = createFakeBlock(blockStore, Block.BLOCK_HEIGHT_GENESIS, tx1);
wallet.receiveFromBlock(tx1, bp.storedBlock, AbstractBlockChain.NewBlockType.BEST_CHAIN, 0);
@@ -1531,7 +1531,7 @@ public class WalletTest extends TestWithWallet {
b.addInput(a.getOutput(0));
b.addOutput(CENT, someOtherAddress);
Coin v = COIN.subtract(CENT);
b.addOutput(v, wallet.getChangeAddress());
b.addOutput(v, wallet.currentChangeAddress());
a = roundTripTransaction(params, a);
b = roundTripTransaction(params, b);
wallet.receivePending(b, null);