Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
Z
zbNode
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
ken
zbNode
Commits
0644be84
Commit
0644be84
authored
May 09, 2018
by
ken
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
改key
parent
664e0558
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
30 additions
and
2 deletions
+30
-2
package.json
package.json
+1
-0
zb.js
zb.js
+29
-2
No files found.
package.json
View file @
0644be84
...
...
@@ -10,6 +10,7 @@
"author"
:
""
,
"license"
:
"
ISC
"
,
"dependencies"
:
{
"
ezcrypto
"
:
"0.0.3"
,
"
redis
"
:
"^2.8.0"
,
"
request
"
:
"^2.85.0"
,
"
ws
"
:
"^5.1.0"
...
...
zb.js
View file @
0644be84
const
stream
=
'wss://api.zb.com:9999/websocket'
;
const
WebSocket
=
require
(
'ws'
);
const
request
=
require
(
'request'
);
const
crypto
=
require
(
'
crypto'
)
;
const
crypto
=
require
(
'
ezcrypto'
).
Crypto
;
const
options
=
{};
const
observerSymbol
=
[
"btcusdt"
,
'ethusdt'
,
'ethbtc'
,
'eosbtc'
];
const
redis
=
require
(
'redis'
);
...
...
@@ -13,6 +13,27 @@ const APISECRET = "30577876-ddd0-4969-92f9-f6a1dfb85703";
const
lastEventTimeMap
=
{};
function
signParams2Str
(
params
)
{
// const accountReq = {accesskey: APIKEY,channel: accountInfoChannel,event: "addChannel", sign: "a5f785d4627ae21f4b4baf9c1baf1a60"};
let
paramsSort
=
sortDict
(
params
);
const
paramsSortString
=
JSON
.
stringify
(
paramsSort
);
let
digest
=
crypto
.
SHA1
(
APISECRET
);
let
sign
=
crypto
.
HMAC
(
crypto
.
MD5
,
paramsSortString
,
digest
);
paramsSort
[
'sign'
]
=
sign
;
return
JSON
.
stringify
(
paramsSort
);
}
function
sortDict
(
dict
)
{
let
dict2
=
{},
keys
=
Object
.
keys
(
dict
).
sort
();
for
(
let
key
of
keys
)
{
dict2
[
key
]
=
dict
[
key
]
}
return
dict2
}
const
_handleSocketError
=
function
(
error
)
{
// Errors ultimately result in a `close` event.
// see: https://github.com/websockets/ws/blob/828194044bf247af852b31c49e2800d557fedeff/lib/websocket.js#L126
...
...
@@ -29,7 +50,13 @@ const _handleSocketOpen = function(opened_callback) {
const
req
=
{
event
:
'addChannel'
,
channel
:
symbol
+
'_depth'
};
this
.
send
(
JSON
.
stringify
(
req
));
}
const
accountReq
=
{
accesskey
:
APIKEY
,
channel
:
accountInfoChannel
,
event
:
"addChannel"
,
sign
:
"9719e6907ee292b8eee9ec93c8db4145"
};
const
accountReq
=
{
accesskey
:
APIKEY
,
channel
:
accountInfoChannel
,
event
:
"addChannel"
,
};
const
sign
=
signParams2Str
(
accountReq
);
accountReq
.
sign
=
sign
;
console
.
log
(
JSON
.
stringify
(
accountReq
));
setInterval
(()
=>
{
this
.
send
(
JSON
.
stringify
(
accountReq
));
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment