tmpim / Krist

Krist is a centralized-database economy system for Minecraft servers. Krist does not use a block-chain, or any similar technology. Krist is not a "cryptocurrency".
https://krist.dev/
GNU General Public License v3.0
24 stars 19 forks source link

Issue parsing Data through fields when trying to make a transaction #33

Closed Tyrasuki closed 7 years ago

Tyrasuki commented 7 years ago

so, i've been trying to make a transaction through computercraft, since im working on a shop, but whenever i try to pass my privatekey through the http.post, it just errors the following:

{"ok":false,"error":"missing_parameter","parameter":"privatekey"}

even tho i posted the key with the http.post

code used to send request:

pay = http.post("http://krist.ceriat.net/transactions?to=k5n6r931i1&privatekey=xxxxxxxx&amount="..payamm.."&metadata=test").readAll()
print(pay) -- checking for errors

if there is anything im doing wrong here please tell me, i've been looking over the internet for more than an hour.

Lemmmy commented 7 years ago
local pay = http.post("http://krist.ceriat.net/transactions", "to=k5n6r931i1&privatekey=xxxxxxxx&amount="..payamm.."&metadata=test").readAll()
print(pay) -- checking for errors

read the wiki next time.

Tyrasuki commented 7 years ago

lemmmy, does the privatekey have to be encoded or can it be just plain text?

Lemmmy commented 7 years ago

it will have to be encoded if it uses any non-ascii characters, or any of the following characters:

character codepoint (hex)
(space) 20
" 22
# 23
$ 24
% 25
& 26
+ 2B
, 2C
/ 2F
: 3A
; 3B
< 3C
= 3D
> 3E
? 3F
@ 40

in other words, yes. always url-encode all user input.

local pay = http.post("http://krist.ceriat.net/transactions", "to=k5n6r931i1&privatekey=" .. textutils.urlEncode(privatekey) .. "&amount="..payamm.."&metadata=test").readAll()
print(pay) -- checking for errors

please take further issues to the CC forums, and not my repository. this is a place for bug reports, not programming help.