3
0
mirror of https://github.com/Qortal/altcoinj.git synced 2025-01-31 23:32:16 +00:00

Rename enforceDefaultClientFeeRelayRules to ensureMinRequiredFee which is shorter.

This commit is contained in:
Mike Hearn 2013-06-10 16:02:38 +02:00
parent 9a389c9475
commit afaebd062a
3 changed files with 14 additions and 14 deletions

View File

@ -1713,7 +1713,7 @@ public class Wallet implements Serializable, BlockChainListener {
* 26,000 bytes. If you get a transaction which is that large, you should set a fee and feePerKb of at least * 26,000 bytes. If you get a transaction which is that large, you should set a fee and feePerKb of at least
* {@link Transaction#REFERENCE_DEFAULT_MIN_TX_FEE}.</p> * {@link Transaction#REFERENCE_DEFAULT_MIN_TX_FEE}.</p>
*/ */
public boolean enforceDefaultReferenceClientFeeRelayRules = true; public boolean ensureMinRequiredFee = true;
/** /**
* The AES key to use to decrypt the private keys before signing. * The AES key to use to decrypt the private keys before signing.
@ -1933,7 +1933,7 @@ public class Wallet implements Serializable, BlockChainListener {
// We need to know if we need to add an additional fee because one of our values are smaller than 0.01 BTC // We need to know if we need to add an additional fee because one of our values are smaller than 0.01 BTC
boolean needAtLeastReferenceFee = false; boolean needAtLeastReferenceFee = false;
if (req.enforceDefaultReferenceClientFeeRelayRules) { if (req.ensureMinRequiredFee) {
for (TransactionOutput output : req.tx.getOutputs()) for (TransactionOutput output : req.tx.getOutputs())
if (output.getValue().compareTo(Utils.CENT) < 0) { if (output.getValue().compareTo(Utils.CENT) < 0) {
needAtLeastReferenceFee = true; needAtLeastReferenceFee = true;
@ -1999,7 +1999,7 @@ public class Wallet implements Serializable, BlockChainListener {
TransactionOutput changeOutput = null; TransactionOutput changeOutput = null;
// If change is < 0.01 BTC, we will need to have at least minfee to be accepted by the network // If change is < 0.01 BTC, we will need to have at least minfee to be accepted by the network
if (req.enforceDefaultReferenceClientFeeRelayRules && !change.equals(BigInteger.ZERO) && if (req.ensureMinRequiredFee && !change.equals(BigInteger.ZERO) &&
change.compareTo(Utils.CENT) < 0 && fees.compareTo(Transaction.REFERENCE_DEFAULT_MIN_TX_FEE) < 0) { change.compareTo(Utils.CENT) < 0 && fees.compareTo(Transaction.REFERENCE_DEFAULT_MIN_TX_FEE) < 0) {
// This solution may fit into category 2, but it may also be category 3, we'll check that later // This solution may fit into category 2, but it may also be category 3, we'll check that later
eitherCategory2Or3 = true; eitherCategory2Or3 = true;
@ -2016,7 +2016,7 @@ public class Wallet implements Serializable, BlockChainListener {
changeAddress = getChangeAddress(); changeAddress = getChangeAddress();
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.enforceDefaultReferenceClientFeeRelayRules && Transaction.MIN_NONDUST_OUTPUT.compareTo(change) >= 0) { if (req.ensureMinRequiredFee && Transaction.MIN_NONDUST_OUTPUT.compareTo(change) >= 0) {
// This solution definitely fits in category 3 // This solution definitely fits in category 3
isCategory3 = true; isCategory3 = true;
additionalValueForNextCategory = Transaction.REFERENCE_DEFAULT_MIN_TX_FEE.add( additionalValueForNextCategory = Transaction.REFERENCE_DEFAULT_MIN_TX_FEE.add(

View File

@ -307,7 +307,7 @@ public class PeerGroupTest extends TestWithPeerGroup {
// Do the same thing with an offline transaction. // Do the same thing with an offline transaction.
peerGroup.removeWallet(wallet); peerGroup.removeWallet(wallet);
Wallet.SendRequest req = Wallet.SendRequest.to(dest, Utils.toNanoCoins(2, 0)); Wallet.SendRequest req = Wallet.SendRequest.to(dest, Utils.toNanoCoins(2, 0));
req.enforceDefaultReferenceClientFeeRelayRules = false; req.ensureMinRequiredFee = false;
Transaction t3 = wallet.sendCoinsOffline(req); Transaction t3 = wallet.sendCoinsOffline(req);
assertNull(outbound(p1)); // Nothing sent. assertNull(outbound(p1)); // Nothing sent.
// Add the wallet to the peer group (simulate initialization). Transactions should be announced. // Add the wallet to the peer group (simulate initialization). Transactions should be announced.

View File

@ -120,7 +120,7 @@ public class WalletTest extends TestWithWallet {
if (testEncryption) { if (testEncryption) {
// Try to create a send with a fee but no password (this should fail). // Try to create a send with a fee but no password (this should fail).
try { try {
req.enforceDefaultReferenceClientFeeRelayRules = false; req.ensureMinRequiredFee = false;
wallet.completeTx(req); wallet.completeTx(req);
fail("No exception was thrown trying to sign an encrypted key with no password supplied."); fail("No exception was thrown trying to sign an encrypted key with no password supplied.");
} catch (KeyCrypterException kce) { } catch (KeyCrypterException kce) {
@ -133,7 +133,7 @@ public class WalletTest extends TestWithWallet {
req = Wallet.SendRequest.to(destination, v2); req = Wallet.SendRequest.to(destination, v2);
req.aesKey = wrongAesKey; req.aesKey = wrongAesKey;
req.fee = toNanoCoins(0, 1); req.fee = toNanoCoins(0, 1);
req.enforceDefaultReferenceClientFeeRelayRules = false; req.ensureMinRequiredFee = false;
try { try {
wallet.completeTx(req); wallet.completeTx(req);
@ -149,7 +149,7 @@ public class WalletTest extends TestWithWallet {
req = Wallet.SendRequest.to(destination, v2); req = Wallet.SendRequest.to(destination, v2);
req.aesKey = aesKey; req.aesKey = aesKey;
req.fee = toNanoCoins(0, 1); req.fee = toNanoCoins(0, 1);
req.enforceDefaultReferenceClientFeeRelayRules = false; req.ensureMinRequiredFee = false;
} }
// Complete the transaction successfully. // Complete the transaction successfully.
@ -234,7 +234,7 @@ public class WalletTest extends TestWithWallet {
Wallet.SendRequest req = Wallet.SendRequest.to(new ECKey().toAddress(params), toNanoCoins(0, 48)); Wallet.SendRequest req = Wallet.SendRequest.to(new ECKey().toAddress(params), toNanoCoins(0, 48));
req.aesKey = aesKey; req.aesKey = aesKey;
Address a = req.changeAddress = new ECKey().toAddress(params); Address a = req.changeAddress = new ECKey().toAddress(params);
req.enforceDefaultReferenceClientFeeRelayRules = false; req.ensureMinRequiredFee = false;
wallet.completeTx(req); wallet.completeTx(req);
Transaction t3 = req.tx; Transaction t3 = req.tx;
assertEquals(a, t3.getOutput(1).getScriptPubKey().getToAddress(params)); assertEquals(a, t3.getOutput(1).getScriptPubKey().getToAddress(params));
@ -269,7 +269,7 @@ public class WalletTest extends TestWithWallet {
t2.addOutput(v3, a2); t2.addOutput(v3, a2);
t2.addOutput(v4, a2); t2.addOutput(v4, a2);
SendRequest req = SendRequest.forTx(t2); SendRequest req = SendRequest.forTx(t2);
req.enforceDefaultReferenceClientFeeRelayRules = false; req.ensureMinRequiredFee = false;
boolean complete = wallet.completeTx(req) != null; boolean complete = wallet.completeTx(req) != null;
// Do some basic sanity checks. // Do some basic sanity checks.
@ -974,7 +974,7 @@ public class WalletTest extends TestWithWallet {
TransactionOutput o2 = new TransactionOutput(params, t2, v2, k2.toAddress(params)); TransactionOutput o2 = new TransactionOutput(params, t2, v2, k2.toAddress(params));
t2.addOutput(o2); t2.addOutput(o2);
SendRequest req = SendRequest.forTx(t2); SendRequest req = SendRequest.forTx(t2);
req.enforceDefaultReferenceClientFeeRelayRules = false; req.ensureMinRequiredFee = false;
boolean complete = wallet.completeTx(req) != null; boolean complete = wallet.completeTx(req) != null;
assertTrue(complete); assertTrue(complete);
@ -1202,7 +1202,7 @@ public class WalletTest extends TestWithWallet {
assertNull(wallet.createSend(notMyAddr, BigInteger.ONE)); assertNull(wallet.createSend(notMyAddr, BigInteger.ONE));
// Spend it all without fee enforcement // Spend it all without fee enforcement
SendRequest req = SendRequest.to(notMyAddr, BigInteger.TEN.add(BigInteger.ONE.add(BigInteger.ONE))); SendRequest req = SendRequest.to(notMyAddr, BigInteger.TEN.add(BigInteger.ONE.add(BigInteger.ONE)));
req.enforceDefaultReferenceClientFeeRelayRules = false; req.ensureMinRequiredFee = false;
assertNotNull(wallet.sendCoinsOffline(req)); assertNotNull(wallet.sendCoinsOffline(req));
assertEquals(BigInteger.ZERO, wallet.getBalance()); assertEquals(BigInteger.ZERO, wallet.getBalance());
@ -1513,7 +1513,7 @@ public class WalletTest extends TestWithWallet {
// Now check that we dont complete // Now check that we dont complete
assertNull(wallet.completeTx(request24)); assertNull(wallet.completeTx(request24));
// Test feePerKb when we aren't using enforceDefaultReferenceClientFeeRelayRules // Test feePerKb when we aren't using ensureMinRequiredFee
// Same as request 19 // Same as request 19
SendRequest request25 = SendRequest.to(notMyAddr, Utils.CENT); SendRequest request25 = SendRequest.to(notMyAddr, Utils.CENT);
for (int i = 0; i < 99; i++) for (int i = 0; i < 99; i++)
@ -1523,7 +1523,7 @@ public class WalletTest extends TestWithWallet {
// Now reset request19 and give it a fee per kb // Now reset request19 and give it a fee per kb
request25.completed = false; request25.tx.clearInputs(); request25.completed = false; request25.tx.clearInputs();
request25.feePerKb = Utils.CENT.divide(BigInteger.valueOf(3)); request25.feePerKb = Utils.CENT.divide(BigInteger.valueOf(3));
request25.enforceDefaultReferenceClientFeeRelayRules = false; request25.ensureMinRequiredFee = false;
assertTrue(wallet.completeTx(request25).equals(Utils.CENT.subtract(BigInteger.ONE)) && request25.tx.getInputs().size() == 2); assertTrue(wallet.completeTx(request25).equals(Utils.CENT.subtract(BigInteger.ONE)) && request25.tx.getInputs().size() == 2);
BigInteger outValue25 = BigInteger.ZERO; BigInteger outValue25 = BigInteger.ZERO;
for (TransactionOutput out : request25.tx.getOutputs()) for (TransactionOutput out : request25.tx.getOutputs())