public async Task <EthereumAppGetPublicKeyResponse> GetPublicKeyResponse(string path, bool getChainCode, bool showDisplay)
        {
            byte[] data = Helpers.GetDerivationPathData(path);

            EthereumAppGetPublicKeyResponse response = await SendRequestAsync <EthereumAppGetPublicKeyResponse, EthereumAppGetPublicKeyRequest>(new EthereumAppGetPublicKeyRequest(showDisplay, getChainCode, data));

            return(response.IsSuccess ? response : null);
        }
Beispiel #2
0
        public Task <TResponse> SendRequestAsync <TResponse, TRequest>(TRequest request)
            where TResponse : ResponseBase
            where TRequest : RequestBase
        {
            ResponseBase response = null;

            if (request is EthereumAppGetPublicKeyRequest e && e.Data.ToList().SequenceEqual(EthereumAppGetIncorrectPublicKeyRequestData))
            {
                //This is a case where the request is Ethereum and the Purpose is Segwit.
                //TODO: This should hinge on CurrentState, not Request type
                throw new Exception();
            }

            switch (request)
            {
            case BitcoinAppGetPublicKeyRequest bitcoinAppGetPublicKeyRequest:

                if (CurrentState == CurrentState.Dashboard)
                {
                    response = new BitcoinAppGetPublicKeyResponse(NoAppLoadedResponseData);
                }
                else if (bitcoinAppGetPublicKeyRequest.Ins == Constants.BTCHIP_INS_GET_WALLET_PUBLIC_KEY)
                {
                    response = new BitcoinAppGetPublicKeyResponse(BitcoinPublicKeyResponseData);
                }
                else
                {
                    //TODO: Make this a real bitcoin address length
                    response = new BitcoinAppGetPublicKeyResponse(BitcoinPublicKeyResponseData);
                }
                break;

            case EthereumAppGetPublicKeyRequest ethereumAppGetPublicKeyRequest:
                //TODO: Make this a real Ethereum address length
                response = new EthereumAppGetPublicKeyResponse(BitcoinPublicKeyResponseData);
                break;

            case TronAppSignatureRequest tronAppSignatureRequest:
                response = new TronAppSignatureResponse(TronTransactionResponseData);
                break;

            case TronAppGetPublicKeyRequest tronAppGetPublicKeyRequest:
                //TODO: Make this a real Tron address length
                response = new TronAppGetPublicKeyResponse(BitcoinPublicKeyResponseData);
                break;

            case GetCoinVersionRequest getCoinVersionRequest:
                response = new GetCoinVersionResponse(GetCoinVersionResponseData);
                break;

            case EthereumAppSignatureRequest tronAppSignatureRequest:
                response = new EthereumAppSignatureResponse(TronTransactionResponseData);
                break;

            default:
                throw new NotImplementedException();
            }



            return(Task.FromResult((TResponse)response));
        }