Skip to content

Commit

Permalink
1.9.20
Browse files Browse the repository at this point in the history
  • Loading branch information
tongvanlinh committed Jun 8, 2023
1 parent 10b26dc commit dc43784
Show file tree
Hide file tree
Showing 55 changed files with 1,348 additions and 1,199 deletions.
5 changes: 5 additions & 0 deletions CMakeLists.txt
Expand Up @@ -140,6 +140,7 @@ set(Views_SRCS
Views/STATE_ID_SCR_ADD_LEDGER_ASK.cpp
Views/STATE_ID_SCR_ADD_TREZOR.cpp
Views/STATE_ID_SCR_ADD_TREZOR_ASK.cpp
Views/STATE_ID_SCR_SELECT_WALLET_CO_SIGN_POLICE.cpp
)

set(Views_MOCS
Expand Down Expand Up @@ -262,6 +263,10 @@ if(APPLE)
PROPERTIES MACOSX_BUNDLE_INFO_PLIST "${CMAKE_CURRENT_SOURCE_DIR}/Info.plist")
endif()

if(WIN32)
# set_target_properties(${PROJECT_NAME} PROPERTIES WIN32_EXECUTABLE FALSE)
endif()

target_link_libraries (${PROJECT_NAME} Qt5::Core Qt5::Gui Qt5::Qml Qt5::Quick Qt5::Concurrent Qt5::Svg )

if(UNIX AND NOT APPLE)
Expand Down
6 changes: 3 additions & 3 deletions Info.plist
Expand Up @@ -22,9 +22,9 @@
<key>CFBundleDisplayName</key>
<string>${PRODUCT_NAME}</string>
<key>CFBundleShortVersionString</key>
<string>1.9.19</string>
<string>1.9.20</string>
<key>CFBundleGetInfoString</key>
<string>${PRODUCT_NAME} 1.9.19</string>
<string>${PRODUCT_NAME} 1.9.20</string>
<key>NSHighResolutionCapable</key>
<true/>
<key>NSCameraUsageDescription</key>
Expand All @@ -34,7 +34,7 @@
<key>CFBundleInfoDictionaryVersion</key>
<string>6.0</string>
<key>CFBundleVersion</key>
<string>1.9.19</string>
<string>1.9.20</string>
<key>CFBundleIconName</key>
<string>AppIcon</string>
<key>UIPrerenderedIcon</key>
Expand Down
26 changes: 0 additions & 26 deletions Models/AppModel.cpp
Expand Up @@ -508,32 +508,6 @@ void AppModel::setMinFee(qint64 fee)
}
}

void AppModel::checkDeviceUsableToSign()
{
if( transactionInfo() && transactionInfo()->singleSignersAssigned()){
if(deviceList()){
transactionInfo()->singleSignersAssigned()->resetSignerReadyToSign();
for (QDevicePtr signer : deviceList()->fullList()) {
transactionInfo()->singleSignersAssigned()->updateSignerReadyToSign(signer.data()->masterFingerPrint());
}
}
}
}

void AppModel::checkDeviceUsableToAdd()
{
if(deviceList() && masterSignerList()){
deviceList()->resetUsableToAdd();
for (int i = 0; i < deviceList()->rowCount(); i++) {
QDevicePtr dv = deviceList()->getDeviceByIndex(i);
if(dv){
bool usable = masterSignerList()->containsFingerPrint(dv.data()->masterFingerPrint());
deviceList()->updateUsableToAdd(dv.data()->masterFingerPrint(), !usable);
}
}
}
}

