/** * @param identity The identity to be signed */ public void beginSignIdentityUseCase(Identity identity) { log.debug("Begin 'sign identity' use case"); // Clear relevant information resetAllButFeatures(); // Track the use case currentUseCase = ContextUseCase.SIGN_IDENTITY; // Store the overall context parameters this.identity = Optional.of(identity); // Set the event receiving state currentState = HardwareWalletStates.newConfirmSignIdentityState(); // Issue starting message to elicit the event client.signIdentity(identity); }
/** * <p>Reset the context back to the initialised state (standard awaiting state with features)</p> */ public void resetToInitialised() { log.debug("Reset to 'initialised'"); // Clear relevant information resetAllButFeatures(); // Perform the state change currentState = HardwareWalletStates.newInitialisedState(); // Fire the high level event HardwareWalletEvents.fireHardwareWalletEvent(HardwareWalletEventType.SHOW_DEVICE_READY, features.get(), client.name()); }
/** * <p>Begin the "get deterministic hierarchy" use case</p> * * @param childNumbers The child numbers describing the required chain from the master node including hardening bits */ public void beginGetDeterministicHierarchyUseCase(List<ChildNumber> childNumbers) { log.debug("Begin 'get deterministic hierarchy' use case"); // Clear relevant information resetAllButFeatures(); // Track the use case currentUseCase = ContextUseCase.REQUEST_DETERMINISTIC_HIERARCHY; // Store the overall context parameters this.childNumbers = Optional.of(childNumbers); // Set the event receiving state currentState = HardwareWalletStates.newConfirmGetDeterministicHierarchyState(); // Issue starting message to elicit the event // In this case we start with the master node (empty list) to enable building up a complete // hierarchy in case of hardened child numbers that require private keys to create client.getDeterministicHierarchy(Lists.<ChildNumber>newArrayList()); }
/** * <p>Begin the "wipe device" use case</p> */ public void beginWipeDeviceUseCase() { log.debug("Begin 'wipe device' use case"); // Clear relevant information resetAllButFeatures(); // Track the use case currentUseCase = ContextUseCase.WIPE_DEVICE; // Set the event receiving state currentState = HardwareWalletStates.newConfirmWipeState(); // Issue starting message to elicit the event client.wipeDevice(); }
/** * <p>Begin the "load wallet" use case</p> * * @param specification The specification describing the use of PIN, seed strength etc */ public void beginLoadWallet(LoadWalletSpecification specification) { log.debug("Begin 'load wallet' use case"); // Clear relevant information resetAllButFeatures(); // Track the use case currentUseCase = ContextUseCase.LOAD_WALLET; // Store the overall context parameters this.loadWalletSpecification = Optional.fromNullable(specification); // Set the event receiving state currentState = HardwareWalletStates.newConfirmWipeState(); // Issue starting message to elicit the event client.wipeDevice(); }
/** * <p>Begin the "create wallet on device" use case</p> * * @param specification The specification describing the use of PIN, seed strength etc */ public void beginCreateWallet(CreateWalletSpecification specification) { log.debug("Begin 'create wallet on device' use case"); // Clear relevant information resetAllButFeatures(); // Track the use case currentUseCase = ContextUseCase.CREATE_WALLET; // Store the overall context parameters this.createWalletSpecification = Optional.fromNullable(specification); // Set the event receiving state currentState = HardwareWalletStates.newConfirmWipeState(); // Issue starting message to elicit the event client.wipeDevice(); }
/** * <p>Change or remove the device PIN.</p> * * @param remove True if an existing PIN should be removed */ public void beginChangePIN(boolean remove) { log.debug("Begin 'change PIN' use case"); // Clear relevant information resetAllButFeatures(); // Track the use case currentUseCase = ContextUseCase.CHANGE_PIN; // Store the overall context parameters // Set the event receiving state currentState = HardwareWalletStates.newConfirmChangePINState(); // Issue starting message to elicit the event client.changePIN(remove); }
/** * <p>Reset the context back to a failed state (retain device information but prevent further communication)</p> */ public void resetToFailed() { log.debug("Reset to 'failed'"); // Clear relevant information resetAllButFeatures(); // Perform the state change currentState = HardwareWalletStates.newFailedState(); // Fire the high level event HardwareWalletEvents.fireHardwareWalletEvent(HardwareWalletEventType.SHOW_DEVICE_FAILED, client.name()); }
/** * <p>Begin the "sign transaction" use case</p> * * @param transaction The transaction containing the inputs and outputs * @param receivingAddressPathMap The map of paths for our receiving addresses * @param changeAddressPathMap The map paths for our change address */ public void beginSignTxUseCase( Transaction transaction, Map<Integer, ImmutableList<ChildNumber>> receivingAddressPathMap, Map<Address, ImmutableList<ChildNumber>> changeAddressPathMap) { log.debug("Begin 'sign transaction' use case"); // Clear relevant information resetAllButFeatures(); // Track the use case currentUseCase = ContextUseCase.SIGN_TX; // Store the overall context parameters this.transaction = Optional.of(transaction); this.receivingAddressPathMap = receivingAddressPathMap; this.changeAddressPathMap = changeAddressPathMap; // Set the event receiving state currentState = HardwareWalletStates.newConfirmSignTxState(); // Issue starting message to elicit the event client.signTx(transaction); }
/** * <p>Begin the "get public key" use case</p> * * @param account The plain account number (0 gives maximum compatibility) * @param keyPurpose The key purpose (RECEIVE_FUNDS,CHANGE,REFUND,AUTHENTICATION etc) * @param index The plain index of the required address */ public void beginGetPublicKeyUseCase(int account, KeyChain.KeyPurpose keyPurpose, int index) { log.debug("Begin 'get public key' use case"); // Clear relevant information resetAllButFeatures(); // Track the use case currentUseCase = ContextUseCase.REQUEST_PUBLIC_KEY; // Store the overall context parameters // Set the event receiving state currentState = HardwareWalletStates.newConfirmGetPublicKeyState(); // Issue starting message to elicit the event client.getPublicKey( account, keyPurpose, index ); }
/** * <p>Begin the "get public key" use case</p> * * @param identityUri The identity URI (e.g. "https://user@multibit.org/trezor-connect") * @param index The index of the identity to use (default is zero) to allow for multiple identities on same path * @param ecdsaCurveName The ECDSA curve name to use for TLS (e.g. "nist256p1") leave null to use default * @param showDisplay True if the result should only be given on the device display */ public void beginGetPublicKeyForIdentityUseCase(URI identityUri, int index, String ecdsaCurveName, boolean showDisplay) { log.debug("Begin 'get public key for identity' use case"); // Clear relevant information resetAllButFeatures(); // Track the use case currentUseCase = ContextUseCase.REQUEST_PUBLIC_KEY_FOR_IDENTITY; // Store the overall context parameters // Set the event receiving state currentState = HardwareWalletStates.newConfirmGetPublicKeyForIdentityState(); // Issue starting message to elicit the event client.getPublicKeyForIdentity( identityUri, index, ecdsaCurveName, showDisplay ); }
/** * <p>Begin the "get address" use case</p> * * @param account The plain account number (0 gives maximum compatibility) * @param keyPurpose The key purpose (RECEIVE_FUNDS,CHANGE,REFUND,AUTHENTICATION etc) * @param index The plain index of the required address * @param showDisplay True if the device should display the same address to allow the user to verify no tampering has occurred (recommended). */ public void beginGetAddressUseCase(int account, KeyChain.KeyPurpose keyPurpose, int index, boolean showDisplay) { log.debug("Begin 'get address' use case"); // Clear relevant information resetAllButFeatures(); // Track the use case currentUseCase = ContextUseCase.REQUEST_ADDRESS; // Store the overall context parameters // Set the event receiving state currentState = HardwareWalletStates.newConfirmGetAddressState(); // Issue starting message to elicit the event client.getAddress( account, keyPurpose, index, showDisplay ); }
/** * <p>Begin the "sign message key use case</p> * * @param account The plain account number (0 gives maximum compatibility) * @param keyPurpose The key purpose (RECEIVE_FUNDS,CHANGE,REFUND,AUTHENTICATION etc) * @param index The plain index of the required address * @param message The message for signing */ public void beginSignMessageUseCase( int account, KeyChain.KeyPurpose keyPurpose, int index, byte[] message ) { log.debug("Begin 'sign message' use case"); // Clear relevant information resetAllButFeatures(); // Track the use case currentUseCase = ContextUseCase.SIGN_MESSAGE; // Store the overall context parameters // Set the event receiving state currentState = HardwareWalletStates.newConfirmSignMessageState(); // Issue starting message to elicit the event client.signMessage( account, keyPurpose, index, message ); }
/** * <p>Reset the context into a stopped state (the service will have to be stopped and a new one started)</p> */ public void resetToStopped() { log.debug("Reset to 'stopped'"); // Clear relevant information resetAllButFeatures(); // Issue a hard detach - we are done client.hardDetach(); // Unsubscribe from events MessageEvents.unsubscribe(this); // Perform the state change currentState = HardwareWalletStates.newStoppedState(); // Fire the high level event HardwareWalletEvents.fireHardwareWalletEvent(HardwareWalletEventType.SHOW_DEVICE_STOPPED, client.name()); }