mirror of
https://github.com/Qortal/altcoinj.git
synced 2025-11-03 14:07:14 +00:00
Rename getChangeAddress() to currentChangeAddress()
This commit is contained in:
@@ -597,9 +597,15 @@ public class Wallet extends BaseTaggableObject
|
|||||||
}
|
}
|
||||||
|
|
||||||
/** Returns the address used for change outputs. Note: this will probably go away in future. */
|
/** 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);
|
return currentAddress(KeyChain.KeyPurpose.CHANGE);
|
||||||
}
|
}
|
||||||
|
/**
|
||||||
|
* @deprecated use {@link #currentChangeAddress()} instead.
|
||||||
|
*/
|
||||||
|
public Address getChangeAddress() {
|
||||||
|
return currentChangeAddress();
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* <p>Deprecated alias for {@link #importKey(ECKey)}.</p>
|
* <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
|
* <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
|
* <p>If you just want to send money quickly, you probably want
|
||||||
* {@link Wallet#sendCoins(TransactionBroadcaster, Address, Coin)} instead. That will create the sending
|
* {@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
|
* <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>
|
* 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
|
* <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
|
* 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
|
* 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.
|
* if one may be required for the transaction to be confirmed.
|
||||||
@@ -4641,10 +4647,10 @@ public class Wallet extends BaseTaggableObject
|
|||||||
if (change.signum() > 0) {
|
if (change.signum() > 0) {
|
||||||
// The value of the inputs is greater than what we want to send. Just like in real life then,
|
// 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
|
// 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;
|
Address changeAddress = req.changeAddress;
|
||||||
if (changeAddress == null)
|
if (changeAddress == null)
|
||||||
changeAddress = getChangeAddress();
|
changeAddress = currentChangeAddress();
|
||||||
changeOutput = new TransactionOutput(params, req.tx, change, changeAddress);
|
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 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) {
|
if (req.ensureMinRequiredFee && Transaction.MIN_NONDUST_OUTPUT.compareTo(change) >= 0) {
|
||||||
|
|||||||
@@ -806,7 +806,7 @@ public class PeerTest extends TestWithNetworkConnections {
|
|||||||
t1.addOutput(COIN, new ECKey().toAddress(params));
|
t1.addOutput(COIN, new ECKey().toAddress(params));
|
||||||
Transaction t2 = new Transaction(params);
|
Transaction t2 = new Transaction(params);
|
||||||
t2.addInput(t1.getOutput(0));
|
t2.addInput(t1.getOutput(0));
|
||||||
t2.addOutput(COIN, wallet.getChangeAddress());
|
t2.addOutput(COIN, wallet.currentChangeAddress());
|
||||||
inbound(writeTarget, t2);
|
inbound(writeTarget, t2);
|
||||||
final InventoryItem inventoryItem = new InventoryItem(InventoryItem.Type.Transaction, t2.getInput(0).getOutpoint().getHash());
|
final InventoryItem inventoryItem = new InventoryItem(InventoryItem.Type.Transaction, t2.getInput(0).getOutpoint().getHash());
|
||||||
final NotFoundMessage nfm = new NotFoundMessage(params, Lists.newArrayList(inventoryItem));
|
final NotFoundMessage nfm = new NotFoundMessage(params, Lists.newArrayList(inventoryItem));
|
||||||
|
|||||||
@@ -403,7 +403,7 @@ public class WalletTest extends TestWithWallet {
|
|||||||
assertEquals("Wrong number of tx inputs", 1, t.getInputs().size());
|
assertEquals("Wrong number of tx inputs", 1, t.getInputs().size());
|
||||||
assertEquals("Wrong number of tx outputs",2, t.getOutputs().size());
|
assertEquals("Wrong number of tx outputs",2, t.getOutputs().size());
|
||||||
assertEquals(destination, t.getOutput(0).getScriptPubKey().getToAddress(params));
|
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());
|
assertEquals(valueOf(0, 49), t.getOutputs().get(1).getValue());
|
||||||
// Check the script runs and signatures verify.
|
// Check the script runs and signatures verify.
|
||||||
t.getInputs().get(0).verify();
|
t.getInputs().get(0).verify();
|
||||||
@@ -1509,7 +1509,7 @@ public class WalletTest extends TestWithWallet {
|
|||||||
tx2.addInput(tx1.getOutput(0));
|
tx2.addInput(tx1.getOutput(0));
|
||||||
tx2.addOutput(valueOf(0, 9), someOtherAddress);
|
tx2.addOutput(valueOf(0, 9), someOtherAddress);
|
||||||
// Add a change address to ensure this tx is relevant.
|
// Add a change address to ensure this tx is relevant.
|
||||||
tx2.addOutput(CENT, wallet.getChangeAddress());
|
tx2.addOutput(CENT, wallet.currentChangeAddress());
|
||||||
wallet.receivePending(tx2, null);
|
wallet.receivePending(tx2, null);
|
||||||
BlockPair bp = createFakeBlock(blockStore, Block.BLOCK_HEIGHT_GENESIS, tx1);
|
BlockPair bp = createFakeBlock(blockStore, Block.BLOCK_HEIGHT_GENESIS, tx1);
|
||||||
wallet.receiveFromBlock(tx1, bp.storedBlock, AbstractBlockChain.NewBlockType.BEST_CHAIN, 0);
|
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.addInput(a.getOutput(0));
|
||||||
b.addOutput(CENT, someOtherAddress);
|
b.addOutput(CENT, someOtherAddress);
|
||||||
Coin v = COIN.subtract(CENT);
|
Coin v = COIN.subtract(CENT);
|
||||||
b.addOutput(v, wallet.getChangeAddress());
|
b.addOutput(v, wallet.currentChangeAddress());
|
||||||
a = roundTripTransaction(params, a);
|
a = roundTripTransaction(params, a);
|
||||||
b = roundTripTransaction(params, b);
|
b = roundTripTransaction(params, b);
|
||||||
wallet.receivePending(b, null);
|
wallet.receivePending(b, null);
|
||||||
|
|||||||
Reference in New Issue
Block a user