Skip to content

Commit

Permalink
v0.3.4
Browse files Browse the repository at this point in the history
  • Loading branch information
ManfredKarrer committed Feb 8, 2016
1 parent 96090b7 commit 86284fe
Show file tree
Hide file tree
Showing 30 changed files with 134 additions and 114 deletions.
2 changes: 1 addition & 1 deletion common/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<parent>
<artifactId>parent</artifactId>
<groupId>io.bitsquare</groupId>
<version>0.3.4-SNAPSHOT</version>
<version>0.3.4</version>
</parent>
<modelVersion>4.0.0</modelVersion>

Expand Down
2 changes: 0 additions & 2 deletions common/src/main/java/io/bitsquare/common/util/Tuple3.java
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,4 @@ public int hashCode() {
result = 31 * result + (third != null ? third.hashCode() : 0);
return result;
}


}
3 changes: 1 addition & 2 deletions core/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
<parent>
<artifactId>parent</artifactId>
<groupId>io.bitsquare</groupId>
<version>0.3.4-SNAPSHOT</version>
<version>0.3.4</version>
</parent>

<artifactId>core</artifactId>
Expand Down Expand Up @@ -52,6 +52,5 @@
<version>4.8</version>
</dependency>


</dependencies>
</project>
2 changes: 1 addition & 1 deletion core/src/main/java/io/bitsquare/btc/FeePolicy.java
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ public static Coin getFeePerKb() {
}

// Some wallets (Mycelium) don't support higher fees
public static Coin getMinFundingFee() {
public static Coin getMinRequiredFeeForFundingTx() {
return Coin.valueOf(20_000);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,14 @@
import com.google.common.util.concurrent.Futures;
import com.google.common.util.concurrent.SettableFuture;
import com.google.inject.Inject;
import io.bitsquare.app.Log;
import io.bitsquare.btc.BitcoinNetwork;
import io.bitsquare.btc.FeePolicy;
import io.bitsquare.btc.blockchain.providers.BlockTrailProvider;
import io.bitsquare.btc.blockchain.providers.BlockchainApiProvider;
import io.bitsquare.btc.blockchain.providers.BlockrIOProvider;
import io.bitsquare.btc.blockchain.providers.TradeBlockProvider;
import io.bitsquare.user.Preferences;
import org.bitcoinj.core.Coin;
import org.jetbrains.annotations.NotNull;
import org.slf4j.Logger;
Expand All @@ -20,34 +24,47 @@ public class BlockchainService {
private static final Logger log = LoggerFactory.getLogger(BlockchainService.class);

private final ArrayList<BlockchainApiProvider> providers;
private final boolean isMainNet;

@Inject
public BlockchainService(Preferences preferences) {
isMainNet = preferences.getBitcoinNetwork() == BitcoinNetwork.MAINNET;
providers = new ArrayList<>(Arrays.asList(new BlockrIOProvider(), new BlockTrailProvider(), new TradeBlockProvider()));
}

public BlockchainService() {
isMainNet = false;
providers = new ArrayList<>(Arrays.asList(new BlockrIOProvider(), new BlockTrailProvider(), new TradeBlockProvider()));
}

public SettableFuture<Coin> requestFeeFromBlockchain(String transactionId) {
log.debug("Request fee from providers");
Log.traceCall(transactionId);
long startTime = System.currentTimeMillis();
final SettableFuture<Coin> resultFuture = SettableFuture.create();
for (BlockchainApiProvider provider : providers) {
GetFeeRequest getFeeRequest = new GetFeeRequest();
SettableFuture<Coin> future = getFeeRequest.requestFee(transactionId, provider);
Futures.addCallback(future, new FutureCallback<Coin>() {
public void onSuccess(Coin fee) {
if (!resultFuture.isDone()) {
log.info("Request fee from providers done after {} ms.", (System.currentTimeMillis() - startTime));
resultFuture.set(fee);

if (isMainNet) {
for (BlockchainApiProvider provider : providers) {
GetFeeRequest getFeeRequest = new GetFeeRequest();
SettableFuture<Coin> future = getFeeRequest.requestFee(transactionId, provider);
Futures.addCallback(future, new FutureCallback<Coin>() {
public void onSuccess(Coin fee) {
if (!resultFuture.isDone()) {
log.info("Request fee from providers done after {} ms.", (System.currentTimeMillis() - startTime));
resultFuture.set(fee);
}
}
}

public void onFailure(@NotNull Throwable throwable) {
if (!resultFuture.isDone()) {
log.warn("Could not get the fee from any provider after repeated requests.");
resultFuture.setException(throwable);
public void onFailure(@NotNull Throwable throwable) {
if (!resultFuture.isDone()) {
log.warn("Could not get the fee from any provider after repeated requests.");
resultFuture.setException(throwable);
}
}
}
});
});
}
} else {
// For regtest/testnet we dont care of the check and set the expected value
resultFuture.set(FeePolicy.getMinRequiredFeeForFundingTx());
}
return resultFuture;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,18 +31,18 @@ public final class FinalizePayoutTxRequest extends TradeMessage implements Mailb

public final byte[] sellerSignature;
public final String sellerPayoutAddress;
public final long lockTime;
public final long lockTimeAsBlockHeight;
private final NodeAddress senderNodeAddress;

public FinalizePayoutTxRequest(String tradeId,
byte[] sellerSignature,
String sellerPayoutAddress,
long lockTime,
long lockTimeAsBlockHeight,
NodeAddress senderNodeAddress) {
super(tradeId);
this.sellerSignature = sellerSignature;
this.sellerPayoutAddress = sellerPayoutAddress;
this.lockTime = lockTime;
this.lockTimeAsBlockHeight = lockTimeAsBlockHeight;
this.senderNodeAddress = senderNodeAddress;
}

Expand All @@ -59,7 +59,7 @@ public boolean equals(Object o) {

FinalizePayoutTxRequest that = (FinalizePayoutTxRequest) o;

if (lockTime != that.lockTime) return false;
if (lockTimeAsBlockHeight != that.lockTimeAsBlockHeight) return false;
if (!Arrays.equals(sellerSignature, that.sellerSignature)) return false;
if (sellerPayoutAddress != null ? !sellerPayoutAddress.equals(that.sellerPayoutAddress) : that.sellerPayoutAddress != null)
return false;
Expand All @@ -72,7 +72,7 @@ public int hashCode() {
int result = super.hashCode();
result = 31 * result + (sellerSignature != null ? Arrays.hashCode(sellerSignature) : 0);
result = 31 * result + (sellerPayoutAddress != null ? sellerPayoutAddress.hashCode() : 0);
result = 31 * result + (int) (lockTime ^ (lockTime >>> 32));
result = 31 * result + (int) (lockTimeAsBlockHeight ^ (lockTimeAsBlockHeight >>> 32));
result = 31 * result + (senderNodeAddress != null ? senderNodeAddress.hashCode() : 0);
return result;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ protected void run() {

processModel.tradingPeer.setSignature(checkNotNull(message.sellerSignature));
processModel.tradingPeer.setPayoutAddressString(nonEmptyStringOf(message.sellerPayoutAddress));
trade.setLockTimeAsBlockHeight(nonNegativeLongOf(message.lockTime));
trade.setLockTimeAsBlockHeight(nonNegativeLongOf(message.lockTimeAsBlockHeight));

trade.setState(Trade.State.FIAT_PAYMENT_RECEIPT_MSG_RECEIVED);

Expand Down
3 changes: 1 addition & 2 deletions core/src/main/java/io/bitsquare/user/Preferences.java
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ public static List<String> getBtcDenominations() {

private static Locale defaultLocale = Locale.getDefault();
//TODO test with other locales
//private static Locale defaultLocale = Locale.US;
// private static Locale defaultLocale = Locale.US;

public static Locale getDefaultLocale() {
return defaultLocale;
Expand Down Expand Up @@ -416,5 +416,4 @@ public long getTxFeePerKB() {
public boolean getUseTorForBitcoinJ() {
return useTorForBitcoinJ;
}

}
2 changes: 1 addition & 1 deletion gui/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
<parent>
<artifactId>parent</artifactId>
<groupId>io.bitsquare</groupId>
<version>0.3.4-SNAPSHOT</version>
<version>0.3.4</version>
</parent>
<modelVersion>4.0.0</modelVersion>

Expand Down
16 changes: 11 additions & 5 deletions gui/src/main/java/io/bitsquare/app/BitsquareApp.java
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@
import javafx.stage.Modality;
import javafx.stage.Stage;
import javafx.stage.StageStyle;
import org.bitcoinj.store.BlockStoreException;
import org.bouncycastle.jce.provider.BouncyCastleProvider;
import org.controlsfx.dialog.Dialogs;
import org.reactfx.EventStreams;
Expand Down Expand Up @@ -108,10 +109,15 @@ public void start(Stage primaryStage) throws IOException {
// setup UncaughtExceptionHandler
Thread.UncaughtExceptionHandler handler = (thread, throwable) -> {
// Might come from another thread
log.error("Uncaught Exception from thread " + Thread.currentThread().getName());
log.error("Uncaught Exception throwableMessage= " + throwable.getMessage());
throwable.printStackTrace();
UserThread.execute(() -> showErrorPopup(throwable, false));
if (throwable.getCause() != null && throwable.getCause().getCause() != null &&
throwable.getCause().getCause() instanceof BlockStoreException) {
log.error(throwable.getMessage());
} else {
log.error("Uncaught Exception from thread " + Thread.currentThread().getName());
log.error("Uncaught Exception throwableMessage= " + throwable.getMessage());
throwable.printStackTrace();
UserThread.execute(() -> showErrorPopup(throwable, false));
}
};
Thread.setDefaultUncaughtExceptionHandler(handler);
Thread.currentThread().setUncaughtExceptionHandler(handler);
Expand All @@ -135,7 +141,7 @@ public void start(Stage primaryStage) throws IOException {
if (mainView != null)
mainView.setPersistedFilesCorrupted(corruptedDatabaseFiles);
});

// load the main view and create the main scene
CachingViewLoader viewLoader = injector.getInstance(CachingViewLoader.class);
mainView = (MainView) viewLoader.load(MainView.class);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@

public class TitledGroupBg extends Pane {


private final Label label;
private final StringProperty text = new SimpleStringProperty();

Expand Down
5 changes: 4 additions & 1 deletion gui/src/main/java/io/bitsquare/gui/main/MainViewModel.java
Original file line number Diff line number Diff line change
Expand Up @@ -637,7 +637,10 @@ private void setWalletServiceException(Throwable error) {
if (error instanceof TimeoutException) {
walletServiceErrorMsg.set("Connecting to the bitcoin network failed because of a timeout.");
} else if (error.getCause() instanceof BlockStoreException) {
walletServiceErrorMsg.set("Bitsquare is already running. You cannot run 2 instances of Bitsquare.");
new Popup().warning("Bitsquare is already running. You cannot run 2 instances of Bitsquare.")
.closeButtonText("Shut down")
.onClose(BitsquareApp.shutDownHandler::run)
.show();
} else if (error.getMessage() != null) {
walletServiceErrorMsg.set("Connection to the bitcoin network failed because of an error:" + error.getMessage());
} else {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@

<TableView fx:id="table" VBox.vgrow="ALWAYS">
<columns>
<TableColumn text="Date/Time" fx:id="dateColumn" minWidth="170" maxWidth="170"/>
<TableColumn text="Date/Time" fx:id="dateColumn" minWidth="180" maxWidth="180"/>
<TableColumn text="Details" fx:id="detailsColumn" minWidth="260"/>
<TableColumn text="Address" fx:id="addressColumn" minWidth="320" maxWidth="320">
<cellValueFactory>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,12 +28,12 @@
</padding>
<TableView fx:id="table" VBox.vgrow="ALWAYS">
<columns>
<TableColumn text="Date/Time" fx:id="dateColumn" minWidth="160" maxWidth="160">
<TableColumn text="Date/Time" fx:id="dateColumn" minWidth="180" maxWidth="180">
<cellValueFactory>
<PropertyValueFactory property="date"/>
</cellValueFactory>
</TableColumn>
<TableColumn text="Details" fx:id="detailsColumn" minWidth="210" maxWidth="210"/>
<TableColumn text="Details" fx:id="detailsColumn" minWidth="220" maxWidth="220"/>
<TableColumn text="Address" fx:id="addressColumn" minWidth="180"/>
<TableColumn text="Transaction" fx:id="transactionColumn" minWidth="100"/>
<TableColumn text="Amount (BTC)" fx:id="amountColumn" minWidth="110" maxWidth="110">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@
<TableView fx:id="table" VBox.vgrow="ALWAYS">
<columns>
<TableColumn text="Select" fx:id="selectColumn" minWidth="60" maxWidth="60" sortable="false"/>
<TableColumn text="Date/Time" fx:id="dateColumn" minWidth="170" maxWidth="170"/>
<TableColumn text="Date/Time" fx:id="dateColumn" minWidth="180" maxWidth="180"/>
<TableColumn text="Details" fx:id="detailsColumn" minWidth="160" maxWidth="160"/>
<TableColumn text="Address" fx:id="addressColumn" minWidth="320" maxWidth="320">
<cellValueFactory>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -191,9 +191,9 @@ public void onFailure(@NotNull Throwable t) {
new Popup().headLine("Confirm your withdrawal request")
.message("Sending: " + formatter.formatCoinWithCode(senderAmount) + "\n" +
"From address: " + withdrawFromTextField.getText() + "\n" +
"To receiving address: " + withdrawToTextField.getText() + ".\n\n" +
"Required transaction fee is: " + formatter.formatCoinWithCode(requiredFee) + "\n" +
"Recipient will receive: " + formatter.formatCoinWithCode(receiverAmount) + "\n\n" +
"To receiving address: " + withdrawToTextField.getText() + ".\n" +
"Required transaction fee is: " + formatter.formatCoinWithCode(requiredFee) + "\n\n" +
"The recipient will receive: " + formatter.formatCoinWithCode(receiverAmount) + "\n\n" +
"Are you sure you want to withdraw that amount?")
.onAction(() -> doWithdraw(receiverAmount, callback))
.show();
Expand Down
Loading

0 comments on commit 86284fe

Please sign in to comment.