device: show address on device display

- Trezor: support for device address display (subaddress, integrated address)
- Wallet::API support added
- Simplewallet:
  - address device [<index>]
  - address new <label>  // shows address on device also
  - integrated_address [device] <payment_id|address>  // new optional "device" arg to display also on the device
This commit is contained in:
Dusan Klinec 2019-05-31 10:41:52 +02:00
parent 5fbfa8a656
commit f074b6b571
No known key found for this signature in database
GPG key ID: 6337E118CCBCE103
12 changed files with 128 additions and 7 deletions

View file

@ -200,6 +200,10 @@ namespace trezor {
}
}
void device_trezor::display_address(const cryptonote::subaddress_index& index, const boost::optional<crypto::hash8> &payment_id) {
get_address(index, payment_id, true);
}
/* ======================================================================= */
/* Helpers */
/* ======================================================================= */
@ -209,8 +213,12 @@ namespace trezor {
/* ======================================================================= */
std::shared_ptr<messages::monero::MoneroAddress> device_trezor::get_address(
const boost::optional<cryptonote::subaddress_index> & subaddress,
const boost::optional<crypto::hash8> & payment_id,
bool show_address,
const boost::optional<std::vector<uint32_t>> & path,
const boost::optional<cryptonote::network_type> & network_type){
CHECK_AND_ASSERT_THROW_MES(!payment_id || !subaddress || subaddress->is_zero(), "Subaddress cannot be integrated");
TREZOR_AUTO_LOCK_CMD();
require_connected();
device_state_reset_unsafe();
@ -218,6 +226,14 @@ namespace trezor {
auto req = std::make_shared<messages::monero::MoneroGetAddress>();
this->set_msg_addr<messages::monero::MoneroGetAddress>(req.get(), path, network_type);
req->set_show_display(show_address);
if (subaddress){
req->set_account(subaddress->major);
req->set_minor(subaddress->minor);
}
if (payment_id){
req->set_payment_id(std::string(payment_id->data, 8));
}
auto response = this->client_exchange<messages::monero::MoneroAddress>(req);
MTRACE("Get address response received");

View file

@ -110,6 +110,7 @@ namespace trezor {
/* ======================================================================= */
bool get_public_address(cryptonote::account_public_address &pubkey) override;
bool get_secret_keys(crypto::secret_key &viewkey , crypto::secret_key &spendkey) override;
void display_address(const cryptonote::subaddress_index& index, const boost::optional<crypto::hash8> &payment_id) override;
/* ======================================================================= */
/* TREZOR PROTOCOL */
@ -119,6 +120,9 @@ namespace trezor {
* Get address. Throws.
*/
std::shared_ptr<messages::monero::MoneroAddress> get_address(
const boost::optional<cryptonote::subaddress_index> & subaddress = boost::none,
const boost::optional<crypto::hash8> & payment_id = boost::none,
bool show_address = false,
const boost::optional<std::vector<uint32_t>> & path = boost::none,
const boost::optional<cryptonote::network_type> & network_type = boost::none);

View file

@ -27,6 +27,7 @@
// THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
//
#include "version.h"
#include "protocol.hpp"
#include <unordered_map>
#include <set>
@ -502,6 +503,8 @@ namespace tx {
tsx_data.set_num_inputs(static_cast<google::protobuf::uint32>(tx.sources.size()));
tsx_data.set_mixin(static_cast<google::protobuf::uint32>(tx.sources[0].outputs.size() - 1));
tsx_data.set_account(tx.subaddr_account);
tsx_data.set_monero_version(std::string(MONERO_VERSION) + "|" + MONERO_VERSION_TAG);
tsx_data.set_hard_fork(m_aux_data->hard_fork ? m_aux_data->hard_fork.get() : 0);
assign_to_repeatable(tsx_data.mutable_minor_indices(), tx.subaddr_indices.begin(), tx.subaddr_indices.end());
// Rsig decision