"use strict";
var __importDefault = (this && this.__importDefault) || function (mod) {
    return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
const createTransaction_1 = __importDefault(require("@ledgerhq/coin-bitcoin/createTransaction"));
const CAN_EDIT_FEES = true;
const areFeesProvided = tx => !!tx.feePerByte;
const convertToLiveTransaction = ({ account, walletApiTransaction }) => {
    const hasFeesProvided = areFeesProvided(walletApiTransaction);
    const liveTx = (0, createTransaction_1.default)(account);
    if (walletApiTransaction.amount) {
        liveTx.amount = walletApiTransaction.amount;
    }
    if (walletApiTransaction.recipient) {
        liveTx.recipient = walletApiTransaction.recipient;
    }
    if (walletApiTransaction.feePerByte) {
        liveTx.feePerByte = walletApiTransaction.feePerByte;
    }
    if (walletApiTransaction.opReturnData) {
        liveTx.opReturnData = walletApiTransaction.opReturnData;
    }
    if (walletApiTransaction.changeAddress) {
        liveTx.changeAddress = walletApiTransaction.changeAddress;
    }
    if (hasFeesProvided) {
        liveTx.feesStrategy = null;
    }
    return liveTx;
};
const getWalletAPITransactionSignFlowInfos = ({ walletApiTransaction, account }) => {
    return {
        canEditFees: CAN_EDIT_FEES,
        liveTx: convertToLiveTransaction({ walletApiTransaction, account }),
        hasFeesProvided: areFeesProvided(walletApiTransaction),
    };
};
exports.default = { getWalletAPITransactionSignFlowInfos };
//# sourceMappingURL=walletApiAdapter.js.map