"use strict";
var __importDefault = (this && this.__importDefault) || function (mod) {
    return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
const Amount_1 = __importDefault(require("./Amount"));
const Input_1 = __importDefault(require("./Input"));
/**
 * Class for interfacing with utxos in CFD DLC JS
 * https://github.com/atomicfinance/cfd-dlc-js.git#v0.0.18
 */
class Utxo {
    constructor(txid, vout, amount, address, maxWitnessLength, derivationPath, inputSerialId) {
        this.txid = txid;
        this.vout = vout;
        this.amount = amount;
        this.address = address;
        this.maxWitnessLength = maxWitnessLength;
        this.derivationPath = derivationPath;
        this.inputSerialId = inputSerialId;
    }
    toInput() {
        return new Input_1.default(this.txid, this.vout, this.address, this.amount.GetBitcoinAmount(), this.amount.GetSatoshiAmount(), this.derivationPath, this.maxWitnessLength, undefined, // redeemScript
        this.inputSerialId ? BigInt(this.inputSerialId) : undefined, undefined, // scriptPubKey
        undefined, // label
        undefined, // confirmations
        undefined, // spendable
        undefined, // solvable
        undefined, // safe
        undefined);
    }
    toTxInputInfo() {
        return {
            txid: this.txid,
            vout: this.vout,
            scriptSig: Buffer.alloc(0),
            maxWitnessLength: this.maxWitnessLength,
            serialId: this.inputSerialId ? BigInt(this.inputSerialId) : undefined,
        };
    }
    toJSON() {
        return Object.assign({}, this, {
            txid: this.txid,
            vout: this.vout,
            amount: this.amount.toJSON(),
            address: this.address,
            derivationPath: this.derivationPath,
            maxWitnessLength: this.maxWitnessLength,
            inputSerialId: this.inputSerialId,
        });
    }
    static fromJSON(json) {
        const utxo = Object.create(Utxo.prototype);
        return Object.assign(utxo, json, {
            txid: json.txid,
            vout: json.vout,
            amount: Amount_1.default.fromJSON(json.amount),
            address: json.address,
            derivationPath: json.derivationPath,
            maxWitnessLength: json.maxWitnessLength,
        });
    }
    // eslint-disable-next-line @typescript-eslint/no-explicit-any
    static reviver(key, value) {
        return key === '' ? Utxo.fromJSON(value) : value;
    }
}
exports.default = Utxo;
//# sourceMappingURL=Utxo.js.map