void AppModel::resetSignersChecked()
{
if(masterSignerList_){
Expand Down
2 changes: 0 additions & 2 deletions Models/AppModel.h
Expand Up @@ -184,8 +184,6 @@ class AppModel final : public Controller
QString minFee() const;
void setMinFee(qint64 fee);

void checkDeviceUsableToSign();
void checkDeviceUsableToAdd();
void resetSignersChecked();
QString addressBalance() const;
void setAddressBalance(const qint64 &addressBalance);
Expand Down
1 change: 1 addition & 0 deletions Models/Chats/QNunchukRoomModel.cpp
Expand Up @@ -2560,6 +2560,7 @@ void QNunchukRoomListModel::roomNeedTobeLeaved(const QString &id)

void QNunchukRoomListModel::synchonizesUserDataFinished()
{
DBG_INFO;
AppModel::instance()->closePromtNunchukSync();
AppModel::instance()->startReloadWallets();
AppModel::instance()->startReloadMasterSigners();
Expand Down
23 changes: 16 additions & 7 deletions Models/Chats/QUserWallets.cpp
Expand Up @@ -589,12 +589,14 @@ bool QUserWallets::inheritanceClaimRequest(const nunchuk::Wallet wallet, const n
QString reject_msg = transaction.value("reject_msg").toString();
bridge::nunchukUpdateTransaction(QString::fromStdString(wallet.get_id()), QString::fromStdString(txSigned.get_txid()), id, hex, reject_msg, _msg);
}
mInheritance.balance = 0;//BTC
emit ServiceSetting::instance()->inheritanceChanged();
}
else {
AppModel::instance()->showToast(0,
errormsg,
EWARNING::WarningType::ERROR_MSG,
STR_CPP_112);
STR_CPP_118);
}
return ret;
}
Expand Down Expand Up @@ -623,7 +625,7 @@ int QUserWallets::inheritanceClaimStatus(const QJsonObject& data, const QString&
mInheritance.magic = inheritance["magic"].toString();
mInheritance.note = inheritance["note"].toString();
mInheritance.balance = result["balance"].toDouble();//BTC
emit ServiceSetting::instance()->inheritanceChanged();;
emit ServiceSetting::instance()->inheritanceChanged();
}
QJsonObject buffer_period_countdown = result["buffer_period_countdown"].toObject();
if (!buffer_period_countdown.isEmpty()) {
Expand Down Expand Up @@ -747,17 +749,23 @@ void QUserWallets::inheritanceSignTransaction()
auto signer = mInheritance.wallet.get_signers().front();
QWarningMessage msg;
nunchuk::Transaction signed_tx = nunchukiface::instance()->SignTransaction(mInheritance.wallet, mInheritance.tx, nunchuk::Device(signer.get_master_signer_id()),msg);
DBG_INFO << msg.type();
if (NONE_MSG == msg.type()) {
QTransactionPtr trans = bridge::convertTransaction(signed_tx, QString::fromStdString(signer.get_master_signer_id()));
AppModel::instance()->setTransactionInfo(trans);
inheritanceClaimRequest(mInheritance.wallet, signed_tx, mInheritance.magic);
} else {
AppModel::instance()->showToast(msg.code(),
msg.what(),
(EWARNING::WarningType)msg.type(),
STR_CPP_059);
}
}

bool QUserWallets::serverKeyGetCurrentPolicies()
bool QUserWallets::serverKeyGetCurrentPolicies(const QString& wallet_id)
{
QWarningMessage msgWallet;
nunchuk::Wallet wallet = nunchukiface::instance()->GetWallet(m_wallet_id.toStdString(), msgWallet);; // Get current Assisted wallet = <get assisted wallet>
nunchuk::Wallet wallet = nunchukiface::instance()->GetWallet(wallet_id.toStdString(), msgWallet);; // Get current Assisted wallet = <get assisted wallet>
nunchuk::SingleSigner server_key;// Get server key from wallet type = <SignerType::SERVER>
for (auto key : wallet.get_signers()) {
if (key.get_type() == nunchuk::SignerType::SERVER) {
Expand All @@ -766,7 +774,7 @@ bool QUserWallets::serverKeyGetCurrentPolicies()
}
mCoSigning.m_server_key = server_key;
mCoSigning.key_id_or_xfp = QString::fromStdString(server_key.get_master_fingerprint());
mCoSigning.wallet_id = m_wallet_id;
mCoSigning.wallet_id = wallet_id;
QJsonObject output;
QString errormsg = "";
bool ret = Draco::instance()->serverKeysGet(mCoSigning.key_id_or_xfp, output, errormsg);
Expand All @@ -787,8 +795,9 @@ bool QUserWallets::serverKeyGetCurrentPolicies()
// Iron hand
} else {
//Honey badger
QLocale locale(QLocale::English);
maps["interval"] = spendlimit["interval"].toString(); //[ DAILY, WEEKLY, MONTHLY, YEARLY ]
maps["limit"] = spendlimit["limit"].toInt(); //unit is interval
maps["limit"] = locale.toString(spendlimit["limit"].toDouble(), 'f', qUtils::Precision(spendlimit["limit"].toDouble())); //unit is interval
maps["currency"] = spendlimit["currency"].toString();
}
ServiceSetting::instance()->setKeyCoSigning(QVariant::fromValue(maps));
Expand All @@ -808,7 +817,7 @@ QJsonObject QUserWallets::serverKeyBody()
QMap<QString,QVariant> plans = CLIENT_INSTANCE->user().toMap();
if (plans["plan_slug"] == "honey_badger") {
spending_limit["interval"] = maps["interval"].toString();
spending_limit["limit"] = maps["limit"].toInt();
spending_limit["limit"] = maps["limit"].toDouble();
spending_limit["currency"] = maps["currency"].toString();
}

Expand Down
7 changes: 4 additions & 3 deletions Models/Chats/QUserWallets.h
Expand Up @@ -87,20 +87,20 @@ class QUserWallets : public QObject
bool startRecovery(const QString& backup_password);

QMasterSigner *signer() const;

//Inheritance
Q_INVOKABLE int inheritanceCheck(const QString& magic = "", const QString& environment = "PRODUCTION");
bool inheritanceGetPlan(const QString &magic_inpputed, const QString& wallet_id);
int inheritanceDownloadBackup(const QString& magic, const QString& backup_password);
bool inheritanceClaimRequest(const nunchuk::Wallet wallet, const nunchuk::Transaction txSigned, const QString& magic);
int inheritanceClaimStatus(const QJsonObject& data, const QString& autho);
bool inheritanceCreateTx(const nunchuk::SingleSigner& signer, const QJsonObject& data, const QString& autho);

void setInheritanceAddress(const QString& to_wallet_id);
void setInheritanceAddressNewTransaction(const QString& address);
void inheritanceCreateDraftTransaction(double fee_rate = 1000.0);
void inheritanceSignTransaction();

bool serverKeyGetCurrentPolicies();
// For co-signing policies
bool serverKeyGetCurrentPolicies(const QString& wallet_id);
QJsonObject serverKeyBody();
bool serverKeyUpdatePolicies();
bool serverKeyUpdatePoliciesSucceed();
Expand All @@ -120,6 +120,7 @@ class QUserWallets : public QObject
void securityQuestionChanged();
void serverKeyDummyTransactionAlert();
void securityQuestionClosed();
void thereNoAssistedWalletAlert();
private:
QString m_passwordToken;
QString m_secQuesToken;
Expand Down
75 changes: 27 additions & 48 deletions Models/DeviceModel.cpp
Expand Up @@ -21,12 +21,12 @@
#include "AppModel.h"
#include <QQmlEngine>

QDevice::QDevice(): isDraft(true)
QDevice::QDevice(): m_isDraft(true)
{
QQmlEngine::setObjectOwnership(this, QQmlEngine::CppOwnership);
}

QDevice::QDevice(const nunchuk::Device &device) : device_(device)
QDevice::QDevice(const nunchuk::Device &device) : m_device(device)
{
QQmlEngine::setObjectOwnership(this, QQmlEngine::CppOwnership);
}
Expand All @@ -36,55 +36,54 @@ QDevice::~QDevice(){}
QString QDevice::name()
{
QString name = "";
QString xfp = QString::fromStdString(device_.get_master_fingerprint());
QString xfp = QString::fromStdString(m_device.get_master_fingerprint());
if(AppModel::instance()->masterSignerList()){
name = AppModel::instance()->masterSignerList()->getMasterSignerNameByFingerPrint(xfp);
}
if(name == ""){
name = QString::fromStdString(device_.get_type());
name = QString::fromStdString(m_device.get_type());
}
return name;
}

QString QDevice::type() const {
return QString::fromStdString(device_.get_type());
return QString::fromStdString(m_device.get_type());
}

QString QDevice::path() const {
return QString::fromStdString(device_.get_path());
return QString::fromStdString(m_device.get_path());
}

QString QDevice::model() const {
return QString::fromStdString(device_.get_model());
return QString::fromStdString(m_device.get_model());
}

QString QDevice::masterFingerPrint() const {
return QString::fromStdString(device_.get_master_fingerprint());
return QString::fromStdString(m_device.get_master_fingerprint());
}

bool QDevice::connected() const {
return device_.connected();
return m_device.connected();
}

bool QDevice::needsPassPhraseSent() const {
return device_.needs_pass_phrase_sent();
return m_device.needs_pass_phrase_sent();
}

bool QDevice::needsPinSent() const {
return device_.needs_pin_sent();
return m_device.needs_pin_sent();
}

bool QDevice::usableToAdd() const
bool QDevice::usableToAdd()
{
return usableToAdd_;
}

void QDevice::setUsableToAdd(bool usableToAdd)
{
if(usableToAdd_ != usableToAdd){
usableToAdd_ = usableToAdd;
emit usableToAddChanged();
bool used = false;
if(AppModel::instance()->masterSignerList()){
used = AppModel::instance()->masterSignerList()->containsFingerPrint(masterFingerPrint());
}
if(!used && AppModel::instance()->remoteSignerList()){
used = AppModel::instance()->remoteSignerList()->containsFingerPrint(masterFingerPrint());
}
return !used;
}

QString QDevice::masterSignerId() const
Expand All @@ -101,22 +100,22 @@ QString QDevice::masterSignerId() const

QString QDevice::cardId() const
{
return cardId_;
return m_cardId;
}

void QDevice::setCardId(const QString &card_id)
{
cardId_ = card_id;
m_cardId = card_id;
}

nunchuk::Device QDevice::originDevice() const
{
return device_;
return m_device;
}

void QDevice::setOriginDevice(const nunchuk::Device &device)
{
device_ = device;
m_device = device;
}

DeviceListModel::DeviceListModel()
Expand Down Expand Up @@ -277,24 +276,14 @@ QDevicePtr DeviceListModel::getDeviceNeedPinSent(){
return QDevicePtr(NULL);
}

void DeviceListModel::resetUsableToAdd()
{
beginResetModel();
foreach (QDevicePtr it, d_) {
it.data()->setUsableToAdd(false);
}
endResetModel();
}

void DeviceListModel::updateUsableToAdd(const QString &fingerprint, bool value)
bool DeviceListModel::containsFingerPrint(const QString &xfp)
{
foreach (QDevicePtr it, d_) {
if(0 == QString::compare(fingerprint, it.data()->masterFingerPrint(), Qt::CaseInsensitive)){
it.data()->setUsableToAdd(value);
emit dataChanged(this->index(d_.indexOf(it)),this->index(d_.indexOf(it)));
if(0 == QString::compare(xfp, it.data()->masterFingerPrint(), Qt::CaseInsensitive)){
return true;
}
}
emit containsAddableChanged();
return false;
}

bool DeviceListModel::contains(const QString &fingerprint)
Expand All @@ -321,16 +310,6 @@ bool DeviceListModel::needScanDevice()
return false;
}

bool DeviceListModel::containsAddable() const
{
foreach (QDevicePtr i , d_ ){
if(i.data()->usableToAdd()){
return true;
}
}
return false;
}

QStringList DeviceListModel::getXFPList()
{
QStringList ret;
Expand Down

0 comments on commit dc43784

Please sign in to comment.