private static async Task SendSubscriptionRequestsAuthenticated(CoinbaseWebsocketClient client) { //create an authenticator with your apiKey, apiSecret and passphrase var authenticator = new CoinbaseAuthentication(API_KEY, API_SECRET, API_PASSPHRASE); var subscription = new SubscribeRequest( new[] { "BTC-EUR", "BTC-USD" }, new[] { ChannelSubscriptionType.Heartbeat, ChannelSubscriptionType.Ticker, ChannelSubscriptionType.Matches, ChannelSubscriptionType.Heartbeat, ChannelSubscriptionType.User, ChannelSubscriptionType.Level2, //ChannelSubscriptionType.Status }, authenticator); client.Send(subscription); }
public void CreateSignature_ShouldReturnCorrectString() { var nonce = CoinbaseAuthentication.CreateAuthNonce(123456); var payload = CoinbaseAuthentication.CreateAuthPayload(nonce); var signature = CoinbaseAuthentication.CreateSignature(payload, "api_secret"); Assert.Equal("f6bea0776d7db5b8f74bc930f5b8d6901376874cfc433cf4b68b688d78238e74", signature); }
/// Stream wallet snapshot manually /// </summary> /// <param name="communicator"></param> /// <param name="apiKey"></param> /// <param name="apiSecret"></param> /// <param name="passphrase"></param> /// <returns></returns> public static async Task StreamWalletsSnapshot(ICoinbaseCommunicator communicator, string apiKey, string apiSecret, string passphrase) { var authentication = new CoinbaseAuthentication(apiKey, apiSecret, passphrase); var request = await CoinbaseHttpClient.SendHttpRequest(authentication, apiKey, apiSecret, passphrase, "/accounts"); var wallets = WalletResponse.FromJson(request); var snapshot = new WalletsSnapshotResponse(); snapshot.Wallets = wallets; snapshot.Type = ChannelType.WalletsSnapshot; var serialized = JsonConvert.SerializeObject(snapshot, CoinbaseJsonSerializer.Settings); communicator.StreamFakeMessage(ResponseMessage.TextMessage(serialized)); }