Listen=1 But Not change error
i write a simple programm with delphi to Raw Connect the RPC protocol (JSON-RPC)
First extract Real packet with Wireshark :
{"id": 1, "method": "mining.subscribe", "params": ["cpuminer/2.4.1"]}
{"id":1,"result":[[["mining.set_difficulty","b4b6693b72a50c7116db18d6497cac52"],["mining.notify","ae6812eb4cd7735a302a8a9dd95cf71f"]],"7c660042",4],"error":null}
{"id":null,"params":[1024],"method":"mining.set_difficulty"}
{"id": 2, "method": "mining.authorize", "params": ["Xuser", "Q12345678"]}
And So replace in raw requets
but give me error 500 or 401 Unauthorize
function SendJson(js:string):string;
var
Json: string;
sResponse: string;
JsonToSend: TStringStream;
begin
JSON := JS;
JsonToSend := TStringStream.Create(Utf8Encode(Json));
try
Form1.IDHTTP1.Request.ContentType := 'application/json';
Form1.IDHTTP1.Request.CharSet := 'utf-8';
Form1.IdHTTP1.Request.Username:='Xuser';
Form1.IdHTTP1.Request.Password:='Q123456789';
try
sResponse := Form1.IDHTTP1.Post('http://127.0.0.1:8332', JsonToSend);
except
on E: Exception do
ShowMessage('Error on request: '#13#10 + e.Message);
end;
finally
JsonToSend.Free;
end;
Result := sResponse;
end;
//---------------------------------
procedure TForm1.Button3Click(Sender: TObject);
begin
memo1.Lines.Add( SendJson('{"id": 2, "method": "mining.authorize", "params": ["Xuser", "Q123456789"]}'));
memo1.Lines.Add( SendJson('{"id": 1, "method": "mining.subscribe", "params": ["cpuminer/2.4.1"]}'));
memo1.Lines.Add( SendJson('{"jsonrpc": "1.0", "method": getinfo, "params": "[]" }'));
end;
my brain Fucked