Check if a username exists, return the registered address if so
(s string, h int64)
| 1381 | |
| 1382 | // Check if a username exists, return the registered address if so |
| 1383 | func checkUsername(s string, h int64) (address string, err error) { |
| 1384 | if session.Offline { |
| 1385 | return |
| 1386 | } |
| 1387 | |
| 1388 | if h < 0 { |
| 1389 | address, err = engram.Disk.NameToAddress(s) |
| 1390 | } else { |
| 1391 | var params rpc.NameToAddress_Params |
| 1392 | var response *jrpc2.Response |
| 1393 | var result rpc.NameToAddress_Result |
| 1394 | |
| 1395 | rpc_client.WS, _, err = websocket.DefaultDialer.Dial("ws://"+session.Daemon+"/ws", nil) |
| 1396 | if err != nil { |
| 1397 | return |
| 1398 | } |
| 1399 | |
| 1400 | input_output := rwc.New(rpc_client.WS) |
| 1401 | rpc_client.RPC = jrpc2.NewClient(channel.RawJSON(input_output, input_output), nil) |
| 1402 | |
| 1403 | if rpc_client.RPC != nil { |
| 1404 | params.Name = s |
| 1405 | params.TopoHeight = h |
| 1406 | |
| 1407 | address = "" |
| 1408 | response, err = rpc_client.RPC.Call(context.Background(), "DERO.NameToAddress", params) |
| 1409 | |
| 1410 | rpc_client.WS.Close() |
| 1411 | rpc_client.RPC.Close() |
| 1412 | |
| 1413 | if err != nil { |
| 1414 | return |
| 1415 | } |
| 1416 | |
| 1417 | err = response.UnmarshalResult(&result) |
| 1418 | if err != nil { |
| 1419 | return |
| 1420 | } |
| 1421 | |
| 1422 | if result.Status != "OK" { |
| 1423 | err = errors.New("username does not exist") |
| 1424 | return |
| 1425 | } |
| 1426 | |
| 1427 | address = result.Address |
| 1428 | } |
| 1429 | } |
| 1430 | |
| 1431 | return |
| 1432 | } |
| 1433 | |
| 1434 | // Get the transaction fees to be paid |
| 1435 | func getGasEstimate(gp rpc.GasEstimate_Params) (gas uint64, err error) { |
no outgoing calls
no test coverage detected