Moin, hier mal eine kleine Datei, womit man das Wallet per RPC steuern kann:
- import requests
- import json
- user = "rpcuser"
- pw = "rpcpassword"
- port = "rpcport"
- method = "getblockcount"
- params = None
- url = "http://{}:{}@127.0.0.1:{}/".format(user, pw, port)
- jsonrpc = "2.0"
- payload = {"jsonrpc": jsonrpc, "method": method, "params": params}
- r = requests.post(url, data=json.dumps(payload)).json()
- print(r)
Hier im Beispiel würde die dem Wallet bekannte Blockhöhe abgefragt werden.
In Zeile 1 und 2 werden die Module "requests" und "json" importiert.
requests ist da, um in python http-Anfragen zu stellen.
Mit json kann man wunderbar zu json datein formatieren.
Danach werden die "Zugangsdaten" gesetzt. Hier trägt man die Daten ein, die man in der jumpcoin.conf vom Wallet hinterlegt hat. Diese sollten möglichst sicher gewählt sein, da damit das gesammte Wallet gesteuert werden kann.
Im Folgenden wird die gewünschte Methode angegeben. Wenn du nicht weißt welche Methoden es gibt, dann ist hier eine Liste:
addmultisigaddress <nrequired> <'["key","key"]'> [account]
addredeemscript <redeemScript> [account]
backupwallet <destination>
checkwallet
createrawtransaction [{"txid":txid,"vout":n},...] {address:amount,...}
decoderawtransaction <hex string>
decodescript <hex string>
dumpprivkey <jumpcoinaddress>
dumpwallet <filename>
encryptwallet <passphrase>
getaccount <jumpcoinaddress>
getaccountaddress <account>
getaddressesbyaccount <account>
getbalance [account] [minconf=1]
getbestblockhash
getblock <hash> [txinfo]
getblock <number> [txinfo]
getblockcount
getblockhash <index>
getblocktemplate [params]
getcheckpoint
getconnectioncount
getdifficulty
getinfo
getmininginfo
getnewaddress [account]
getnewpubkey [account]
getpeerinfo
getrawmempool
getrawtransaction <txid> [verbose=0]
getreceivedbyaccount <account> [minconf=1]
getreceivedbyaddress <jumpcoinaddress> [minconf=1]
getstakinginfo
getsubsidy [nTarget]
gettransaction <txid>
getwork [data]
getworkex [data, coinbase]
help [command]
importprivkey <jumpcoinprivkey> [label]
importwallet <filename>
keypoolrefill [new-size]
listaccounts [minconf=1]
listaddressgroupings
listreceivedbyaccount [minconf=1] [includeempty=false]
listreceivedbyaddress [minconf=1] [includeempty=false]
listsinceblock [blockhash] [target-confirmations]
listtransactions [account] [count=10] [from=0]
listunspent [minconf=1] [maxconf=9999999] ["address",...]
makekeypair [prefix]
move <fromaccount> <toaccount> <amount> [minconf=1] [comment]
repairwallet
resendtx
reservebalance [<reserve> [amount]]
sendalert <message> <privatekey> <minver> <maxver> <priority> <id> [cancelupto]
sendfrom <fromaccount> <tojumpcoinaddress> <amount> [minconf=1] [comment] [comment-to]
sendmany <fromaccount> {address:amount,...} [minconf=1] [comment]
sendrawtransaction <hex string>
sendtoaddress <jumpcoinaddress> <amount> [comment] [comment-to]
setaccount <jumpcoinaddress> <account>
settxfee <amount>
signmessage <jumpcoinaddress> <message>
signrawtransaction <hex string> [{"txid":txid,"vout":n,"scriptPubKey":hex},...] [<privatekey1>,...] [sighashtype="ALL"]
stop <detach>
submitblock <hex data> [optional-params-obj]
validateaddress <jumpcoinaddress>
validatepubkey <jumpcoinpubkey>
verifymessage <jumpcoinaddress> <signature> <message>
Im Beispielcode wird wie bereits erwähnt, die aktuelle dem Wallet bekannte Blockhöhe abgefragt.
Dies bedarf keiner Parameter, die weitere Informationen angeben. Andere Methoden benötigen allerdings Parametern, die genauere Anweisungen geben, die dann hier angegeben werden müssen.
Danach wird eine Variable mit den vorher gegebenen Werten erstellt, worin steht, wohin die Anfrage gehen soll. Geschweifte Klammern werden am Ende durch .format(x, y...) der Reihenfolge nach ausgefüllt.
Im Payload wird nun nochmal die Anfrage zusammengefasst.
Daraufhin wird eine sogenannte post-request - encodiert im json-Format - an das Wallet geschickt und die Antwort in der Variable r gespeichert.
Zum Schluss wird nun die Antwort des Wallets ausgegeben.
Dies sollte grundsätzlich in ziemlich allen Programmiersprachen möglich sein, in denen man http-requests versenden kann - mein Beispiel ist in Python.
Sollte es noch Fragen geben, gerne hier drunter stellen oder privat anschreiben!