Skip to content
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

Merged
merged 2 commits into from
May 31, 2018

Conversation

naughtyfox
Copy link
Contributor

@naughtyfox naughtyfox commented Mar 23, 2018

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:

  • create multisig wallets
  • multisig key images exchange
  • create, sign, commit multisig transactions
  • Refactored the facility to set Wallet status to work in atomic way.

Tested transaction sending on ubuntu 17.10
API usage example: https://github.com/naughtyfox/monero-multisig-api-example/blob/master/main.cpp

Copy link
Contributor

@stoffu stoffu left a 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.

break;
}


Copy link
Contributor

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("");
Copy link
Contributor

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?

Copy link
Contributor Author

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("");
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same

Copy link
Contributor Author

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("");
Copy link
Contributor

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");
Copy link
Contributor

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

Copy link
Contributor Author

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

Copy link
Contributor Author

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

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;
Copy link
Contributor

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.

{
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);
}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No whitespace changes

@@ -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;
Copy link
Contributor

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?

}

tools::wallet2::multisig_tx_set txSet;
if (!m_wallet->load_multisig_tx(binary, txSet, std::function<bool(const tools::wallet2::multisig_tx_set&)>())) {
Copy link
Contributor

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 {}

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

that's it! thx :)

/**
* @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
Copy link
Contributor

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".

Copy link
Contributor Author

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

@stoffu
Copy link
Contributor

stoffu commented Mar 26, 2018

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
@naughtyfox naughtyfox changed the title [WIP] multisig entries for wallet api [RELEASE] multisig entries for wallet api Mar 28, 2018
@naughtyfox
Copy link
Contributor Author

naughtyfox commented Mar 28, 2018

squashed into 3 commits
@stoffu please check this out

@stoffu
Copy link
Contributor

stoffu commented Mar 28, 2018

@naughtyfox
Are you intentionally refusing to remove those indentation changes and spurious line addition/deletion, which I'm strongly against?

@naughtyfox
Copy link
Contributor Author

@stoffu Sorry, just got your message about minimizing changes wrong. Brought it back

@@ -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 {
Copy link
Contributor

@stoffu stoffu Mar 28, 2018

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.

Copy link
Contributor Author

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

@@ -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;

Copy link
Contributor

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.

@stoffu
Copy link
Contributor

stoffu commented Mar 28, 2018

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.

@naughtyfox
Copy link
Contributor Author

i thought i removed all of identations... did i miss something?

@stoffu
Copy link
Contributor

stoffu commented Mar 28, 2018

Don't you see the problem in the color-coded diff that GitHub offers?

Ah, you just need to squash the last three commits into one. That'll clear the issue.

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
@naughtyfox
Copy link
Contributor Author

Squashed into 2 commits:

  • refactoring
  • feature commit

Copy link
Contributor

@stoffu stoffu left a 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 :)

@naughtyfox
Copy link
Contributor Author

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;
Copy link
Collaborator

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) ?

Copy link
Contributor Author

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

@moneromooo-monero
Copy link
Collaborator

No it's fine, I did not know it was a different m_status field.

@luigi1111 luigi1111 merged commit 5a96056 into monero-project:master May 31, 2018
luigi1111 added a commit that referenced this pull request May 31, 2018
47fdb74 WalletApi: getMultisigInfo entry for gui wallets... (naughtyfox)
47fdb74 Refactored: work with wallet api statuses to make setting and getting operations atomic along with error strings (naughtyfox)
@stoffu stoffu mentioned this pull request Jul 4, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants