Guest User

Untitled

a guest
Aug 1st, 2018
156
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.05 KB | None | 0 0
  1. rpcuser=bitcoinrpc
  2. rpcpassword=somePassword
  3. server=1
  4. rest=1
  5. daemon=1
  6.  
  7. let url = URL(string: "http://bitcoinrpc:somePassword@192.168.1.8:8333")
  8. var request = URLRequest(url: url!)
  9. request.setValue("application/x-www-form-urlencoded", forHTTPHeaderField: "Content-Type")
  10. request.httpMethod = "GET"
  11. request.httpBody = "{"jsonrpc":"1.0","id":"curltext","method":"getinfo","params":[]}".data(using: .utf8)
  12.  
  13. let task = URLSession.shared.dataTask(with: request) { (data, response, error) -> Void in
  14.  
  15. do {
  16.  
  17. if error != nil {
  18.  
  19. print(error)
  20.  
  21. } else {
  22.  
  23. if let urlContent = data {
  24.  
  25. do {
  26.  
  27. let jsonAddressResult = try JSONSerialization.jsonObject(with: urlContent, options: JSONSerialization.ReadingOptions.mutableLeaves) as! NSDictionary
  28.  
  29. print("jsonAddressResult = (jsonAddressResult)")
  30.  
  31. } catch {
  32.  
  33.  
  34. }
  35. }
  36. }
  37. }
  38. }
  39.  
  40. task.resume()
  41.  
  42. }
  43.  
  44. 2018-08-02 12:04:53.659293+0800 BitSense[5596:568091] Task <47A80E16-F0FE-4508-9C5D-3EFDD82B55FB>.<1> HTTP load failed (error code: -1005 [4:-4])
  45. 2018-08-02 12:04:53.660223+0800 BitSense[5596:568092] Task <47A80E16-F0FE-4508-9C5D-3EFDD82B55FB>.<1> finished with error - code: -1005
  46. Optional(Error Domain=NSURLErrorDomain Code=-1005 "The network connection was lost." UserInfo={NSUnderlyingError=0x600000244650 {Error Domain=kCFErrorDomainCFNetwork Code=-1005 "(null)" UserInfo={NSErrorPeerAddressKey=<CFData 0x600000280460 [0x107f6ac80]>{length = 16, capacity = 16, bytes = 0x1002208dc0a801080000000000000000}, _kCFStreamErrorCodeKey=-4, _kCFStreamErrorDomainKey=4}}, NSErrorFailingURLStringKey=http://bitcoinrpc:5bKc4zYHX6qvB9HjKK89Ms2h@192.168.1.8:8333/, NSErrorFailingURLKey=http://bitcoinrpc:5bKc4zYHX6qvB9HjKK89Ms2h@192.168.1.8:8333/, _kCFStreamErrorDomainKey=4, _kCFStreamErrorCodeKey=-4, NSLocalizedDescription=The network connection was lost.})enter preformatted text here
Add Comment
Please, Sign In to add comment