Improve logging, cleanup

This commit is contained in:
Manfred Karrer 2016-11-26 20:54:04 +01:00
parent 7acfdb23de
commit ddf63cccd8
4 changed files with 53 additions and 47 deletions

View File

@ -62,7 +62,8 @@ public class BitsquareEnvironment extends StandardEnvironment {
public static final String DEFAULT_USER_DATA_DIR = defaultUserDataDir();
public static final String DEFAULT_APP_DATA_DIR = appDataDir(DEFAULT_USER_DATA_DIR, DEFAULT_APP_NAME);
public static final String LOG_LEVEL_DEFAULT = (DevFlags.STRESS_TEST_MODE || DevFlags.DEV_MODE) ? Level.TRACE.levelStr : Level.INFO.levelStr;
//public static final String LOG_LEVEL_DEFAULT = (DevFlags.STRESS_TEST_MODE || DevFlags.DEV_MODE) ? Level.TRACE.levelStr : Level.INFO.levelStr;
public static final String LOG_LEVEL_DEFAULT = Level.INFO.levelStr;
static final String BITSQUARE_COMMANDLINE_PROPERTY_SOURCE_NAME = "bitsquareCommandLineProperties";
static final String BITSQUARE_APP_DIR_PROPERTY_SOURCE_NAME = "bitsquareAppDirProperties";

View File

@ -683,16 +683,16 @@ public class TradeWalletService {
* @throws AddressFormatException
* @throws TransactionVerificationException
*/
public byte[] signDisputedPayoutTx(byte[] depositTxSerialized,
Coin buyerPayoutAmount,
Coin sellerPayoutAmount,
Coin arbitratorPayoutAmount,
String buyerAddressString,
String sellerAddressString,
AddressEntry arbitratorAddressEntry,
byte[] buyerPubKey,
byte[] sellerPubKey,
byte[] arbitratorPubKey)
public byte[] arbitratorSignsDisputedPayoutTx(byte[] depositTxSerialized,
Coin buyerPayoutAmount,
Coin sellerPayoutAmount,
Coin arbitratorPayoutAmount,
String buyerAddressString,
String sellerAddressString,
AddressEntry arbitratorAddressEntry,
byte[] buyerPubKey,
byte[] sellerPubKey,
byte[] arbitratorPubKey)
throws AddressFormatException, TransactionVerificationException {
Transaction depositTx = new Transaction(params, depositTxSerialized);
log.trace("signDisputedPayoutTx called");
@ -847,24 +847,23 @@ public class TradeWalletService {
List<String> sellerPubKeys,
FutureCallback<Transaction> callback)
throws AddressFormatException, TransactionVerificationException, WalletException {
log.trace("signAndPublishPayoutTx called");
log.trace("depositTxHex " + depositTxHex);
log.trace("buyerPayoutAmount " + buyerPayoutAmount.toFriendlyString());
log.trace("sellerPayoutAmount " + sellerPayoutAmount.toFriendlyString());
log.trace("arbitratorPayoutAmount " + arbitratorPayoutAmount.toFriendlyString());
log.trace("buyerAddressString " + buyerAddressString);
log.trace("sellerAddressString " + sellerAddressString);
log.trace("arbitratorAddressString " + arbitratorAddressString);
log.trace("buyerPrivateKeyAsHex " + buyerPrivateKeyAsHex);
log.trace("sellerPrivateKeyAsHex " + sellerPrivateKeyAsHex);
log.trace("arbitratorPrivateKeyAsHex " + arbitratorPrivateKeyAsHex);
log.trace("buyerPubKeyAsHex " + buyerPubKeyAsHex);
log.trace("sellerPubKeyAsHex " + sellerPubKeyAsHex);
log.trace("arbitratorPubKeyAsHex " + arbitratorPubKeyAsHex);
log.trace("P2SHMultiSigOutputScript " + P2SHMultiSigOutputScript);
log.trace("buyerPubKeys " + buyerPubKeys);
log.trace("sellerPubKeys " + sellerPubKeys);
log.info("signAndPublishPayoutTx called");
log.info("depositTxHex " + depositTxHex);
log.info("buyerPayoutAmount " + buyerPayoutAmount.toFriendlyString());
log.info("sellerPayoutAmount " + sellerPayoutAmount.toFriendlyString());
log.info("arbitratorPayoutAmount " + arbitratorPayoutAmount.toFriendlyString());
log.info("buyerAddressString " + buyerAddressString);
log.info("sellerAddressString " + sellerAddressString);
log.info("arbitratorAddressString " + arbitratorAddressString);
log.info("buyerPrivateKeyAsHex " + buyerPrivateKeyAsHex);
log.info("sellerPrivateKeyAsHex " + sellerPrivateKeyAsHex);
log.info("arbitratorPrivateKeyAsHex " + arbitratorPrivateKeyAsHex);
log.info("buyerPubKeyAsHex " + buyerPubKeyAsHex);
log.info("sellerPubKeyAsHex " + sellerPubKeyAsHex);
log.info("arbitratorPubKeyAsHex " + arbitratorPubKeyAsHex);
log.info("P2SHMultiSigOutputScript " + P2SHMultiSigOutputScript);
log.info("buyerPubKeys " + buyerPubKeys);
log.info("sellerPubKeys " + sellerPubKeys);
checkNotNull((buyerPrivateKeyAsHex != null || sellerPrivateKeyAsHex != null), "either buyerPrivateKeyAsHex or sellerPrivateKeyAsHex must not be null");
@ -889,8 +888,8 @@ public class TradeWalletService {
byte[] sk = ECKey.fromPublicOnly(Utils.HEX.decode(s)).getPubKey();
p2SHMultiSigOutputScript = getP2SHMultiSigOutputScript(bk, sk, arbitratorPubKey);
if (p2SHMultiSigOutputScript.toString().contains(P2SHMultiSigOutputScript)) {
log.trace("Found buyers pub key " + b);
log.trace("Found sellers pub key " + s);
log.info("Found buyers pub key " + b);
log.info("Found sellers pub key " + s);
buyerPubKey = ECKey.fromPublicOnly(Utils.HEX.decode(b)).getPubKey();
sellerPubKey = ECKey.fromPublicOnly(Utils.HEX.decode(s)).getPubKey();
found = true;

View File

@ -598,7 +598,7 @@ public class DisputeSummaryWindow extends Overlay<DisputeSummaryWindow> {
byte[] sellerPubKey,
byte[] arbitratorPubKey)
*/
byte[] arbitratorSignature = tradeWalletService.signDisputedPayoutTx(
byte[] arbitratorSignature = tradeWalletService.arbitratorSignsDisputedPayoutTx(
dispute.getDepositTxSerialized(),
disputeResult.getBuyerPayoutAmount(),
disputeResult.getSellerPayoutAmount(),

View File

@ -34,6 +34,7 @@ import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import javax.annotation.Nullable;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
@ -106,16 +107,17 @@ public class SpendFromDepositTxWindow extends Overlay<SpendFromDepositTxWindow>
InputTextField buyerPubKeysInputTextField = addLabelInputTextField(gridPane, ++rowIndex, "buyerPubKeys:").second;
InputTextField sellerPubKeysInputTextField = addLabelInputTextField(gridPane, ++rowIndex, "sellerPubKeys:").second;
List<String> buyerPubKeys = Arrays.asList(buyerPubKeysInputTextField.getText().split(","));
List<String> sellerPubKeys = Arrays.asList(sellerPubKeysInputTextField.getText().split(","));
/*
List<String> buyerPubKeys = !buyerPubKeysInputTextField.getText().isEmpty() ? Arrays.asList(buyerPubKeysInputTextField.getText().split(",")) : new ArrayList<>();
List<String> sellerPubKeys = !sellerPubKeysInputTextField.getText().isEmpty() ? Arrays.asList(sellerPubKeysInputTextField.getText().split(",")) : new ArrayList<>();
/*
depositTxHex.setText("");
buyerPayoutAmount.setText("1.01");
buyerPayoutAmount.setText("0.01");
sellerPayoutAmount.setText("0.01");
arbitratorPayoutAmount.setText("0");
buyerAddressString.setText("");
buyerPubKeyAsHex.setText("");
buyerPrivateKeyAsHex.setText("");
@ -123,22 +125,26 @@ public class SpendFromDepositTxWindow extends Overlay<SpendFromDepositTxWindow>
sellerAddressString.setText("");
sellerPubKeyAsHex.setText("");
sellerPrivateKeyAsHex.setText("");
arbitratorAddressString.setText("19xdeiQM2Hn2M2wbpT5imcYWzqhiSDHPy4");
arbitratorPubKeyAsHex.setText("02c62e794fe67f3a2115e2de4757143ff7f27bdf38aa4ae58a3595baa6d676875b");
arbitratorAddressString.setText("1FdFzBazmHQxbUbdCUJwuCtR37DrZrEobu");
arbitratorPubKeyAsHex.setText("030fdc2ebc297df4047442f6079f1ce3b7d1938a41f88bd11497545cc94fcfd315");
//4.9
// arbitratorAddressString.setText("19xdeiQM2Hn2M2wbpT5imcYWzqhiSDHPy4");
// arbitratorPubKeyAsHex.setText("02c62e794fe67f3a2115e2de4757143ff7f27bdf38aa4ae58a3595baa6d676875b");
// 4.2
arbitratorAddressString.setText("1FdFzBazmHQxbUbdCUJwuCtR37DrZrEobu");
arbitratorPubKeyAsHex.setText("030fdc2ebc297df4047442f6079f1ce3b7d1938a41f88bd11497545cc94fcfd315");
P2SHMultiSigOutputScript.setText("");
sellerPubKeys = Arrays.asList();
buyerPubKeys = Arrays.asList();
*/
actionButtonText("Sign and publish transaction");
final List<String> finalSellerPubKeys = sellerPubKeys;
final List<String> finalBuyerPubKeys = buyerPubKeys;
FutureCallback<Transaction> callback = new FutureCallback<Transaction>() {
@Override
public void onSuccess(@Nullable Transaction result) {
@ -174,7 +180,7 @@ public class SpendFromDepositTxWindow extends Overlay<SpendFromDepositTxWindow>
sellerPubKeyAsHex.getText(),
arbitratorPubKeyAsHex.getText(),
P2SHMultiSigOutputScript.getText(),
buyerPubKeys,
finalBuyerPubKeys,
finalSellerPubKeys,
callback);
} catch (AddressFormatException | WalletException | TransactionVerificationException e) {