mirror of
https://github.com/haveno-dex/haveno.git
synced 2025-12-16 08:14:15 -05:00
fix formatting bug, wrong fee payment, nullpointer with tab
This commit is contained in:
parent
d5a5db1d42
commit
88a3ec0f7b
8 changed files with 20 additions and 11 deletions
|
|
@ -28,7 +28,7 @@ public class Relay extends Application
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
port = 5000;
|
port = 5001;
|
||||||
}
|
}
|
||||||
|
|
||||||
launch(args);
|
launch(args);
|
||||||
|
|
|
||||||
|
|
@ -696,6 +696,11 @@ public class WalletFacade
|
||||||
log.trace("offererPubKey=" + offererPubKey);
|
log.trace("offererPubKey=" + offererPubKey);
|
||||||
log.trace("takerPubKey=" + takerPubKey);
|
log.trace("takerPubKey=" + takerPubKey);
|
||||||
log.trace("arbitratorPubKey=" + arbitratorPubKey);
|
log.trace("arbitratorPubKey=" + arbitratorPubKey);
|
||||||
|
log.trace("offererInputAmount=" + BtcFormatter.formatSatoshis(offererInputAmount));
|
||||||
|
|
||||||
|
// we need to subtract the fee as it will go to the miners
|
||||||
|
BigInteger amountToPay = offererInputAmount.subtract(FeePolicy.TX_FEE);
|
||||||
|
log.trace("amountToPay=" + BtcFormatter.formatSatoshis(amountToPay));
|
||||||
|
|
||||||
// We pay the offererInputAmount to a temporary MS output which will be changed later to the correct value.
|
// We pay the offererInputAmount to a temporary MS output which will be changed later to the correct value.
|
||||||
// With the usage of completeTx() we get all the work done with fee calculation, validation and coin selection.
|
// With the usage of completeTx() we get all the work done with fee calculation, validation and coin selection.
|
||||||
|
|
@ -705,7 +710,7 @@ public class WalletFacade
|
||||||
// The btc tx fee will be included by the completeTx() call, so we don't need to add it manually.
|
// The btc tx fee will be included by the completeTx() call, so we don't need to add it manually.
|
||||||
Transaction tx = new Transaction(params);
|
Transaction tx = new Transaction(params);
|
||||||
Script multiSigOutputScript = getMultiSigScript(offererPubKey, takerPubKey, arbitratorPubKey);
|
Script multiSigOutputScript = getMultiSigScript(offererPubKey, takerPubKey, arbitratorPubKey);
|
||||||
tx.addOutput(offererInputAmount, multiSigOutputScript);
|
tx.addOutput(amountToPay, multiSigOutputScript);
|
||||||
|
|
||||||
Wallet.SendRequest sendRequest = Wallet.SendRequest.forTx(tx);
|
Wallet.SendRequest sendRequest = Wallet.SendRequest.forTx(tx);
|
||||||
AddressEntry addressEntry = getAddressInfoByTradeID(tradeId);
|
AddressEntry addressEntry = getAddressInfoByTradeID(tradeId);
|
||||||
|
|
|
||||||
|
|
@ -216,14 +216,15 @@ public class MainController implements Initializable, NavigationController
|
||||||
navigateToView(selectedNavigationItem);
|
navigateToView(selectedNavigationItem);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//TODO make ordersButton also reacting to jump to pending tab
|
||||||
private void onTakeOfferRequested(String offerId, PeerAddress sender)
|
private void onTakeOfferRequested(String offerId, PeerAddress sender)
|
||||||
{
|
{
|
||||||
final Button alertButton = new Button("", Icons.getIconImageView(Icons.MSG_ALERT));
|
final Button alertButton = new Button("", Icons.getIconImageView(Icons.MSG_ALERT));
|
||||||
alertButton.setId("nav-alert-button");
|
alertButton.setId("nav-alert-button");
|
||||||
alertButton.relocate(36, 19);
|
alertButton.relocate(36, 19);
|
||||||
alertButton.setOnAction((e) -> {
|
alertButton.setOnAction((e) -> {
|
||||||
OrdersController.GET_INSTANCE().setSelectedTabIndex(1);
|
|
||||||
ordersButton.fire();
|
ordersButton.fire();
|
||||||
|
OrdersController.GET_INSTANCE().setSelectedTabIndex(1);
|
||||||
});
|
});
|
||||||
Tooltip.install(alertButton, new Tooltip("Someone accepted your offer"));
|
Tooltip.install(alertButton, new Tooltip("Someone accepted your offer"));
|
||||||
ordersButtonButtonHolder.getChildren().add(alertButton);
|
ordersButtonButtonHolder.getChildren().add(alertButton);
|
||||||
|
|
|
||||||
|
|
@ -110,9 +110,11 @@ public class CreateOfferController implements Initializable, ChildController, Hi
|
||||||
amountTextField.setText("1");
|
amountTextField.setText("1");
|
||||||
priceTextField.setText("" + (int) (499 - new Random().nextDouble() * 1000 / 100));
|
priceTextField.setText("" + (int) (499 - new Random().nextDouble() * 1000 / 100));
|
||||||
minAmountTextField.setText("0,1");
|
minAmountTextField.setText("0,1");
|
||||||
collateralTextField.setText("10");
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//TODO derive form arbitrators
|
||||||
|
collateralTextField.setText("10");
|
||||||
|
|
||||||
updateVolume();
|
updateVolume();
|
||||||
updateTotals();
|
updateTotals();
|
||||||
|
|
||||||
|
|
@ -296,7 +298,7 @@ public class CreateOfferController implements Initializable, ChildController, Hi
|
||||||
double collateralPercentAsDouble = BitSquareConverter.stringToDouble(collateralTextField.getText());
|
double collateralPercentAsDouble = BitSquareConverter.stringToDouble(collateralTextField.getText());
|
||||||
double collateralAmountAsDouble = collateralPercentAsDouble * amountAsDouble / 100;
|
double collateralAmountAsDouble = collateralPercentAsDouble * amountAsDouble / 100;
|
||||||
BigInteger collateral = BtcFormatter.doubleValueToSatoshis(collateralAmountAsDouble);
|
BigInteger collateral = BtcFormatter.doubleValueToSatoshis(collateralAmountAsDouble);
|
||||||
BigInteger totals = FeePolicy.CREATE_OFFER_FEE.add(collateral);
|
BigInteger totals = FeePolicy.CREATE_OFFER_FEE.add(collateral).add(FeePolicy.TX_FEE);
|
||||||
totalTextField.setText(BtcFormatter.formatSatoshis(totals));
|
totalTextField.setText(BtcFormatter.formatSatoshis(totals));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -282,7 +282,7 @@ public class TakerOfferController implements Initializable, ChildController
|
||||||
|
|
||||||
private String getFormattedTotal()
|
private String getFormattedTotal()
|
||||||
{
|
{
|
||||||
return BitSquareFormatter.formatVolume(getTotal().doubleValue());
|
return BitSquareFormatter.formatDouble(BtcFormatter.satoshiToBTC(getTotal()), 4);
|
||||||
}
|
}
|
||||||
|
|
||||||
private String getFormattedCollateral()
|
private String getFormattedCollateral()
|
||||||
|
|
|
||||||
|
|
@ -38,7 +38,7 @@ public class MessageFacade
|
||||||
private static final Logger log = LoggerFactory.getLogger(MessageFacade.class);
|
private static final Logger log = LoggerFactory.getLogger(MessageFacade.class);
|
||||||
// private static final String PING = "ping";
|
// private static final String PING = "ping";
|
||||||
// private static final String PONG = "pong";
|
// private static final String PONG = "pong";
|
||||||
private static final int MASTER_PEER_PORT = 5000;
|
private static final int MASTER_PEER_PORT = 5001;
|
||||||
|
|
||||||
private final List<OrderBookListener> orderBookListeners = new ArrayList<>();
|
private final List<OrderBookListener> orderBookListeners = new ArrayList<>();
|
||||||
private final List<ArbitratorListener> arbitratorListeners = new ArrayList<>();
|
private final List<ArbitratorListener> arbitratorListeners = new ArrayList<>();
|
||||||
|
|
|
||||||
|
|
@ -17,7 +17,7 @@ public class CreateDepositTx
|
||||||
FaultHandler faultHandler,
|
FaultHandler faultHandler,
|
||||||
WalletFacade walletFacade,
|
WalletFacade walletFacade,
|
||||||
String tradeId,
|
String tradeId,
|
||||||
BigInteger collateralAmount,
|
BigInteger offererInputAmount,
|
||||||
String takerMultiSigPubKey,
|
String takerMultiSigPubKey,
|
||||||
String arbitratorPubKeyAsHex)
|
String arbitratorPubKeyAsHex)
|
||||||
{
|
{
|
||||||
|
|
@ -25,7 +25,7 @@ public class CreateDepositTx
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
String offererPubKey = walletFacade.getAddressInfoByTradeID(tradeId).getPubKeyAsHexString();
|
String offererPubKey = walletFacade.getAddressInfoByTradeID(tradeId).getPubKeyAsHexString();
|
||||||
Transaction transaction = walletFacade.offererCreatesMSTxAndAddPayment(collateralAmount, offererPubKey, takerMultiSigPubKey, arbitratorPubKeyAsHex, tradeId);
|
Transaction transaction = walletFacade.offererCreatesMSTxAndAddPayment(offererInputAmount, offererPubKey, takerMultiSigPubKey, arbitratorPubKeyAsHex, tradeId);
|
||||||
|
|
||||||
String preparedOffererDepositTxAsHex = Utils.bytesToHexString(transaction.bitcoinSerialize());
|
String preparedOffererDepositTxAsHex = Utils.bytesToHexString(transaction.bitcoinSerialize());
|
||||||
long offererTxOutIndex = transaction.getInput(0).getOutpoint().getIndex();
|
long offererTxOutIndex = transaction.getInput(0).getOutpoint().getIndex();
|
||||||
|
|
|
||||||
|
|
@ -4,6 +4,7 @@ import com.google.bitcoin.core.ECKey;
|
||||||
import com.google.bitcoin.core.Transaction;
|
import com.google.bitcoin.core.Transaction;
|
||||||
import io.bitsquare.bank.BankAccount;
|
import io.bitsquare.bank.BankAccount;
|
||||||
import io.bitsquare.btc.BlockChainFacade;
|
import io.bitsquare.btc.BlockChainFacade;
|
||||||
|
import io.bitsquare.btc.FeePolicy;
|
||||||
import io.bitsquare.btc.WalletFacade;
|
import io.bitsquare.btc.WalletFacade;
|
||||||
import io.bitsquare.crypto.CryptoFacade;
|
import io.bitsquare.crypto.CryptoFacade;
|
||||||
import io.bitsquare.msg.MessageFacade;
|
import io.bitsquare.msg.MessageFacade;
|
||||||
|
|
@ -194,9 +195,9 @@ public class ProtocolForOffererAsBuyer
|
||||||
log.debug("onResultVerifyTakeOfferFeePayment called " + step++);
|
log.debug("onResultVerifyTakeOfferFeePayment called " + step++);
|
||||||
|
|
||||||
BigInteger collateral = trade.getCollateralAmount();
|
BigInteger collateral = trade.getCollateralAmount();
|
||||||
|
BigInteger offererInputAmount = collateral.add(FeePolicy.TX_FEE);
|
||||||
state = State.CreateDepositTx;
|
state = State.CreateDepositTx;
|
||||||
CreateDepositTx.run(this::onResultCreateDepositTx, this::onFault, walletFacade, tradeId, collateral, takerPubKey, arbitratorPubKey);
|
CreateDepositTx.run(this::onResultCreateDepositTx, this::onFault, walletFacade, tradeId, offererInputAmount, takerPubKey, arbitratorPubKey);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void onResultCreateDepositTx(String offererPubKey, String preparedOffererDepositTxAsHex, long offererTxOutIndex)
|
public void onResultCreateDepositTx(String offererPubKey, String preparedOffererDepositTxAsHex, long offererTxOutIndex)
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue