Pages:
Author

Topic: [Nxt] API of Nxt - page 19. (Read 37336 times)

legendary
Activity: 2142
Merit: 1010
Newbie
December 08, 2013, 03:46:37 PM
#36
Is there already a way to retrieve the last block without knowing its id?

http://localhost:7874/nxt?requestType=getState

Look at "lastBlock" value.
legendary
Activity: 1540
Merit: 1002
December 08, 2013, 03:31:25 PM
#35
Is there already a way to retrieve the last block without knowing its id?
legendary
Activity: 2142
Merit: 1010
Newbie
December 08, 2013, 02:12:16 AM
#34
Is there a way to check if an account is unlocked?

No.


if I use wget to send the unlock request, how long will it stay unlocked?

Until u send "lock" request.
omo
full member
Activity: 147
Merit: 100
December 07, 2013, 10:34:38 PM
#33
How would I have an account unlocked automatically when Nxt starts (or soon after)?

I have Nxt running in a server and wish to unlock the account after reboot because I was told that the account needs to be unlocked to generate POS.

Thanks!

Try to use this dirty hack:

http://localhost:7875/?user=0.7657349163200706&request=unlockAccount&secretPhrase=MySecret

Value of "user" must be any random number. This is the way the client unlocks accounts. Ignore a response.

Is there a way to check if an account is unlocked?
if I use wget to send the unlock request, how long will it stay unlocked?
legendary
Activity: 1540
Merit: 1002
December 07, 2013, 02:00:08 PM
#32
API method request:

- create unsigned transaction, to be signed elsewhere (similar to sendmoney without passphrase and returning the raw unsigned transaction?)
- sign transaction, accepting a raw unsigned transaction, returning a raw signed transaction
- broadcast transactions, accepting a raw signed transaction
legendary
Activity: 1540
Merit: 1002
December 07, 2013, 01:31:42 PM
#31
API method request: a way to get a list of transactions pending inclusion in blocks (a la bitcoind getmemorypool).
legendary
Activity: 2142
Merit: 1010
Newbie
December 05, 2013, 03:08:24 PM
#30
But we have to be careful; sendMoney gives valid-looking txid even if the transaction was spitted out and not sent to the blockchain. Any way to fix that?

Use 5 minute deadline and resend a transaction if it's not confirmed. It's impossible to make sure that nodes didn't receive a transaction and if they r going to include it into a block.
hero member
Activity: 566
Merit: 500
December 05, 2013, 03:05:03 PM
#29
Very good!

But we have to be careful; sendMoney gives valid-looking txid even if the transaction was spitted out and not sent to the blockchain. Any way to fix that?

Happily the client does not show the spitted tx.

{"transaction":"10170673123314889622"}


The client has a malfunction in that it does not show all the sendMoney transactions until much later. It does show some. Additional hazard is that even the blockchain explorer does not show the properly sent & accepted transactions until later. This has the potential to cause some serious mess.
legendary
Activity: 2142
Merit: 1010
Newbie
December 05, 2013, 07:14:52 AM
#28
sendMoney API request enabled in 0.3.11.
legendary
Activity: 2142
Merit: 1010
Newbie
December 04, 2013, 05:33:56 PM
#27
Changes in API

URL changed from localhost:7876/?request=XXX to localhost:7874/nxt?requestType=XXX

API can be accessed via HTTPS if port 7875 used.

Added http://localhost:7874/nxt?requestType=getMyInfo request, "host" can be used to set "allowedBotHosts" parameter in web.xml
legendary
Activity: 2142
Merit: 1010
Newbie
December 04, 2013, 05:04:38 PM
#26
What are we doing wrong with the API?

http://111.111.111.111:7876/?request=sendMoney&secretPhrase=masked&recipient=12345678901234567890&amount=12&fee=1&deadline=900

Result is:

{"errorCode":1,"errorDescription":"Incorrect request"}

Disabled coz I was rewriting networking part. A new version will be released in an hour. Some minor changes in API.

Edit: sendMoney and broadcastTransaction will be disabled though, we need more testing on this requests. A version that supports them is planned to be released within 24 hours.
hero member
Activity: 566
Merit: 500
December 04, 2013, 04:56:48 PM
#25
What are we doing wrong with the API?

http://111.111.111.111:7876/?request=sendMoney&secretPhrase=masked&recipient=12345678901234567890&amount=12&fee=1&deadline=900

Result is:

{"errorCode":1,"errorDescription":"Incorrect request"}
legendary
Activity: 2142
Merit: 1010
Newbie
November 30, 2013, 10:57:53 AM
#24
I have just noticed that getBlock request returns "previousBlock". No longer required to scan the blockchain from Genesis block, descending approach should work better!
legendary
Activity: 2142
Merit: 1010
Newbie
November 30, 2013, 05:31:25 AM
#23
List of error codes:

1 - Incorrect request
2 - Blockchain not up to date
3 - Parameter not specified
4 - Incorrect parameter
5 - Unknown object (block, transaction, etc.)
6 - Not enough funds

This is complete list for version <= 0.2.17
legendary
Activity: 2142
Merit: 1010
Newbie
November 28, 2013, 03:45:44 PM
#22
If we wanted to walk through the blocks, what is the genesis block for Nxt?

2680262203532249785
full member
Activity: 140
Merit: 100
November 28, 2013, 03:33:08 PM
#21
If we wanted to walk through the blocks, what is the genesis block for Nxt?
legendary
Activity: 2142
Merit: 1010
Newbie
November 28, 2013, 12:37:37 PM
#20
This approach is useful if u don't want to force 2-factor authorization.
That's nearly ingenious! "1.5-factor" authorization built in, takes a while to sink in for the old dog. So I gather the token can be used as OTP.

If only the transaction numbers were used in the web client for consumers to refer to, transition to these new ways of payment authentication would be less painful...

Aye, I like it too. I'm so tired doing registration/authorization for each project. Or adding authorization via Facebook, Twitter, Google, so on and so forth...
hero member
Activity: 566
Merit: 500
November 28, 2013, 12:32:04 PM
#19
This approach is useful if u don't want to force 2-factor authorization.
That's nearly ingenious! "1.5-factor" authorization built in, takes a while to sink in for the old dog. So I gather the token can be used as OTP.

If only the transaction numbers were used in the web client for consumers to refer to, transition to these new ways of payment authentication would be less painful...
legendary
Activity: 2142
Merit: 1010
Newbie
November 28, 2013, 12:14:40 PM
#18
Could you describe the usage of Decode token request please? I can't get my head over the web site authorization system supported by Nxt.

Also, it would be practically necessary to get transaction identifiers for own transactions to be displayed in the wallet client to be able to refer to them while conducting exchanges of value. They have little use in the API otherwise.

1. User visits ur site and sees that SSL certificate is issued to "domain.com"
2. He unlocks his account
3. Then he clicks purple key icon next to his account id
4. Into "Website" field he enters "domain.com" and clicks [Generate authorization token]
5. He gets a long string like "quj6mp8oj4er2b46guvi1viqtg2utrb1nivijah8rocrq7nj0m71sseupk39em80vp0j18i1cbt59qi vpke50klg6p4enedlf312jpsa7itg37ldul09lnqfd3ss6a5780u5ahhv5iv30vfpqnpjmc8klib2e9 i9"
6. Then he copies it and pastes into a special field on ur site
7. U get this string (token) and do request http://88.198.210.245:7876/?request=decodeToken&website=domain.com&token=quj6mp8oj4er2b46guvi1viqtg2utrb1nivijah8rocrq7nj0m71sseupk39em80vp0j18i1cbt59qivpke50klg6p4enedlf312jpsa7itg37ldul09lnqfd3ss6a5780u5ahhv5iv30vfpqnpjmc8klib2e9i9
8. Response should look like
Code:
{"timestamp":364062,"valid":true,"account":"3791936988034107349"}

Now u know that this is the legit owner of account 3791936988034107349. U scan the blockchain to get all transactions from 3791936988034107349 to ur account (even sent in advance) to know how much he deposited. U already now how much he withdrew, so u know his balance in ur service.

This approach is useful if u don't want to force 2-factor authorization. All that u need is to let to withdraw funds to 3791936988034107349 only.

Pay attention that "domain.com" must be entered coz it protects the user. If he didn't enter some text that is associated with ur service then u could use his token to authorize urself on some other service like u were him.

Also u can take into account "timestamp" field and reject all attempts to login with very old timestamp.
hero member
Activity: 566
Merit: 500
November 28, 2013, 12:00:54 PM
#17
Could you describe the usage of Decode token request please? I can't get my head over the web site authorization system supported by Nxt.

Also, it would be practically necessary to get transaction identifiers for own transactions to be displayed in the wallet client to be able to refer to them while conducting exchanges of value. They have little use in the API otherwise.
Pages:
Jump to: