package bisq.core.btc.model;

import bisq.core.dao.state.model.blockchain.TxType;
import bisq.core.util.coin.CoinUtil;

import org.bitcoinj.core.Coin;
import org.bitcoinj.core.LegacyAddress;
import org.bitcoinj.core.Transaction;

import lombok.Getter;

@Getter
public final class BsqTransferModel {

    private final LegacyAddress receiverAddress;
    private final Coin receiverAmount;
    private final Transaction preparedSendTx;
    private final Transaction txWithBtcFee;
    private final Transaction signedTx;
    private final Coin miningFee;
    private final int txSize;
    private final TxType txType;

    public BsqTransferModel(LegacyAddress receiverAddress,
                            Coin receiverAmount,
                            Transaction preparedSendTx,
                            Transaction txWithBtcFee,
                            Transaction signedTx) {
        this.receiverAddress = receiverAddress;
        this.receiverAmount = receiverAmount;
        this.preparedSendTx = preparedSendTx;
        this.txWithBtcFee = txWithBtcFee;
        this.signedTx = signedTx;
        this.miningFee = signedTx.getFee();
        this.txSize = signedTx.bitcoinSerialize().length;
        this.txType = TxType.TRANSFER_BSQ;
    }

    public String getReceiverAddressAsString() {
        return receiverAddress.toString();
    }

    public double getMiningFeeInSatoshisPerByte() {
        return CoinUtil.getFeePerVbyte(miningFee, txSize);
    }

    public double getTxSizeInKb() {
        return txSize / 1000d;
    }

    public String toShortString() {
        return "{" + "\n" +
                "  receiverAddress='" + getReceiverAddressAsString() + '\'' + "\n" +
                ", receiverAmount=" + receiverAmount + "\n" +
                ", txWithBtcFee.txId=" + txWithBtcFee.getTxId() + "\n" +
                ", miningFee=" + miningFee + "\n" +
                ", miningFeeInSatoshisPerByte=" + getMiningFeeInSatoshisPerByte() + "\n" +
                ", txSizeInKb=" + getTxSizeInKb() + "\n" +
                '}';
    }

    @Override
    public String toString() {
        return "BsqTransferModel{" + "\n" +
                "  receiverAddress='" + getReceiverAddressAsString() + '\'' + "\n" +
                ", receiverAmount=" + receiverAmount + "\n" +
                ", preparedSendTx=" + preparedSendTx + "\n" +
                ", txWithBtcFee=" + txWithBtcFee + "\n" +
                ", signedTx=" + signedTx + "\n" +
                ", miningFee=" + miningFee + "\n" +
                ", miningFeeInSatoshisPerByte=" + getMiningFeeInSatoshisPerByte() + "\n" +
                ", txSize=" + txSize + "\n" +
                ", txSizeInKb=" + getTxSizeInKb() + "\n" +
                ", txType=" + txType + "\n" +
                '}';
    }
}

@@ -78,45 +78,8 @@
 ype;
-%0Aimport bisq.core.util.coin.CoinUtil;
 %0A%0Aim
@@ -1313,126 +1313,8 @@
  %7D%0A%0A
-    public double getMiningFeeInSatoshisPerByte() %7B%0A        return CoinUtil.getFeePerVbyte(miningFee, txSize);%0A    %7D%0A%0A
     
@@ -1723,99 +1723,8 @@
 %22 +%0A
-                %22, miningFeeInSatoshisPerByte=%22 + getMiningFeeInSatoshisPerByte() + %22%5Cn%22 +%0A
     
@@ -2204,32 +2204,32 @@
 gnedTx + %22%5Cn%22 +%0A
+
                 
@@ -2268,99 +2268,8 @@
 %22 +%0A
-                %22, miningFeeInSatoshisPerByte=%22 + getMiningFeeInSatoshisPerByte() + %22%5Cn%22 +%0A
     

Remove method only used in class' toString