From d65e09893324d7378e365d5eb2ad14855a2ec0c3 Mon Sep 17 00:00:00 2001 From: Manfred Karrer Date: Tue, 7 Feb 2017 18:47:20 -0500 Subject: [PATCH] Increase tx fee to 0.0007 btc, increase tradeprotocol version, change log level for tx details to INFO --- .../main/java/io/bitsquare/app/Version.java | 2 +- .../main/java/io/bitsquare/btc/FeePolicy.java | 18 +++++------ .../io/bitsquare/btc/TradeWalletService.java | 32 +++++++++++-------- 3 files changed, 28 insertions(+), 24 deletions(-) diff --git a/common/src/main/java/io/bitsquare/app/Version.java b/common/src/main/java/io/bitsquare/app/Version.java index a2a7a137d3..3fc43cc715 100644 --- a/common/src/main/java/io/bitsquare/app/Version.java +++ b/common/src/main/java/io/bitsquare/app/Version.java @@ -43,7 +43,7 @@ public class Version { // The version no. of the current protocol. The offer holds that version. // A taker will check the version of the offers to see if his version is compatible. - public static final int TRADE_PROTOCOL_VERSION = 1; + public static final int TRADE_PROTOCOL_VERSION = 2; private static int p2pMessageVersion; public static int getP2PMessageVersion() { diff --git a/core/src/main/java/io/bitsquare/btc/FeePolicy.java b/core/src/main/java/io/bitsquare/btc/FeePolicy.java index aec8b80a78..644ddd2281 100644 --- a/core/src/main/java/io/bitsquare/btc/FeePolicy.java +++ b/core/src/main/java/io/bitsquare/btc/FeePolicy.java @@ -29,22 +29,22 @@ public class FeePolicy { // http://p2sh.info/dashboard/db/fee-estimation // https://bitcoinfees.github.io/#1d // Average values are 10-100 satoshis/byte in january 2016 + // Average values are 60-140 satoshis/byte in february 2017 // // Our trade transactions have a fixed set of inputs and outputs making the size very predictable // (as long the user does not do multiple funding transactions) // - // trade fee tx: 226 bytes // 88 satoshi/byte - // deposit tx: 336 bytes // 59 satoshi/byte - // payout tx: 371 bytes // 53 satoshi/byte - // disputed payout tx: 408 bytes // 49 satoshi/byte + // trade fee tx: 226 bytes // 309 satoshi/byte + // deposit tx: 336 bytes // 208 satoshi/byte + // payout tx: 371 bytes // 188 satoshi/byte + // disputed payout tx: 408 bytes // 171 satoshi/byte // We set a fixed fee to make the needed amounts in the trade predictable. - // We use 0.0002 BTC (0.08 EUR @ 400 EUR/BTC) which is for our tx sizes about 50-90 satoshi/byte + // We use 0.0007 BTC (0.7 EUR @ 1000 EUR/BTC) which is for our tx sizes about 150-300 satoshi/byte // We cannot make that user defined as it need to be the same for both users, so we can only change that in // software updates - // TODO before Beta we should get a good future proof guess as a change causes incompatible versions public static Coin getFixedTxFeeForTrades() { - return DevFlags.STRESS_TEST_MODE ? Coin.valueOf(5_000) : Coin.valueOf(20_000); + return DevFlags.STRESS_TEST_MODE ? Coin.valueOf(5_000) : Coin.valueOf(70_000); } // For non trade transactions (withdrawal) we use the default fee calculation @@ -65,9 +65,9 @@ public class FeePolicy { // 0.0005 BTC 0.05% of 1 BTC about 0.2 EUR @ 400 EUR/BTC public static Coin getCreateOfferFee() { - // We need to pay the quite high miner fee of 30_000 from the trading fee tx so 30_000 us our lower limit + // We need to pay the quite high miner fee of 70_000 from the trading fee tx so 30_000 is our lower limit // The arbitrator receive only 0.0002 BTC - less than the miners - return DevFlags.STRESS_TEST_MODE ? Coin.valueOf(10_000) : Coin.valueOf(50_000); + return DevFlags.STRESS_TEST_MODE ? Coin.valueOf(10_000) : Coin.valueOf(100_000); } // 0.001 BTC 0.1% of 1 BTC about 0.4 EUR @ 400 EUR/BTC diff --git a/core/src/main/java/io/bitsquare/btc/TradeWalletService.java b/core/src/main/java/io/bitsquare/btc/TradeWalletService.java index 74bc6ab5ce..34cca326d9 100644 --- a/core/src/main/java/io/bitsquare/btc/TradeWalletService.java +++ b/core/src/main/java/io/bitsquare/btc/TradeWalletService.java @@ -238,7 +238,7 @@ public class TradeWalletService { verifyTransaction(dummyTX); - printTxWithInputs("dummyTX", dummyTX); + //printTxWithInputs("dummyTX", dummyTX); List rawTransactionInputList = dummyTX.getInputs().stream() .map(e -> { @@ -407,7 +407,7 @@ public class TradeWalletService { verifyTransaction(preparedDepositTx); - printTxWithInputs("preparedDepositTx", preparedDepositTx); + //printTxWithInputs("preparedDepositTx", preparedDepositTx); return new PreparedDepositTxAndOffererInputs(offererRawTransactionInputs, preparedDepositTx.bitcoinSerialize()); } @@ -429,14 +429,14 @@ public class TradeWalletService { * @throws WalletException */ public Transaction takerSignsAndPublishesDepositTx(boolean takerIsSeller, - byte[] contractHash, - byte[] offerersDepositTxSerialized, - List buyerInputs, - List sellerInputs, - byte[] buyerPubKey, - byte[] sellerPubKey, - byte[] arbitratorPubKey, - FutureCallback callback) throws SigningException, TransactionVerificationException, + byte[] contractHash, + byte[] offerersDepositTxSerialized, + List buyerInputs, + List sellerInputs, + byte[] buyerPubKey, + byte[] sellerPubKey, + byte[] arbitratorPubKey, + FutureCallback callback) throws SigningException, TransactionVerificationException, WalletException { Transaction offerersDepositTx = new Transaction(params, offerersDepositTxSerialized); @@ -493,7 +493,7 @@ public class TradeWalletService { // Add all outputs from offerersDepositTx to depositTx offerersDepositTx.getOutputs().forEach(depositTx::addOutput); - printTxWithInputs("offerersDepositTx", offerersDepositTx); + //printTxWithInputs("offerersDepositTx", offerersDepositTx); // Sign inputs int start = takerIsSeller ? buyerInputs.size() : 0; @@ -577,7 +577,7 @@ public class TradeWalletService { verifyTransaction(preparedPayoutTx); - printTxWithInputs("preparedPayoutTx", preparedPayoutTx); + //printTxWithInputs("preparedPayoutTx", preparedPayoutTx); return sellerSignature.encodeToDER(); } @@ -732,7 +732,7 @@ public class TradeWalletService { verifyTransaction(preparedPayoutTx); - printTxWithInputs("preparedPayoutTx", preparedPayoutTx); + //printTxWithInputs("preparedPayoutTx", preparedPayoutTx); return arbitratorSignature.encodeToDER(); } @@ -1122,7 +1122,11 @@ public class TradeWalletService { } private static void printTxWithInputs(String tracePrefix, Transaction tx) { - log.info(tracePrefix + ": " + tx.toString()); + long fee = tx.getFee() != null ? tx.getFee().value : 0; + int size = tx.getMessageSize(); + log.info(tracePrefix + ": " + tx.toString() + "\nSize (Byte): " + size + "\nFee (Satoshi/Byte): " + + (fee / size)); + for (TransactionInput input : tx.getInputs()) { if (input.getConnectedOutput() != null) log.info(tracePrefix + " input value: " + input.getConnectedOutput().getValue().toFriendlyString());