mirror of
https://github.com/haveno-dex/haveno.git
synced 2025-07-29 09:48:46 -04:00
Polish FeePolicy
- Convert static fields to final instance fields - Remove commented code - Rethrow any AddressFormatException as a BitsquareException instead of logging and returning null (doing so would cause NPEs in BitcoinJ internals).
This commit is contained in:
parent
b911cd2a95
commit
b0411393f5
1 changed files with 13 additions and 29 deletions
|
@ -17,6 +17,8 @@
|
||||||
|
|
||||||
package io.bitsquare.btc;
|
package io.bitsquare.btc;
|
||||||
|
|
||||||
|
import io.bitsquare.BitsquareException;
|
||||||
|
|
||||||
import org.bitcoinj.core.Address;
|
import org.bitcoinj.core.Address;
|
||||||
import org.bitcoinj.core.AddressFormatException;
|
import org.bitcoinj.core.AddressFormatException;
|
||||||
import org.bitcoinj.core.Coin;
|
import org.bitcoinj.core.Coin;
|
||||||
|
@ -28,27 +30,21 @@ import org.slf4j.Logger;
|
||||||
import org.slf4j.LoggerFactory;
|
import org.slf4j.LoggerFactory;
|
||||||
|
|
||||||
public class FeePolicy {
|
public class FeePolicy {
|
||||||
|
|
||||||
public static final Coin TX_FEE = Transaction.REFERENCE_DEFAULT_MIN_TX_FEE;
|
public static final Coin TX_FEE = Transaction.REFERENCE_DEFAULT_MIN_TX_FEE;
|
||||||
|
|
||||||
// The min. REGISTRATION_FEE calculated with Transaction.MIN_NONDUST_OUTPUT would be 0.00015460 which might lead
|
// The min. REGISTRATION_FEE calculated with Transaction.MIN_NONDUST_OUTPUT would be
|
||||||
// to problems for the spending wallet.
|
// 0.00015460 which might lead to problems for the spending wallet.
|
||||||
// Some web wallets don't allow more then 4 decimal places (need more investigation)
|
// Some web wallets don't allow more then 4 decimal places (need more investigation)
|
||||||
// So we use 0.0002 as that fits also to our 4 decimal places restriction for BTC values.
|
// So we use 0.0002 as that fits also to our 4 decimal places restriction for BTC values.
|
||||||
// The remaining 0.0000454 BTC is given to miners at the moment as it is lower then dust.
|
// The remaining 0.0000454 BTC is given to miners at the moment as it is lower then dust.
|
||||||
public static final Coin REGISTRATION_FEE = TX_FEE.add(TX_FEE);
|
public static final Coin REGISTRATION_FEE = TX_FEE.add(TX_FEE);
|
||||||
|
|
||||||
public static final Coin CREATE_OFFER_FEE = REGISTRATION_FEE; // 0.0002
|
public static final Coin CREATE_OFFER_FEE = REGISTRATION_FEE; // 0.0002
|
||||||
public static final Coin TAKE_OFFER_FEE = CREATE_OFFER_FEE;
|
public static final Coin TAKE_OFFER_FEE = CREATE_OFFER_FEE;
|
||||||
private static final Logger log = LoggerFactory.getLogger(FeePolicy.class);
|
|
||||||
|
|
||||||
// those are just dummy yet. trading fees will go probably to arbiters
|
|
||||||
// Not used at the moment
|
|
||||||
// private static final String registrationFeeAddress = "mvkDXt4QmN4Nq9dRUsRigBCaovde9nLkZR";
|
|
||||||
|
|
||||||
private static String createOfferFeeAddress;
|
|
||||||
private static String takeOfferFeeAddress;
|
|
||||||
|
|
||||||
private final BitcoinNetwork bitcoinNetwork;
|
private final BitcoinNetwork bitcoinNetwork;
|
||||||
|
private final String createOfferFeeAddress;
|
||||||
|
private final String takeOfferFeeAddress;
|
||||||
|
|
||||||
@Inject
|
@Inject
|
||||||
public FeePolicy(BitcoinNetwork bitcoinNetwork) {
|
public FeePolicy(BitcoinNetwork bitcoinNetwork) {
|
||||||
|
@ -68,28 +64,17 @@ public class FeePolicy {
|
||||||
createOfferFeeAddress = "n2upbsaKAe4PD3cc4JfS7UCqPC5oNd7Ckg";
|
createOfferFeeAddress = "n2upbsaKAe4PD3cc4JfS7UCqPC5oNd7Ckg";
|
||||||
takeOfferFeeAddress = "n2upbsaKAe4PD3cc4JfS7UCqPC5oNd7Ckg";
|
takeOfferFeeAddress = "n2upbsaKAe4PD3cc4JfS7UCqPC5oNd7Ckg";
|
||||||
break;
|
break;
|
||||||
|
default:
|
||||||
|
throw new BitsquareException("Unknown bitcoin network: %s", bitcoinNetwork);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
//TODO who is receiver? other users or dev address? use donation option list?
|
|
||||||
// Not used at the moment
|
|
||||||
// (dev, other users, wikileaks, tor, sub projects (bitcoinj, tomp2p,...)...)
|
|
||||||
/* public Address getAddressForRegistrationFee() {
|
|
||||||
try {
|
|
||||||
return new Address(params, registrationFeeAddress);
|
|
||||||
} catch (AddressFormatException e) {
|
|
||||||
e.printStackTrace();
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
}*/
|
|
||||||
|
|
||||||
//TODO get address form arbitrator list
|
//TODO get address form arbitrator list
|
||||||
public Address getAddressForCreateOfferFee() {
|
public Address getAddressForCreateOfferFee() {
|
||||||
try {
|
try {
|
||||||
return new Address(bitcoinNetwork.getParameters(), createOfferFeeAddress);
|
return new Address(bitcoinNetwork.getParameters(), createOfferFeeAddress);
|
||||||
} catch (AddressFormatException e) {
|
} catch (AddressFormatException ex) {
|
||||||
e.printStackTrace();
|
throw new BitsquareException(ex);
|
||||||
return null;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -97,9 +82,8 @@ public class FeePolicy {
|
||||||
public Address getAddressForTakeOfferFee() {
|
public Address getAddressForTakeOfferFee() {
|
||||||
try {
|
try {
|
||||||
return new Address(bitcoinNetwork.getParameters(), takeOfferFeeAddress);
|
return new Address(bitcoinNetwork.getParameters(), takeOfferFeeAddress);
|
||||||
} catch (AddressFormatException e) {
|
} catch (AddressFormatException ex) {
|
||||||
e.printStackTrace();
|
throw new BitsquareException(ex);
|
||||||
return null;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue