-
-
Notifications
You must be signed in to change notification settings - Fork 3.1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[RELEASE] multisig entries for wallet api #3489
[RELEASE] multisig entries for wallet api #3489
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There are some changes done and undone in different commits; if possible, please try to squash them before the final merge.
src/wallet/api/wallet.cpp
Outdated
break; | ||
} | ||
|
||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Spurious?
} catch (const tools::error::not_enough_unlocked_money& e) { | ||
m_status = Status_Error; | ||
setStatusError(""); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
setStatusError()
is called a few lines below. Mistake?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
actually no. in previous version of code there was something like this:
m_status = Status_Error;
....
m_status = Status_Error;
m_errorString = "...";
because api lib wanted a caller to know error happened before setting actual error string. I followed the same way since m_status
was atomic
} catch (const tools::error::not_enough_money& e) { | ||
m_status = Status_Error; | ||
setStatusError(""); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
answered above
} catch (const tools::error::tx_not_possible& e) { | ||
m_status = Status_Error; | ||
setStatusError(""); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same
} | ||
|
||
if (!ready) { | ||
throw runtime_error("Multisig wallet is not finalized yet"); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Seems spurious, since checkMultisigWalletReady()
is called just above
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
you absolutely right, thank you! i wrote this code first then refactored a bit and forgot about this lines. will fix it
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
i deleted redundant checks but github shows it still for some reason
src/wallet/wallet2.cpp
Outdated
multisig_tx_set txs; | ||
txs.m_ptx = ptx_vector; | ||
wallet2::multisig_tx_set wallet2::make_multisig_tx_set(const std::vector<pending_tx>& ptx_vector) const { | ||
multisig_tx_set txs; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please conform to the same indentation convention already used in each file, which in this case is two whitespaces.
src/wallet/wallet2.cpp
Outdated
{ | ||
crypto::public_key pkey = get_multisig_signing_public_key(msk); | ||
for (auto &ptx: txs.m_ptx) for (auto &sig: ptx.multisig_sigs) sig.signing_keys.insert(pkey); | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No whitespace changes
src/wallet/wallet2.h
Outdated
@@ -821,6 +821,8 @@ namespace tools | |||
a & m_ring_history_saved; | |||
} | |||
|
|||
multisig_tx_set make_multisig_tx_set(const std::vector<pending_tx>& ptx_vector) const; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe move this line next to save_multisig_tx()
as they're closely related?
src/wallet/api/wallet.cpp
Outdated
} | ||
|
||
tools::wallet2::multisig_tx_set txSet; | ||
if (!m_wallet->load_multisig_tx(binary, txSet, std::function<bool(const tools::wallet2::multisig_tx_set&)>())) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The last argument can simply be {}
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
that's it! thx :)
src/wallet/api/wallet2_api.h
Outdated
/** | ||
* @brief makeMultisig - switches wallet in multisig state. The one and only creation phase for N / N wallets | ||
* @param info - vector of multisig infos from other participants obtained with getMulitisInfo call | ||
* @param threshold - number of required signatures to make valid transaction. Must be equal to number of participants (N) or N - 1 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'd rephrase "number of required signatures" to "number of required signers".
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
good point, i'll do it
Please do not make changes to indentations if there's no functional change. |
… operations atomic along with error strings WalletApi: added method statusWithErrorString to atomically retrieve error with error string
93b056e
to
c9bc037
Compare
squashed into 3 commits |
@naughtyfox |
@stoffu Sorry, just got your message about minimizing changes wrong. Brought it back |
src/wallet/wallet2.cpp
Outdated
@@ -4955,18 +4955,19 @@ bool wallet2::save_multisig_tx(const multisig_tx_set &txs, const std::string &fi | |||
return epee::file_io_utils::save_string_to_file(filename, ciphertext); | |||
} | |||
//---------------------------------------------------------------------------------------------------- | |||
wallet2::multisig_tx_set wallet2::make_multisig_tx_set(const std::vector<pending_tx>& ptx_vector) const { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please revert this indentation change.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
why do you want to revert it? this function is used in WalletImpl::createTransaction
src/wallet/wallet2.h
Outdated
@@ -821,8 +822,6 @@ namespace tools | |||
a & m_ring_history_saved; | |||
} | |||
|
|||
multisig_tx_set make_multisig_tx_set(const std::vector<pending_tx>& ptx_vector) const; | |||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please squash this change to the previous commit where this function was introduced.
There should be just two commits, one for the status-related refactoring and the other for the multisig feature. The last two commits should be squashed into the second commit, and the indentation change should be undone. |
i thought i removed all of identations... did i miss something? |
Ah, you just need to squash the last three commits into one. That'll clear the issue. |
86b0f7f
to
235adb5
Compare
WalletApi: makeMultisig call introduced WalletApi: finalizeMultisig call introduced WalletApi: new calls exportMultisigImages and importMultisigImages WalletApi: method to return multisig wallet creation state WalletApi: create multisig transaction, sign multisig transaction, commit transaction and get multisig data are added WalletApi: identation and style fixes
235adb5
to
5a96056
Compare
Squashed into 2 commits:
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good!
Sorry for being a little snarky about style changes, there's been quite a few similar cases lately, and I seem to be getting a little nervous about them :)
No worries! It's my fault i didn't read the contribution doc, that's my first open source contribution and i've been a bit distracted. Thank you for your patience! |
auto cipher = m_wallet.m_wallet->save_multisig_tx(m_pending_tx); | ||
return epee::string_tools::buff_to_hex_nodelimer(cipher); | ||
} catch (const std::exception& e) { | ||
m_status = Status_Error; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should this not lock the new mutex (and others below) ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It seems PendingTransactionImpl
class is not thread safe and there's no mutex at all. I just followed the same logic. If you want i can fix it
No it's fine, I did not know it was a different m_status field. |
Hey guys! We are making multisig gui wallet and we'd like these changes to be in upcoming release.
Added abilities in gui wallet api to:
Tested transaction sending on ubuntu 17.10
API usage example: https://github.com/naughtyfox/monero-multisig-api-example/blob/master/main.cpp