aboutsummaryrefslogtreecommitdiff
path: root/src/device/device_ledger.hpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/device/device_ledger.hpp')
-rw-r--r--src/device/device_ledger.hpp47
1 files changed, 29 insertions, 18 deletions
diff --git a/src/device/device_ledger.hpp b/src/device/device_ledger.hpp
index e06c5f72c..f1fcaab87 100644
--- a/src/device/device_ledger.hpp
+++ b/src/device/device_ledger.hpp
@@ -32,11 +32,11 @@
#include <cstddef>
#include <string>
-#include <mutex>
#include "device.hpp"
#include <PCSC/winscard.h>
#include <PCSC/wintypes.h>
-
+#include <boost/thread/mutex.hpp>
+#include <boost/thread/recursive_mutex.hpp>
namespace hw {
@@ -80,13 +80,11 @@ namespace hw {
class device_ledger : public hw::device {
private:
- mutable std::mutex device_locker;
- mutable std::mutex tx_locker;
- void lock_device() ;
- void unlock_device() ;
- void lock_tx() ;
- void unlock_tx() ;
-
+ // Locker for concurrent access
+ mutable boost::recursive_mutex device_locker;
+ mutable boost::mutex command_locker;
+
+ //PCSC management
std::string full_name;
SCARDCONTEXT hContext;
SCARDHANDLE hCard;
@@ -95,15 +93,21 @@ namespace hw {
DWORD length_recv;
BYTE buffer_recv[BUFFER_RECV_SIZE];
unsigned int id;
-
- Keymap key_map;
-
-
void logCMD(void);
void logRESP(void);
unsigned int exchange(unsigned int ok=0x9000, unsigned int mask=0xFFFF);
void reset_buffer(void);
+ // hw running mode
+ device_mode mode;
+ // map public destination key to ephemeral destination key
+ Keymap key_map;
+
+ // To speed up blockchain parsing the view key maybe handle here.
+ crypto::secret_key viewkey;
+ bool has_view_key;
+
+ //extra debug
#ifdef DEBUG_HWDEVICE
device *controle_device;
#endif
@@ -130,6 +134,15 @@ namespace hw {
bool connect(void) override;
bool disconnect() override;
+ bool set_mode(device_mode mode) override;
+
+ /* ======================================================================= */
+ /* LOCKER */
+ /* ======================================================================= */
+ void lock(void) override;
+ void unlock(void) override;
+ bool try_lock(void) override;
+
/* ======================================================================= */
/* WALLET & ADDRESS */
/* ======================================================================= */
@@ -156,6 +169,7 @@ namespace hw {
bool sc_secret_add(crypto::secret_key &r, const crypto::secret_key &a, const crypto::secret_key &b) override;
crypto::secret_key generate_keys(crypto::public_key &pub, crypto::secret_key &sec, const crypto::secret_key& recovery_key = crypto::secret_key(), bool recover = false) override;
bool generate_key_derivation(const crypto::public_key &pub, const crypto::secret_key &sec, crypto::key_derivation &derivation) override;
+ bool conceal_derivation(crypto::key_derivation &derivation, const crypto::public_key &tx_pub_key, const std::vector<crypto::public_key> &additional_tx_pub_keys, const crypto::key_derivation &main_derivation, const std::vector<crypto::key_derivation> &additional_derivations) override;
bool derivation_to_scalar(const crypto::key_derivation &derivation, const size_t output_index, crypto::ec_scalar &res) override;
bool derive_secret_key(const crypto::key_derivation &derivation, const std::size_t output_index, const crypto::secret_key &sec, crypto::secret_key &derived_sec) override;
bool derive_public_key(const crypto::key_derivation &derivation, const std::size_t output_index, const crypto::public_key &pub, crypto::public_key &derived_pub) override;
@@ -168,8 +182,6 @@ namespace hw {
bool open_tx(crypto::secret_key &tx_key) override;
- bool set_signature_mode(unsigned int sig_mode) override;
-
bool encrypt_payment_id(crypto::hash8 &payment_id, const crypto::public_key &public_key, const crypto::secret_key &secret_key) override;
bool ecdhEncode(rct::ecdhTuple & unmasked, const rct::key & sharedSec) override;
@@ -190,10 +202,9 @@ namespace hw {
};
-
#ifdef DEBUG_HWDEVICE
- extern crypto::secret_key viewkey;
- extern crypto::secret_key spendkey;
+ extern crypto::secret_key dbg_viewkey;
+ extern crypto::secret_key dbg_spendkey;
#endif
#endif //WITH_DEVICE_LEDGER