77 "encoding/json"
88 "fmt"
99 "github.com/blocktree/openwallet/v2/common"
10- "github.com/blocktree/openwallet/v2/crypto"
1110 "github.com/blocktree/openwallet/v2/hdkeystore"
1211 "github.com/blocktree/openwallet/v2/log"
1312 "github.com/blocktree/openwallet/v2/openwallet"
@@ -264,22 +263,12 @@ func (api *APINode) GetSymbolList(symbol string, offset, limit, hasRole int, syn
264263 "hasRole" : hasRole ,
265264 }
266265
267- return api .node .Call (HostNodeID , "getSymbolList" , params , sync , func (resp owtp.Response ) {
268- data := resp .JsonData ()
269- symbols := make ([]* Symbol , 0 )
270- symbolArray := data .Get ("symbols" )
271- total := data .Get ("total" ).Int ()
272- if symbolArray .IsArray () {
273- for _ , s := range symbolArray .Array () {
274- var sym Symbol
275- err := json .Unmarshal ([]byte (s .Raw ), & sym )
276- if err == nil {
277- symbols = append (symbols , & sym )
278- }
279- }
266+ return api .node .Call (HostNodeID , "getSymbolBlockList" , params , sync , func (resp owtp.Response ) {
267+ var result []* Symbol
268+ if err := json .Unmarshal ([]byte (resp .JsonData ().Raw ), & result ); err != nil {
269+ log .Error ("json unmarshal failed: " , err )
280270 }
281-
282- reqFunc (resp .Status , resp .Msg , int (total ), symbols )
271+ reqFunc (resp .Status , resp .Msg , 0 , nil )
283272 })
284273}
285274
@@ -1102,30 +1091,6 @@ func (api *APINode) ImportAccount(
11021091 })
11031092}
11041093
1105- // BindDevice 绑定设备ID
1106- func (api * APINode ) BindDevice (
1107- deviceID string ,
1108- sync bool ,
1109- reqFunc func (status uint64 , msg string )) error {
1110- if api == nil {
1111- return fmt .Errorf ("APINode is not inited" )
1112- }
1113- appID := api .config .AppID
1114- appKey := api .config .AppKey
1115- accessTime := time .Now ().UnixNano () / 1e6
1116- t := strconv .FormatInt (accessTime , 10 )
1117- sigStr := appID + "." + deviceID + "." + t + "." + appKey
1118- params := map [string ]interface {}{
1119- "appID" : appID ,
1120- "deviceID" : deviceID ,
1121- "accessTime" : accessTime ,
1122- "sign" : crypto .GetMD5 (sigStr ),
1123- }
1124- return api .node .Call (HostNodeID , "bindAppDevice" , params , sync , func (resp owtp.Response ) {
1125- reqFunc (resp .Status , resp .Msg )
1126- })
1127- }
1128-
11291094// ImportBatchAddress 批量导入地址
11301095func (api * APINode ) ImportBatchAddress (
11311096 walletID , accountID , memo string ,
@@ -1183,11 +1148,13 @@ func (api *APINode) GetNotifierNodeInfo() (string, string, error) {
11831148 )
11841149 appID := api .config .AppID
11851150 time := time .Now ().UnixNano ()
1186- plainText := fmt .Sprintf ("%s%d%s" , appID , time , api .config .AppKey )
1187- sign := crypto .GetMD5 (plainText )
1151+ nonce := RandNonce ()
1152+ plainText := fmt .Sprintf ("%s%s%d" , appID , nonce , time )
1153+ sign := HmacSHA256 ([]byte (plainText ), []byte (api .config .AppKey ))
11881154
11891155 params := map [string ]interface {}{
11901156 "appID" : appID ,
1157+ "nonce" : nonce ,
11911158 "time" : time ,
11921159 "sign" : sign ,
11931160 }
@@ -1201,7 +1168,7 @@ func (api *APINode) GetNotifierNodeInfo() (string, string, error) {
12011168
12021169 data := resp .JsonData ()
12031170 pubKey = data .Get ("pubKey" ).String ()
1204- nodeId = data .Get ("nodeId " ).String ()
1171+ nodeId = data .Get ("nodeID " ).String ()
12051172 })
12061173 if err != nil {
12071174 return "" , "" , err
0 commit comments