Trezor Connection Status#
trezor_connection_statusAPI-v2 trezor_connection_status #
The trezor_connection_status method reports the real-time connection state of a Trezor hardware wallet that was previously initialized (see task::init_trezor::* ).
Request Parameters#
Parameter Type Required Description device_pubkey string
–
Expected public key of the Trezor device. If specified and a different device is connected, an error is returned.
Response Parameters#
Parameter Type Required Description status string
✓
One of: Connected, Disconnected, Busy.
📌 Example#
JSON Bash Python JavaScript PHP Go Ruby
Copy
{
"userpass" : "RPC_UserP@SSW0RD" ,
"mmrpc" : "2.0" ,
"method" : "trezor_connection_status" ,
"id" : 0
}
Copy
curl --url "http://127.0.0.1:7783" --data '{
"userpass": "RPC_UserP@SSW0RD",
"mmrpc": "2.0",
"method": "trezor_connection_status",
"id": 0
}'
Copy
import requests
import json
url = "http://127.0.0.1:7783"
payload = {
"userpass" : "RPC_UserP@SSW0RD" ,
"mmrpc" : "2.0" ,
"method" : "trezor_connection_status" ,
"id" : 0
}
response = requests.post(url, json = payload)
print (json.dumps(response.json(), indent = 2 ))
Copy
const payload = {
"userpass" : "RPC_UserP@SSW0RD" ,
"mmrpc" : "2.0" ,
"method" : "trezor_connection_status" ,
"id" : 0
};
const response = await fetch ( "http://127.0.0.1:7783" , {
method: "POST" ,
body: JSON . stringify (payload),
});
console. log ( await response. json ());
Copy
<? php
$payload = <<< ' JSON '
{
"userpass" : "RPC_UserP@SSW0RD" ,
"mmrpc" : "2.0" ,
"method" : "trezor_connection_status" ,
"id" : 0
}
JSON ;
$ch = curl_init ( "http://127.0.0.1:7783" );
curl_setopt ($ch, CURLOPT_POST , true );
curl_setopt ($ch, CURLOPT_POSTFIELDS , $payload);
curl_setopt ($ch, CURLOPT_RETURNTRANSFER , true );
curl_setopt ($ch, CURLOPT_HTTPHEADER , [ 'Content-Type: application/json' ]);
$response = curl_exec ($ch);
curl_close ($ch);
echo $response;
Copy
package main
import (
" bytes "
" fmt "
" io "
" net/http "
)
func main () {
payload := [] byte ( `{"userpass":"RPC_UserP@SSW0RD","mmrpc":"2.0","method":"trezor_connection_status","id":0}` )
resp, err := http. Post ( "http://127.0.0.1:7783" , "application/json" , bytes. NewBuffer (payload))
if err != nil {
panic (err)
}
defer resp.Body. Close ()
body, _ := io. ReadAll (resp.Body)
fmt. Println ( string (body))
}
Copy
require 'net/http'
require 'json'
require 'uri'
uri = URI ( "http://127.0.0.1:7783" )
payload = {
"userpass" : "RPC_UserP@SSW0RD" ,
"mmrpc" : "2.0" ,
"method" : "trezor_connection_status" ,
"id" : 0
}
response = Net :: HTTP . post (uri, payload. to_json , 'Content-Type' => 'application/json' )
puts JSON . pretty_generate ( JSON . parse (response. body ))
Show Trezor Connection Status Response {
"mmrpc" : "2.0" ,
"result" : {
"status" : "Connected"
},
"id" : 0
}
Error Types#
Parameter Type Required Description TrezorNotInitialized string
–
A Trezor device has not been initialized on this node. FoundUnexpectedDevice string
–
A connected device does not match the supplied device_pubkey. Internal string
–
Unhandled internal error.