/* * This file is part of the Flowee project * Copyright (C) 2025 Tom Zander * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program. If not, see . */ #include "QMLData.h" #include "SeedsBackup.h" QMLData::QMLData(QObject *parent) : QObject{parent} { } QMLData::~QMLData() { delete m_backup; } void QMLData::addWallet(const std::shared_ptr &wallet, bool fullMatch) { m_matches.append({wallet, fullMatch}); } bool QMLData::seedKnown() const { return !m_matches.isEmpty(); } QList QMLData::matchingAccounts() const { QList answer; for (const auto &m : m_matches) { answer.append(m.wallet->segment()->segmentId()); } return answer; } bool QMLData::fullMatch(int id) const { for (const auto &m : m_matches) { if (m.wallet->segment()->segmentId() == id) { return m.fullMatch; } } return false; } QString QMLData::derivationPath(int index) const { assert(m_backup); assert(index >= 0); assert(m_backup->paths().size() > index); return m_backup->paths().at(index).path; } QString QMLData::pathName(int index) const { assert(m_backup); assert(index >= 0); assert(m_backup->paths().size() > index); return m_backup->paths().at(index).name; } int QMLData::pathStartingHeight(int index) const { assert(m_backup); assert(index >= 0); assert(m_backup->paths().size() > index); return m_backup->paths().at(index).startingHeight; } int QMLData::numberOfPaths() const { assert(m_backup); return m_backup->paths().size(); } SeedsBackup *QMLData::seeds() const { return m_backup; } void QMLData::setSeeds(SeedsBackup *seeds) { m_backup = seeds; } QString QMLData::seed() const { return m_seed; } void QMLData::setSeed(const QString &newSeed) { m_seed = newSeed; } QString QMLData::backupName() const { assert(m_backup); return m_backup->name(); }