Bitcoin Forum

Alternate cryptocurrencies => Altcoin Discussion => Topic started by: BCNext on October 17, 2013, 08:22:35 PM



Title: [Nxt] API of Nxt
Post by: BCNext on October 17, 2013, 08:22:35 PM
This thread is dedicated to discussion of Nxt API.  Information about Nxt can be found at https://bitcointalk.org/index.php?topic=303898.0


Requests to Nxt software are done using HTTP GET requests.  Parameters are passed as HTTP parameters.  Responses are returned as JSON objects.  If something goes wrong a response will look {"errorCode": 6, "errorDescription": "Blah-blah-blah"}.

The list of all requests is below, I will update it each time I add new ones.


Decode token
Decodes an authorization token.

Request:
http://localhost:7876/? request=decodeToken & website=www.domain.com & token=StringOf160Chars

Response:
{ "account": "398532577100249608", "timestamp": 622, "valid": true }

Note:
This approach should be used to authorize users on web sites.


Get balance
Retrieves the balance of an account.

Request:
http://localhost:7876/? request=getBalance & account=398532577100249608

Response:
{ "balance": 5000, "unconfirmedBalance": 4200 }

Note:
"unconfirmedBalance" is the balance minus all unconfirmed sent transactions.  It doesn't include double-spending and unconfirmed received transactions.  A user sees the unconfirmed balance in the client.


Get block
Retrieves block data.

Request:
http://localhost:7876/? request=getBlock & block=12726165958299924733

Response:
{ "height": 16, "generator": "398532577100249608", "timestamp": 504, "numberOfTransactions": 149, "totalAmount": 17400, "totalFee": 24, "version": 1, "baseTarget": "54029906605928", "previousBlock": "3483738553242041290", "nextBlock": "9200836476619146595", "payloadHash": "32BytesRepresentedInHexadecimalForm", "generationSignature": "64BytesRepresentedInHexadecimalForm", "blockSignature": "64BytesRepresentedInHexadecimalForm", "transactions": ["2590525739676698091", "5436057910978689871", "8815617645011985536", ...] }

Note:
"generator" is the account that generated the block.
Payload length = "numberOfTransactions" * 128 B.
"previousBlock" absents for the genesis block.
"nextBlock" absents for the last block in the blockchain.
"transactions" is an array of transaction ids.


Get time
Retrieves current time.

Request:
http://localhost:7876/? request=getTime

Response:
{ "time": 417 }

Note:
"time" is measured in seconds since the genesis block timestamp.


Get transaction
Retrieves transaction data.

Request:
http://localhost:7876/? request=getTransaction & transaction=16244659048134841060

Response:
{ "block": "12726165958299924733", "timestamp": 417, "deadline": 900, "sender": "6330031667105067575",  "recipient": "398532577100249608", "amount": 1500, "fee": 5, "confirmations": 2, "signature": "64BytesRepresentedInHexadecimalForm" }

Note:
Data of an unconfirmed transaction doesn't contain "block" and "confirmations" parameters.  Double-spending transactions are not retrieved.


Send money
Sends money.

Request:
http://localhost:7876/? request=sendMoney & secretPhrase=IWontTellYou & recipient=398532577100249608 & amount=1500 & fee=5 & deadline=900 & referencedTransaction=13689168149259791567

Response:
{ "transaction": "16244659048134841060" }

Note:
"deadline" is specified in minutes.
"referencedTransaction" can be omitted.


Title: Re: [Nxt] API of Nxt
Post by: Hazard on October 17, 2013, 09:22:02 PM
Yawn


Title: Re: [Nxt] API of Nxt
Post by: Come-from-Beyond on October 18, 2013, 09:34:54 AM
Sub


Title: Re: [Nxt] API of Nxt
Post by: xchrix on October 18, 2013, 05:30:43 PM
i dont think sending keys as GET param is a good idea! someone who is logging the traffic can easily sniff every message


Title: Re: [Nxt] API of Nxt
Post by: BCNext on October 18, 2013, 05:41:40 PM
API bot shouldn't connect to a remote server.  You can tunnel it through TLS if you wish.


Title: Re: [Nxt] API of Nxt
Post by: Come-from-Beyond on October 19, 2013, 02:07:20 PM
Could u create anything that lets to get new transactions to an account, plz?


Title: Re: [Nxt] API of Nxt
Post by: MessyCoin on November 28, 2013, 06:52:23 AM
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!


Title: Re: [Nxt] API of Nxt
Post by: Come-from-Beyond on November 28, 2013, 08:10:45 AM
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.


Title: Re: [Nxt] API of Nxt
Post by: MessyCoin on November 28, 2013, 08:44:15 AM
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.

Thank you. Any way of doing this without visiting a browser? Nxt is running on a headless linux server and configured to start when server reboots. I want it to be generating POS without having to do anything other than boot it up. Perhaps I can use wget or something to ping the url you've suggested after Nxt is started. Just not sure if that is sufficient.


Title: Re: [Nxt] API of Nxt
Post by: Come-from-Beyond on November 28, 2013, 08:46:11 AM
Thank you. Any way of doing this without visiting a browser? Nxt is running on a headless linux server and configured to start when server reboots. I want it to be generating POS without having to do anything other than boot it up. Perhaps I can use wget or something to ping the url you've suggested after Nxt is started. Just not sure if that is sufficient.

U don't need browser, use wget and ping each minute.

Btw, it's better to use the same "user" value each time, so client won't create a new user session.


Title: Re: [Nxt] API of Nxt
Post by: MessyCoin on November 28, 2013, 09:16:13 AM
Thank you. Any way of doing this without visiting a browser? Nxt is running on a headless linux server and configured to start when server reboots. I want it to be generating POS without having to do anything other than boot it up. Perhaps I can use wget or something to ping the url you've suggested after Nxt is started. Just not sure if that is sufficient.

U don't need browser, use wget and ping each minute.

Btw, it's better to use the same "user" value each time, so client won't create a new user session.

Code:
>wget -t 1 http://localhost:7875/?user=0.468539437886&request=unlockAccoun&secretPhrase=<secret>
Connecting to localhost (localhost)|127.0.0.1|:7875... connected.
HTTP request sent, awaiting response... No data received.

This is the response I get from doing my wget command from the console. Seems to give no response at all. Does that seem right?

I've used crontab to do this same command each minute. Added -t 1 to wget so it does not keep retrying.

Even if all is correct then I guess it will take some time to see if it's generating POS, or is there some way I can find out?

Thanks once again.


Title: Re: [Nxt] API of Nxt
Post by: Come-from-Beyond on November 28, 2013, 09:21:17 AM
This is the response I get from doing my wget command from the console. Seems to give no response at all. Does that seem right?

I've used crontab to do this same command each minute. Added -t 1 to wget so it does not keep retrying.

Even if all is correct then I guess it will take some time to see if it's generating POS, or is there some way I can find out?

Thanks once again.

This is right, client talks to webbrowser with Long-polling style. Next request using the same connection would return a response for the previous one.

It begins generating blocks right after u unlock an account.


Title: Re: [Nxt] API of Nxt
Post by: Come-from-Beyond on November 28, 2013, 10:31:46 AM
After running my Nxt Slot Machine (https://bitcointalk.org/index.php?topic=346189.0) script for a while I figured out a safe way to send transactions via API.

When u send a transaction it's processed only if received back from one of the peers. But if u didn't receive it from a peer this does not mean that it won't be included into a block, maybe ur peer just failed to send it back to u.

So the safe way (without a risk to send it twice) is:

1. Send a transaction with a short deadline (10 minutes)
2. In 12 minutes check it's not included into a block and repeat step 1 again if necessary (u will generate a different transaction with the same recipient and amount but not the same timestamp and id)
3. In 720 blocks make sure that the transaction is still in the blockchain (720 blocks is maximum blockchain reorg depth)


Title: Re: [Nxt] API of Nxt
Post by: GCInc. on November 28, 2013, 11:43:53 AM
3. In 720 blocks make sure that the transaction is still in the blockchain (720 blocks is maximum blockchain reorg depth)
So... is it not safe to accept payment before 720 blocks?

What effect does the deadline time have on the payment?


Title: Re: [Nxt] API of Nxt
Post by: Come-from-Beyond on November 28, 2013, 11:49:57 AM
3. In 720 blocks make sure that the transaction is still in the blockchain (720 blocks is maximum blockchain reorg depth)
So... is it not safe to accept payment before 720 blocks?

What effect does the deadline time have on the payment?

Depends on deadline of a depositing transaction. If deadline is set to 24 hours then I would accept it after 10 confirmations. This is equal to 1 Bitcoin confirmation.

Deadline sets transaction expiration time. After blockchain reorg if a new branch doesn't contain a transaction it can be included into a block only if it's not expired.


Title: Re: [Nxt] API of Nxt
Post by: Come-from-Beyond on November 28, 2013, 03:27:44 PM
Version 0.2.16 got 3 new requests:

http://localhost:7876/?request=getState

http://localhost:7876/?request=getTransactionBytes&transaction=XXX

http://localhost:7876/?request=broadcastTransaction&transactionBytes=XXX

They r selfexplanatory I guess.


Title: Re: [Nxt] API of Nxt
Post by: GCInc. on November 28, 2013, 05:00:54 PM
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.


Title: Re: [Nxt] API of Nxt
Post by: Come-from-Beyond on November 28, 2013, 05:14:40 PM
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.


Title: Re: [Nxt] API of Nxt
Post by: GCInc. on November 28, 2013, 05:32:04 PM
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...


Title: Re: [Nxt] API of Nxt
Post by: Come-from-Beyond on November 28, 2013, 05:37:37 PM
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...


Title: Re: [Nxt] API of Nxt
Post by: Snard on November 28, 2013, 08:33:08 PM
If we wanted to walk through the blocks, what is the genesis block for Nxt?


Title: Re: [Nxt] API of Nxt
Post by: Come-from-Beyond on November 28, 2013, 08:45:44 PM
If we wanted to walk through the blocks, what is the genesis block for Nxt?

2680262203532249785


Title: Re: [Nxt] API of Nxt
Post by: Come-from-Beyond on November 30, 2013, 10:31:25 AM
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


Title: Re: [Nxt] API of Nxt
Post by: Come-from-Beyond on November 30, 2013, 03:57:53 PM
I have just noticed that getBlock request returns "previousBlock". No longer required to scan the blockchain from Genesis block, descending approach should work better!


Title: Re: [Nxt] API of Nxt
Post by: GCInc. on December 04, 2013, 09:56:48 PM
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"}


Title: Re: [Nxt] API of Nxt
Post by: Come-from-Beyond on December 04, 2013, 10:04:38 PM
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.


Title: Re: [Nxt] API of Nxt
Post by: Come-from-Beyond on December 04, 2013, 10:33:56 PM
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


Title: Re: [Nxt] API of Nxt
Post by: Come-from-Beyond on December 05, 2013, 12:14:52 PM
sendMoney API request enabled in 0.3.11.


Title: Re: [Nxt] API of Nxt
Post by: GCInc. on December 05, 2013, 08:05:03 PM
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.


Title: Re: [Nxt] API of Nxt
Post by: Come-from-Beyond on December 05, 2013, 08:08:24 PM
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.


Title: Re: [Nxt] API of Nxt
Post by: nelisky on December 07, 2013, 06:31:42 PM
API method request: a way to get a list of transactions pending inclusion in blocks (a la bitcoind getmemorypool).


Title: Re: [Nxt] API of Nxt
Post by: nelisky on December 07, 2013, 07:00:08 PM
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


Title: Re: [Nxt] API of Nxt
Post by: omo on December 08, 2013, 03:34:38 AM
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?


Title: Re: [Nxt] API of Nxt
Post by: Come-from-Beyond on December 08, 2013, 07:12:16 AM
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.


Title: Re: [Nxt] API of Nxt
Post by: nelisky on December 08, 2013, 08:31:25 PM
Is there already a way to retrieve the last block without knowing its id?


Title: Re: [Nxt] API of Nxt
Post by: Come-from-Beyond on December 08, 2013, 08:46:37 PM
Is there already a way to retrieve the last block without knowing its id?

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

Look at "lastBlock" value.


Title: Re: [Nxt] API of Nxt
Post by: omo on December 09, 2013, 12:55:14 AM
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.

so, how does the network know if an account is online?
I understand that starting a nxt client and opening my account in a web browser(online) will have a chance to earn the transaction fees.
Am I confused about UNLOCK and ONLINE?
If I unlock my account and quit the browser(without locking my account), do I have the chance to get trasaction fees?
If I stop the nxt client further, do I have the chance to get transaction fees?


Title: Re: [Nxt] API of Nxt
Post by: Come-from-Beyond on December 09, 2013, 07:23:13 AM
so, how does the network know if an account is online?
I understand that starting a nxt client and opening my account in a web browser(online) will have a chance to earn the transaction fees.
Am I confused about UNLOCK and ONLINE?
If I unlock my account and quit the browser(without locking my account), do I have the chance to get trasaction fees?
If I stop the nxt client further, do I have the chance to get transaction fees?

Network doesn't know if an account online. U unlock an account to let the soft know ur private key.
U can close browser without locking and u will be mining until u restart the client software.


Title: Re: [Nxt] API of Nxt
Post by: omo on December 10, 2013, 03:14:06 AM
Is there some changes about the UNLOCK request in 0.3.16 client?
I use a python script to unlock constantly,
when I restart the client, I got an error:
{u'responses': [{u'message': u'java.lang.NullPointerException', u'response': u'showMessage'}]}

I have to clean the whole nxt directory and restart th client to make the unlock script work again
I was using 0.3.14 and no such problem.

I like 0.3.16 that the numberOfAccounts shows the online accounts, right?


Title: Re: [Nxt] API of Nxt
Post by: Come-from-Beyond on December 10, 2013, 07:12:01 AM
Is there some changes about the UNLOCK request in 0.3.16 client?
I use a python script to unlock constantly,
when I restart the client, I got an error:
{u'responses': [{u'message': u'java.lang.NullPointerException', u'response': u'showMessage'}]}

I have to clean the whole nxt directory and restart th client to make the unlock script work again
I was using 0.3.14 and no such problem.

I like 0.3.16 that the numberOfAccounts shows the online accounts, right?

java.lang.NullPointerException is caused by corrupted files.

numberOfAccounts is number of all accounts.


Title: Re: [Nxt] API of Nxt
Post by: Come-from-Beyond on December 11, 2013, 09:44:53 AM
API method request: a way to get a list of transactions pending inclusion in blocks (a la bitcoind getmemorypool).

http://localhost:7874/nxt?requestType=getUnconfirmedTransactionIds (in 0.3.18)


Title: Re: [Nxt] API of Nxt
Post by: GCInc. on December 11, 2013, 10:43:32 AM
getting
Code:
{"errorCode":6,"errorDescription":"Not enough funds"}
for small amounts of NXT

while

Code:
{"balance":112049900,"effectiveBalance":112049900,"unconfirmedBalance":-90021000}

What's with that?


Title: Re: [Nxt] API of Nxt
Post by: Come-from-Beyond on December 11, 2013, 10:44:29 AM
getting
Code:
{"errorCode":6,"errorDescription":"Not enough funds"}
for small amounts of NXT

while

Code:
{"balance":112049900,"effectiveBalance":112049900,"unconfirmedBalance":-90021000}

What's with that?

Corrupted blockchain file.

Just restart and check again before redownloading the blockchain.


Title: Re: [Nxt] API of Nxt
Post by: GCInc. on December 12, 2013, 12:50:53 PM
We have many times received a txid for submitted sendMoney transactions that have an invalid receiver account number and eventually do not go thru. Is that right?


Title: Re: [Nxt] API of Nxt
Post by: Come-from-Beyond on December 12, 2013, 01:14:05 PM
We have many times received a txid for submitted sendMoney transactions that have an invalid receiver account number and eventually do not go thru. Is that right?

Could u post an example of such incorrect recipient account number?


Title: Re: [Nxt] API of Nxt
Post by: GCInc. on December 12, 2013, 02:44:16 PM
Could u post an example of such incorrect recipient account number?
Will post one when it comes along again. I may have been mistaken, by coincidence some payments that had a space in the account number, or decimals in the amount are not going through even through the wrong format is parsed.

I suppose the system still gives a txid instantly even when the transaction does not eventually necessarily go through.? For instance we have a transfer of 10337 NXT with txid 7304505050048365739 returned by the API, yet this payment has not materialized in the blockchain explorer.


Title: Re: [Nxt] API of Nxt
Post by: Come-from-Beyond on December 12, 2013, 03:02:51 PM
Could u post an example of such incorrect recipient account number?
Will post one when it comes along again. I may have been mistaken, by coincidence some payments that had a space in the account number, or decimals in the amount are not going through even through the wrong format is parsed.

I suppose the system still gives a txid instantly even when the transaction does not eventually necessarily go through.? For instance we have a transfer of 10337 NXT with txid 7304505050048365739 returned by the API, yet this payment has not materialized in the blockchain explorer.

Just like in Bitcoin if u send a transaction it's not guaranteed that it will be included into a block.


Title: Re: [Nxt] API of Nxt
Post by: GCInc. on December 12, 2013, 07:39:39 PM
Just like in Bitcoin if u send a transaction it's not guaranteed that it will be included into a block.
Ok, but NXT blocks are not nearly full. What would constitute the reasons for not including a payment in the numerous empty blocks that appear before the deadline?


Title: Re: [Nxt] API of Nxt
Post by: Come-from-Beyond on December 12, 2013, 07:42:41 PM
Just like in Bitcoin if u send a transaction it's not guaranteed that it will be included into a block.
Ok, but NXT blocks are not nearly full. What would constitute the reasons for not including a payment in the numerous empty blocks that appear before the deadline?

Network fragmentation. Make sure u use recent version and ur node is marked, this greatly increases chance to push a transaction.


Title: Re: [Nxt] API of Nxt
Post by: GCInc. on December 12, 2013, 08:43:30 PM
Network fragmentation. Make sure u use recent version and ur node is marked, this greatly increases chance to push a transaction.
I think I have marked my node. How to verify this pls?


Title: Re: [Nxt] API of Nxt
Post by: Come-from-Beyond on December 12, 2013, 08:45:13 PM
Network fragmentation. Make sure u use recent version and ur node is marked, this greatly increases chance to push a transaction.
I think I have marked my node. How to verify this pls?

Launch client from other node and check ur node in Active peers. It should have a non-zero weight set.


Title: Re: [Nxt] API of Nxt
Post by: GCInc. on December 12, 2013, 10:08:05 PM
Launch client from other node and check ur node in Active peers. It should have a non-zero weight set.
Right. Not in activepeers, had set up ip and hallmark. But just noticed http://localhost:7874/nxt?requestType=getMyInfo gives

Code:
{"host":"127.0.0.1","address":"127.0.0.1"}

How can I change the host to my static IP address? Thanks

Despite having set the IP, for some reason the node is not showing up in active peers.

More important: About the bogus txid received for sendMoney requests that are not included in blockchain; if we do getTransaction immediately after receiving the bogus txid, can we trust that the tx is not included in the blockchain at all (regardless of the deadline) if we get "Unknown transaction" as a reply?


Title: Re: [Nxt] API of Nxt
Post by: Come-from-Beyond on December 13, 2013, 05:12:16 AM
More important: About the bogus txid received for sendMoney requests that are not included in blockchain; if we do getTransaction immediately after receiving the bogus txid, can we trust that the tx is not included in the blockchain at all (regardless of the deadline) if we get "Unknown transaction" as a reply?

NO.


Title: Re: [Nxt] API of Nxt
Post by: Come-from-Beyond on December 13, 2013, 05:12:48 AM
Despite having set the IP, for some reason the node is not showing up in active peers.

PM me with ur hallmark plz.


Title: Re: [Nxt] API of Nxt
Post by: GCInc. on December 13, 2013, 01:16:18 PM
More important: About the bogus txid received for sendMoney requests that are not included in blockchain; if we do getTransaction immediately after receiving the bogus txid, can we trust that the tx is not included in the blockchain at all (regardless of the deadline) if we get "Unknown transaction" as a reply?

NO.
Ok. So is there a simple way to see quickly what sendMoney requests have gone, or are going through? Do we need to wait until the deadline and then check all the txid in question for at least 1 confirmation?


Title: Re: [Nxt] API of Nxt
Post by: Come-from-Beyond on December 13, 2013, 02:17:54 PM
More important: About the bogus txid received for sendMoney requests that are not included in blockchain; if we do getTransaction immediately after receiving the bogus txid, can we trust that the tx is not included in the blockchain at all (regardless of the deadline) if we get "Unknown transaction" as a reply?

NO.
Ok. So is there a simple way to see quickly what sendMoney requests have gone, or are going through? Do we need to wait until the deadline and then check all the txid in question for at least 1 confirmation?

After sendMoney do getTransaction.

1 confirmation is exactly the same as 0 confirmations.


Title: Re: [Nxt] API of Nxt
Post by: GCInc. on December 13, 2013, 02:30:13 PM
After sendMoney do getTransaction.
Yes that's what I asked a few messages back, but you answered NO  :). So we can only trust the tx that give valid output from getTransaction (at least 10 confirmations).

The other half or the problem remains:
What should we do with those tx for which we get valid-looking txid from sendMoney but they are not included in blockchain? They remain pending on our system until we can verify they are not included in blockchain. For how long should we wait before we can issue getTransaction and be sure the response given will be final?


Title: Re: [Nxt] API of Nxt
Post by: Come-from-Beyond on December 13, 2013, 02:49:45 PM
Yes that's what I asked a few messages back, but you answered NO  :). So we can only trust the tx that give valid output from getTransaction (at least 10 confirmations).

Oh, perhaps I didn't get one of ur questions...


The other half or the problem remains:
What should we do with those tx for which we get valid-looking txid from sendMoney but they are not included in blockchain? They remain pending on our system until we can verify they are not included in blockchain. For how long should we wait before we can issue getTransaction and be sure the response given will be final?

There is no "final" in cryptocurrencies. In Nxt a transaction must have 720 confirmations, this is the largest possible chain reorg depth.


Title: Re: [Nxt] API of Nxt
Post by: GCInc. on December 13, 2013, 03:09:38 PM
There is no "final" in cryptocurrencies. In Nxt a transaction must have 720 confirmations, this is the largest possible chain reorg depth.
Yes. But For All Practical Purposes there must be a workaround to the serious problem we are facing with rejected transactions;

- we get txid for every sendMoney call we submit (not considering blockchain not up to date etc.)
- about 25% of these valid-looking txid are not valid, ie. the money sent does not reach the blockchain and not the recipient
- when you say we cannot trust getTransaction, we have no way of programmatically knowing which tx is validly forwarded which are not
- the only way to get a hint of the rejects, we have concluded, is to visually observe the NXT client to see which tx are getting through
- the visual method is very cumbersome, AND it is not certain as some tx will be validly forwarded later even if they are not immediately

The above procedure is not feasible for any business mass handling payments. Additionally, just a single payment of, say 1M NXT, erroneously twice to the same recipient because of not receiving coherent transaction acknowledgement, and the business would be in serious trouble  ???


Title: Re: [Nxt] API of Nxt
Post by: Come-from-Beyond on December 13, 2013, 03:15:12 PM
There is no "final" in cryptocurrencies. In Nxt a transaction must have 720 confirmations, this is the largest possible chain reorg depth.
Yes. But For All Practical Purposes there must be a workaround to the serious problem we are facing with rejected transactions;

- we get txid for every sendMoney call we submit (not considering blockchain not up to date etc.)
- about 25% of these valid-looking txid are not valid, ie. the money sent does not reach the blockchain and not the recipient
- when you say we cannot trust getTransaction, we have no way of programmatically knowing which tx is validly forwarded which are not
- the only way to get a hint of the rejects, we have concluded, is to visually observe the NXT client to see which tx are getting through
- the visual method is very cumbersome, AND it is not certain as some tx will be validly forwarded later even if they are not immediately

The above procedure is not feasible for any business mass handling payments. Additionally, just a single payment of, say 1M NXT, erroneously twice to the same recipient because of not receiving coherent transaction acknowledgement, and the business would be in serious trouble  ???


U should use deadline. If u don't see a transaction after it expired then wait for 10+ (up to 720) more blocks and resend again. I'll enabled broadcastTransaction in next version, so u will be able to set 24h deadline and keep pushing the same transaction until it's confirmed.


Quote
- the only way to get a hint of the rejects, we have concluded, is to visually observe the NXT client to see which tx are getting through

getTransaction returns even unconfirmed transactions. No need to monitor interface.


Title: Re: [Nxt] API of Nxt
Post by: GCInc. on December 13, 2013, 03:47:41 PM
getTransaction returns even unconfirmed transactions. No need to monitor interface.
Does "Unknown transaction" response then mean anything, if the same unknown transaction can become known after any arbitrary length of time within the deadline?

The problem is we receive txid from sendMoney, and when submitting this txid to getTransaction, we get Unknown transaction. This would fine and dandy if it had any usefulness - but this data has no relevance. We would get the same response with a txid pulled from thin air.

So getTransaction can be used to just verify what transactions were positively valid. Those tx which his majesty getTransaction won't acknowledge immediately we need to wait until deadline, then wait for 10 further blocks, then check to verify some of them have gone through, then resubmit the remaining poor rejected ones. Doable yes, not easily.


Title: Re: [Nxt] API of Nxt
Post by: Come-from-Beyond on December 13, 2013, 03:58:28 PM
getTransaction returns even unconfirmed transactions. No need to monitor interface.
Does "Unknown transaction" response then mean anything, if the same unknown transaction can become known after any arbitrary length of time within the deadline?

The problem is we receive txid from sendMoney, and when submitting this txid to getTransaction, we get Unknown transaction. This would fine and dandy if it had any usefulness - but this data has no relevance. We would get the same response with a txid pulled from thin air.

So getTransaction can be used to just verify what transactions were positively valid. Those tx which his majesty getTransaction won't acknowledge immediately we need to wait until deadline, then wait for 10 further blocks, then check to verify some of them have gone through, then resubmit the remaining poor rejected ones. Doable yes, not easily.

Well, this is a decentralized system, Bitcoin has similar issue, Bitcoin network is just larger/more stable.

I would go such a way:
1. sendMoney with 22-day deadline (deadline = 32767 mins)
2. getTransaction in 1 min
3. broadcastTransaction if no transaction found and go to step 2
4. After the transaction is confirmed, check again in 720 blocks and do broadcastTransaction if it disappeared

Large deadline protects ur customer from blockchain reorgs.


Title: Re: [Nxt] API of Nxt
Post by: GCInc. on December 13, 2013, 05:43:16 PM
I would go such a way:
1. sendMoney with 22-day deadline (deadline = 32767 mins)
2. getTransaction in 1 min
3. broadcastTransaction if no transaction found and go to step 2
4. After the transaction is confirmed, check again in 720 blocks and do broadcastTransaction if it disappeared
Thanks - would you think the following more practical logic is sufficient to get reasonable payout success rate and protect us from accidentally paying customers twice;

1. sendMoney with 1-hour deadline
2. getTransaction immediately
3. If txid is known, mark transaction processed
4. after deadline is over, or at any point inbetween, go to part 2

We could run the above as often as necessary, to poll the network for arrived transactions and mark them processed. In the rare case of blockchain reorg, we trust the customer will complain :)


Title: Re: [Nxt] API of Nxt
Post by: Come-from-Beyond on December 13, 2013, 06:19:57 PM
Thanks - would you think the following more practical logic is sufficient to get reasonable payout success rate and protect us from accidentally paying customers twice;

1. sendMoney with 1-hour deadline
2. getTransaction immediately
3. If txid is known, mark transaction processed
4. after deadline is over, or at any point inbetween, go to part 2

We could run the above as often as necessary, to poll the network for arrived transactions and mark them processed. In the rare case of blockchain reorg, we trust the customer will complain :)

Looks fine.


Title: Re: [Nxt] API of Nxt
Post by: newcn on December 14, 2013, 09:51:30 AM
in the web interface, there a line which says "You can generate the next block in x day xx hour...."
is there a request can get that info?


Title: Re: [Nxt] API of Nxt
Post by: Come-from-Beyond on December 14, 2013, 09:54:54 AM
in the web interface, there a line which says "You can generate the next block in x day xx hour...."
is there a request can get that info?

Not in API, only in interface HTTP requests.


Title: Re: [Nxt] API of Nxt
Post by: GCInc. on December 15, 2013, 11:09:48 AM
Could you clarify when unconfirmedBalance is cleared? Deadline set to 60 mins which passed, no unconfirmed transactions, yet getBalance gives:

Code:
{"balance":1104325300,"effectiveBalance":1104325300,"unconfirmedBalance":892757800}


Title: Re: [Nxt] API of Nxt
Post by: Come-from-Beyond on December 15, 2013, 12:03:43 PM
Could you clarify when unconfirmedBalance is cleared? Deadline set to 60 mins which passed, no unconfirmed transactions, yet getBalance gives:

Code:
{"balance":1104325300,"effectiveBalance":1104325300,"unconfirmedBalance":892757800}


This can happen if u send a transaction but don't get it back from peers. Unconfirmed balance is for web interface only. API shouldn't work with it.


Title: Re: [Nxt] API of Nxt
Post by: GCInc. on December 15, 2013, 12:12:40 PM
This can happen if u send a transaction but don't get it back from peers. Unconfirmed balance is for web interface only. API shouldn't work with it.
Does it have any significance? Is there a possibility our balance can without further transactions become that which the unconfirmed amount shows? What happens with the transactions in limbo, can they go through or when are they purged?


Title: Re: [Nxt] API of Nxt
Post by: Come-from-Beyond on December 15, 2013, 12:28:19 PM
This can happen if u send a transaction but don't get it back from peers. Unconfirmed balance is for web interface only. API shouldn't work with it.
Does it have any significance? Is there a possibility our balance can without further transactions become that which the unconfirmed amount shows? What happens with the transactions in limbo, can they go through or when are they purged?

There is possibility that ur balance will become == unconfirmedBalance. Transactions in limbo can be confirmed at any moment before expiration.


Title: Re: [Nxt] API of Nxt
Post by: GCInc. on December 15, 2013, 12:44:23 PM
There is possibility that ur balance will become == unconfirmedBalance. Transactions in limbo can be confirmed at any moment before expiration.
That's a problem. Transactions were sent long ago with a deadline of 60 minutes. Yet they seem to be reflected in the unconfirmedbalance.

In addition, those transactions in limbo cannot be seen ANYWHERE? Very problematic when trying to process payments and ensure what will need to be repeat submitted and when.


Title: Re: [Nxt] API of Nxt
Post by: Come-from-Beyond on December 15, 2013, 12:48:40 PM
There is possibility that ur balance will become == unconfirmedBalance. Transactions in limbo can be confirmed at any moment before expiration.
That's a problem. Transactions were sent long ago with a deadline of 60 minutes. Yet they seem to be reflected in the unconfirmedbalance.

In addition, those transactions in limbo cannot be seen ANYWHERE? Very problematic when trying to process payments and ensure what will need to be repeat submitted and when.

1. Transaction is sent
2. Unconfirmed balance is adjusted
3. Transaction is not received from peers, so it doesn't appear in unconfirmed transactions

This leads to ur situation when even after transaction expiration the unconfirmed balance is not adjusted back.


There is an easy way to make sure that u'll never send one payment twice - https://bitcointalk.org/index.php?topic=313082.msg3950516#msg3950516


Title: Re: [Nxt] API of Nxt
Post by: GCInc. on December 15, 2013, 12:53:10 PM
This leads to ur situation when even after transaction expiration the unconfirmed balance is not adjusted back.
Ok, so after expiration it is safe for us to resend expired non-peer recognized transaction?

Let's just ignore the unconfirmed balance then. Out of interest, when will the unconfirmed balance be adjusted back?


Title: Re: [Nxt] API of Nxt
Post by: Come-from-Beyond on December 15, 2013, 01:33:40 PM
This leads to ur situation when even after transaction expiration the unconfirmed balance is not adjusted back.
Ok, so after expiration it is safe for us to resend expired non-peer recognized transaction?

Let's just ignore the unconfirmed balance then. Out of interest, when will the unconfirmed balance be adjusted back?

It's safe to resend an expired payment only if (A) ur local time is correct and (B) u see the longest branch. It's easy to make sure about (A) but not (B). So u'd better stick to broadcastTransaction approach.

Unconfirmed balance is adjusted back when a transaction expires and it's in unconfirmed transactions list.


Title: Re: [Nxt] API of Nxt
Post by: GCInc. on December 15, 2013, 01:39:23 PM
It's safe to resend an expired payment only if (A) ur local time is correct and (B) u see the longest branch. It's easy to make sure about (A) but not (B). So u'd better stick to broadcastTransaction approach.
Damn, we have risked quite a bit.

Could you add broadcastTransaction specs to the OP of this thread please?


Title: Re: [Nxt] API of Nxt
Post by: Come-from-Beyond on December 15, 2013, 01:41:37 PM
It's safe to resend an expired payment only if (A) ur local time is correct and (B) u see the longest branch. It's easy to make sure about (A) but not (B). So u'd better stick to broadcastTransaction approach.
Damn, we have risked quite a bit.

Could you add broadcastTransaction specs to the OP of this thread please?

No. I can't edit OP.

Read https://bitcointalk.org/index.php?topic=313082.msg3753193#msg3753193


Title: Re: [Nxt] API of Nxt
Post by: GCInc. on December 15, 2013, 02:06:46 PM
No. I can't edit OP.

Read https://bitcointalk.org/index.php?topic=313082.msg3753193#msg3753193
Sorry, missed that one.

What's the response supposed to be, instant acknowledgement like sendMoney?


Title: Re: [Nxt] API of Nxt
Post by: Come-from-Beyond on December 15, 2013, 02:20:42 PM
No. I can't edit OP.

Read https://bitcointalk.org/index.php?topic=313082.msg3753193#msg3753193
Sorry, missed that one.

What's the response supposed to be, instant acknowledgement like sendMoney?

Yes, with the transaction id.


Title: Re: [Nxt] API of Nxt
Post by: GCInc. on December 15, 2013, 07:16:44 PM
The problem we face with tx's in limbo, is that getTransactionBytes does not recognize the txid we just a minute earlier got from sendMoney.

Code:
{"errorCode":5,"errorDescription":"Unknown transaction"}

Thus we can not rebroadcast. It remains in limbo god knows how long?

Another problem that is not consistent with what we have talked here, is that we can not spend more than unconfirmedbalance. You said that "balance" is the actual balance, however we can not use more than 1M NXT from the following:

Code:
{"balance":902320000,"effectiveBalance":902320000,"unconfirmedBalance":108396200}


Title: Re: [Nxt] API of Nxt
Post by: Come-from-Beyond on December 15, 2013, 07:18:04 PM
The problem we face with tx's in limbo, is that getTransactionBytes does not recognize the txid we just a minute earlier got from sendMoney.

Code:
{"errorCode":5,"errorDescription":"Unknown transaction"}

Thus we can not rebroadcast. It remains in limbo god knows how long?

Another problem that is not consistent with what we have talked here, is that we can not spend more than unconfirmedbalance. You said that "balance" is the actual balance, however we can not use more than 1M NXT from the following:

Code:
{"balance":902320000,"effectiveBalance":902320000,"unconfirmedBalance":108396200}

U r right. Tomorrow I'll release 0.3.20 with fixed issues.

Edit: Right now u can relaunch the client to "reset" unconfirmed balance.


Title: Re: [Nxt] API of Nxt
Post by: mr_random on December 15, 2013, 07:26:12 PM
Come from beyond can I have your opinion on my nxt problem please - https://bitcointalk.org/index.php?topic=345619.msg3980085#msg3980085

Am I worrying over nothing that the balance is 0?


Title: Re: [Nxt] API of Nxt
Post by: Come-from-Beyond on December 15, 2013, 07:27:50 PM
Come from beyond can I have your opinion on my nxt problem please - https://bitcointalk.org/index.php?topic=345619.msg3980085#msg3980085

Am I worrying over nothing that the balance is 0?

U have 461'548 NXT on that account right now.


Title: Re: [Nxt] API of Nxt
Post by: mr_random on December 15, 2013, 07:32:27 PM
Come from beyond can I have your opinion on my nxt problem please - https://bitcointalk.org/index.php?topic=345619.msg3980085#msg3980085

Am I worrying over nothing that the balance is 0?

U have 461'548 NXT on that account right now.

Thanks but how can I verify that myself for future transactions? If it's in the blockchain in that blockexplorer with eg 5 confirmations does that my account definitely has it? Cos the block explorer says balance 0 BUT shows 450k nxt going into the account.

 (i'm having client problems on my local machine currently so I can't rely on that today)

Thank you


Title: Re: [Nxt] API of Nxt
Post by: Come-from-Beyond on December 15, 2013, 07:45:02 PM
Come from beyond can I have your opinion on my nxt problem please - https://bitcointalk.org/index.php?topic=345619.msg3980085#msg3980085

Am I worrying over nothing that the balance is 0?

U have 461'548 NXT on that account right now.

Thanks but how can I verify that myself for future transactions? If it's in the blockchain in that blockexplorer with eg 5 confirmations does that my account definitely has it? Cos the block explorer says balance 0 BUT shows 450k nxt going into the account.

 (i'm having client problems on my local machine currently so I can't rely on that today)

Thank you

U have to solve the client problems.


Title: Re: [Nxt] API of Nxt
Post by: mr_random on December 15, 2013, 07:48:31 PM
Come from beyond can I have your opinion on my nxt problem please - https://bitcointalk.org/index.php?topic=345619.msg3980085#msg3980085

Am I worrying over nothing that the balance is 0?

U have 461'548 NXT on that account right now.

Thanks but how can I verify that myself for future transactions? If it's in the blockchain in that blockexplorer with eg 5 confirmations does that my account definitely has it? Cos the block explorer says balance 0 BUT shows 450k nxt going into the account.

 (i'm having client problems on my local machine currently so I can't rely on that today)

Thank you

U have to solve the client problems.

Fair enough but does that mean the blockexplorer is not reliable? I always check my transactions in blockexplorers anyway to double check. Cos the block explorer says balance 0 for my account - that to me is worrying.



Title: Re: [Nxt] API of Nxt
Post by: Come-from-Beyond on December 15, 2013, 07:58:29 PM
Don't derail this thead, plz.


Title: Re: [Nxt] API of Nxt
Post by: GCInc. on December 16, 2013, 06:35:23 AM
Thanks but how can I verify that myself for future transactions? If it's in the blockchain in that blockexplorer with eg 5 confirmations does that my account definitely has it? Cos the block explorer says balance 0 BUT shows 450k nxt going into the account.
Block explorer uses the API, which has inconsistencies with the real / available balance for now.


Title: Re: [Nxt] API of Nxt
Post by: ferment on December 16, 2013, 12:41:48 PM
Version 0.2.16 got 3 new requests:

http://localhost:7876/?request=getState

What do the values of "state" mean? I assume 1 is ok. 2? Are there others?


Title: Re: [Nxt] API of Nxt
Post by: Come-from-Beyond on December 16, 2013, 12:53:55 PM
Version 0.2.16 got 3 new requests:

http://localhost:7876/?request=getState

What do the values of "state" mean? I assume 1 is ok. 2? Are there others?

Where have u seen "1"?


Title: Re: [Nxt] API of Nxt
Post by: ferment on December 16, 2013, 01:00:13 PM
Version 0.2.16 got 3 new requests:

http://localhost:7876/?request=getState

What do the values of "state" mean? I assume 1 is ok. 2? Are there others?

Where have u seen "1"?

From getPeer for node10.nxtbase.com:
Code:
{"application":"NRS",
"weight":1000,
"hallmark":SNIP,
"state":1,
"announcedAddress":"node10.nxtbase.com",
"downloadedVolume":631,
"version":"0.3.19e",
"uploadedVolume":17538}

with nxtbase, I can do easy stuff like this:
Code:
$ for i in {1..10}; do bin/peer node$i.nxtbase.com; done


Title: Re: [Nxt] API of Nxt
Post by: Come-from-Beyond on December 16, 2013, 01:54:38 PM
From getPeer for node10.nxtbase.com:
Code:
{"application":"NRS",
"weight":1000,
"hallmark":SNIP,
"state":1,
"announcedAddress":"node10.nxtbase.com",
"downloadedVolume":631,
"version":"0.3.19e",
"uploadedVolume":17538}

with nxtbase, I can do easy stuff like this:
Code:
$ for i in {1..10}; do bin/peer node$i.nxtbase.com; done

1 == Connected

More info on http://localhost:7874/nxt?requestType=getConstants


Title: Re: [Nxt] API of Nxt
Post by: ferment on December 16, 2013, 11:24:33 PM
Checking balances using 0.3.20, getBalance (http://localhost:7874/nxt?requestType=getBalance&account=11243542237777034551) is returning 100x the actual balance. Is that correct?

Code:
$ bin/nxt balance 11243542237777034551
balance: 1400000
effectiveBalance: 0
unconfirmedBalance: 1400000

Is this to support decimal NXT using integers?

Thanks!



Title: Re: [Nxt] API of Nxt
Post by: Come-from-Beyond on December 17, 2013, 03:41:27 AM
Checking balances using 0.3.20, getBalance (http://localhost:7874/nxt?requestType=getBalance&account=11243542237777034551) is returning 100x the actual balance. Is that correct?

Code:
$ bin/nxt balance 11243542237777034551
balance: 1400000
effectiveBalance: 0
unconfirmedBalance: 1400000

Is this to support decimal NXT using integers?

Thanks!



Yes, this is in cents.


Title: Re: [Nxt] API of Nxt
Post by: getfun12345 on December 17, 2013, 04:02:12 AM
Is there a request can get all the transactions relate to a specific account?


Title: Re: [Nxt] API of Nxt
Post by: Come-from-Beyond on December 17, 2013, 04:53:40 AM
Is there a request can get all the transactions relate to a specific account?

No. This should be done via blockchain scanning.


Title: Re: [Nxt] API of Nxt
Post by: ferment on December 17, 2013, 06:41:22 PM
Is there a way to get a list of all the accounts?

Thanks!


Title: Re: [Nxt] API of Nxt
Post by: Come-from-Beyond on December 17, 2013, 07:02:38 PM
Is there a way to get a list of all the accounts?

Thanks!

Yes, this can be done via blockchain scanning. :)

Let me know if u need a special API call for that.


Title: Re: [Nxt] API of Nxt
Post by: ferment on December 17, 2013, 07:08:12 PM
Is there a way to get a list of all the accounts?

Thanks!

Yes, this can be done via blockchain scanning. :)

Let me know if u need a special API call for that.

I can scan. Where are new accounts recorded?


Title: Re: [Nxt] API of Nxt
Post by: joefox on December 17, 2013, 07:24:32 PM
I can scan. Where are new accounts recorded?

Here's the thing.  CfB may correct me, but I suspect that all Nxt accounts already "exist", in that the network has to treat ANY public key as a valid account.  The account only appears in the blockchain once a deposit is made to a given account number.

The way to scan for accounts, then, would be to scan the blockchain for transactions, and pull the account numbers involved with those transactions.  Once you've scanned up to the latest block, you would only have to update your list with "new account numbers appearing since the last scan", in subsequent new blocks.

Gosh, I hope I'm right ;)


UPDATE:  If you look at the web page for the Blockchain Explorer (http://87.230.14.1/nxt/nxt.cgi?action=1), you can see that there is an "accounts" field on the "Node" line near the top of the window.  My gut says this field implies there are 1,499 accounts represented in the blockchain right now.


Title: Re: [Nxt] API of Nxt
Post by: ferment on December 17, 2013, 07:35:43 PM
I can scan. Where are new accounts recorded?

Here's the thing.  CfB may correct me, but I suspect that all Nxt accounts already "exist", in that the network has to treat ANY public key as a valid account.  The account only appears in the blockchain once a deposit is made to a given account number.

There's a zen koan in here somewhere... if a tree falls in the forest....

Quote
UPDATE:  If you look at the web page for the Blockchain Explorer (http://87.230.14.1/nxt/nxt.cgi?action=1), you can see that there is an "accounts" field on the "Node" line near the top of the window.  My gut says this field implies there are 1,499 accounts represented in the blockchain right now.

All of those accounts have non-zero balances too.

Ok, I get it! Thanks.


Title: Re: [Nxt] API of Nxt
Post by: GCInc. on December 18, 2013, 12:18:10 PM
Is there a request can get all the transactions relate to a specific account?

No. This should be done via blockchain scanning.
Why? It has been requested elsewhere (Android wallet coder) as well and would greatly simplify things.


Title: Re: [Nxt] API of Nxt
Post by: Come-from-Beyond on December 18, 2013, 12:24:54 PM
Is there a request can get all the transactions relate to a specific account?

No. This should be done via blockchain scanning.
Why? It has been requested elsewhere (Android wallet coder) as well and would greatly simplify things.

Blockchain scanning consumes less resources on server side. Anyway, this API call will be added.


Title: Re: [Nxt] API of Nxt
Post by: GCInc. on December 19, 2013, 12:14:06 PM
Can we be sure that if we only once issue sendMoney and then an arbitrarily high number of broadcastTransaction, the payment is sent just once. So boradcastTransaction does not resend the payment under any circumstances regarldess of blockchain / client status?


Title: Re: [Nxt] API of Nxt
Post by: Come-from-Beyond on December 19, 2013, 12:19:42 PM
Can we be sure that if we only once issue sendMoney and then an arbitrarily high number of broadcastTransaction, the payment is sent just once. So boradcastTransaction does not resend the payment under any circumstances regarldess of blockchain / client status?

Yes, u can be sure. broadcastTransaction only broadcasts, it doesn't alter bytes in any way. Sequence of bytes determines transaction id. Every node rejects transactions with id that already exists in blockchain or unconfirmed transactions.


Title: Re: [Nxt] API of Nxt
Post by: ferment on December 20, 2013, 01:57:47 AM
Are the APIs for the node in clearly separate classes from the web client?

For example, in addition to removing the HTML, could I also some class files?



Title: Re: [Nxt] API of Nxt
Post by: ferment on December 20, 2013, 02:05:43 AM
Is this the current list of APIs?

sendMoney
transactionBytes
broadcastTransaction
getPeers
getPeer
getState
getBalance
getMyInfo
decodeHallmark
decodeToken
getBlock
getTime
getTransaction
getConstants
getUnconfirmedTransactionIds
markHost (why not encodeHallmark?)

Are lock/unlock official APIs? Are they on the client and not the server?

Are there APIs for these?
encoding a token
generating an account number from a passphrase









Title: Re: [Nxt] API of Nxt
Post by: Come-from-Beyond on December 20, 2013, 05:23:03 AM
Are the APIs for the node in clearly separate classes from the web client?

For example, in addition to removing the HTML, could I also some class files?

No.


Title: Re: [Nxt] API of Nxt
Post by: Come-from-Beyond on December 20, 2013, 05:31:35 AM
Is this the current list of APIs?

sendMoney
transactionBytes
broadcastTransaction
getPeers
getPeer
getState
getBalance
getMyInfo
decodeHallmark
decodeToken
getBlock
getTime
getTransaction
getConstants
getUnconfirmedTransactionIds
markHost (why not encodeHallmark?)

Are lock/unlock official APIs? Are they on the client and not the server?

Are there APIs for these?
encoding a token
generating an account number from a passphrase

Current list:

assignAlias
broadcastTransaction
decodeHallmark
decodeToken
cancelAskOrder
cancelBidOrder
getAccountId
getAccountTransactionIds
getAlias
getAliasIds
getAliasURI
getAskOrder
getAskOrderIds
getAsset
getAssetIds
getBalance
getBidOrder
getBidOrderIds
getBlock
getConstants
getMyInfo
getPeer
getPeers
getState
getTime
getTransaction
getTransactionBytes
getUnconfirmedTransactionIds
issueAsset
markHost
placeAskOrder
placeBidOrder
sendMoney
transferAsset

Lock/unlock is for client only, this is not API.

Encoding a token - no such API
Generating account id = getAccountId

PS: This is complete list, some calls r absent in 0.3.20 and will be included into 0.4.0 (related to alias system) or disabled for the time being (related to asset exchange)


Title: Re: [Nxt] API of Nxt
Post by: ferment on December 20, 2013, 12:15:40 PM
Thanks for posting the list!


Encoding a token - no such API


Will this be added?

If not, can you describe how it's done?

Thanks!



Title: Re: [Nxt] API of Nxt
Post by: Come-from-Beyond on December 20, 2013, 12:20:45 PM
Thanks for posting the list!


Encoding a token - no such API


Will this be added?

If not, can you describe how it's done?

Thanks!

I'll add it.


Title: Re: [Nxt] API of Nxt
Post by: newcn on December 25, 2013, 02:50:57 AM
would you please add an entry of "numberOfPeers" to the output of getState request?


Title: Re: [Nxt] API of Nxt
Post by: Come-from-Beyond on December 25, 2013, 11:41:46 AM
would you please add an entry of "numberOfPeers" to the output of getState request?

Ok


Title: Re: [Nxt] API of Nxt
Post by: OKNXT on December 25, 2013, 02:36:06 PM

listAccountAliases&account

@CfB, could you please tell me which api should I call to list all my alias names? I know the account. Thanks.

http://localhost:7874/nxt?requestType=listAccountAliases&account=123


Title: Re: [Nxt] API of Nxt
Post by: wesleyh on December 25, 2013, 04:15:27 PM
How do I get a list of transactions associated with a specific account? (specifically incoming money transactions)


Title: Re: [Nxt] API of Nxt
Post by: Come-from-Beyond on December 25, 2013, 04:56:10 PM
How do I get a list of transactions associated with a specific account? (specifically incoming money transactions)

http://localhost:7874/nxt?requestType=getAccountTransactionIds&account=123&timestamp=0


Title: Re: [Nxt] API of Nxt
Post by: jl777 on December 26, 2013, 06:16:55 AM
Sorry for the newbie question, how do i associate a secret with an account?

Is the account a SHA 256 of a SHA 256 of a secret? 

James


Title: Re: [Nxt] API of Nxt
Post by: jl777 on December 26, 2013, 06:18:12 AM
Also, how do you create an account via API?

James


Title: Re: [Nxt] API of Nxt
Post by: Come-from-Beyond on December 26, 2013, 06:37:19 AM
Sorry for the newbie question, how do i associate a secret with an account?

Is the account a SHA 256 of a SHA 256 of a secret? 

James

Secret is mapped to account id via Curve25519(SHA256(secret))


Title: Re: [Nxt] API of Nxt
Post by: Come-from-Beyond on December 26, 2013, 06:37:50 AM
Also, how do you create an account via API?

James

Account is created by the very 1st transaction.


Title: Re: [Nxt] API of Nxt
Post by: datz on December 26, 2013, 10:15:03 AM
I have a NXT exchange built for you guys.

I have one missing link: generating NXT accounts from secrets.

I do curve25519hex(shaValue256(secretKey)) but this generates an alphanumerical hex, not a pure numerical account prevalent in NXT.

How do I generate accounts?


Title: Re: [Nxt] API of Nxt
Post by: Come-from-Beyond on December 26, 2013, 10:16:53 AM
I have a NXT exchange built for you guys.

I have one missing link: generating NXT accounts from secrets.

I do curve25519hex(shaValue256(secretKey)) but this generates an alphanumerical hex, not a pure numerical account prevalent in NXT.

How do I generate accounts?

http://localhost:7874/nxt?requestType=getAccountId&secretPhrase=MYSECRET

Edit: U could also take first 8 bytes and convert into unsinged long using little-endian notation.


Title: Re: [Nxt] API of Nxt
Post by: datz on December 26, 2013, 10:29:04 AM
great. now how can I tell if an address is a valid NXT address just from the address - no API calls?


Title: Re: [Nxt] API of Nxt
Post by: datz on December 26, 2013, 10:44:38 AM
NXT exchange launched!

https://peercover.com/#/simpleGateway

Please help us test!


Title: Re: [Nxt] API of Nxt
Post by: Come-from-Beyond on December 26, 2013, 11:09:01 AM
great. now how can I tell if an address is a valid NXT address just from the address - no API calls?

Try http://localhost:7874/nxt?requestType=getAccountPublicKey&account=123


Title: Re: [Nxt] API of Nxt
Post by: datz on December 26, 2013, 11:25:32 AM
great. now how can I tell if an address is a valid NXT address just from the address - no API calls?

Try http://localhost:7874/nxt?requestType=getAccountPublicKey&account=123

Cool. We are good to go, ready to provide exchange services for NXT.


Title: Re: [Nxt] API of Nxt
Post by: newcn on December 26, 2013, 11:44:40 AM
hello,
     I just made a statistic about all account's balance using API request. the total number is strange.
I start from the most recent block, and follow the 'previousBlock', go all the way down
until 'previousBlock'=None, and check transactions in each block, remember the 'sender'
and ' receipient'. then use getBalance api to get balance of each,and sumup all accounts's balance.
the number of accounts I got is 4205, which is the same as the output of getState.(when block height=25004)
but the total balance number is 18579288365!

I also find 2 accounts' balance is less than 0:
7577840883495855927 -999997985
15874940801139996458 -999997985
But I checked on http://87.230.14.1/nxt/nxt.cgi?action=10
these 2 accounts are ok.

did I make some mistakes, or is there a bug in the client/API?


Title: Re: [Nxt] API of Nxt
Post by: nexern on December 26, 2013, 12:01:18 PM
hello,
     I just made a statistic about all account's balance using API request. the total number is strange.
I start from the most recent block, and follow the 'previousBlock', go all the way down
until 'previousBlock'=None, and check transactions in each block, remember the 'sender'
and ' receipient'. then use getBalance api to get balance of each,and sumup all accounts's balance.
the number of accounts I got is 4205, which is the same as the output of getState.(when block height=25004)
but the total balance number is 18579288365!

I also find 2 accounts' balance is less than 0:
7577840883495855927 -999997985
15874940801139996458 -999997985
But I checked on http://87.230.14.1/nxt/nxt.cgi?action=10
these 2 accounts are ok.

did I make some mistakes, or is there a bug in the client/API?

hi nwecn,
you ar right, the blockexplorer is under constant attack to the node and also by automated query request.
the resulting database reorganization from this attacks de-sync's the db. therefore i wrote a note on top.
i am working to stop at least the query flooding as soon as possible. when done, it should be synced again.


Title: Re: [Nxt] API of Nxt
Post by: datz on December 26, 2013, 07:48:37 PM
For:

http://localhost:7874/nxt?requestType=getAccountTransactionIds&account=14862723975094572194&timestamp=0

I get {"errorCode":5,"errorDescription":"Unknown account"}

Why?

http://87.230.14.1/nxt/nxt.cgi?action=3000&acc=14862723975094572194



Title: Re: [Nxt] API of Nxt
Post by: Come-from-Beyond on December 26, 2013, 07:50:10 PM
For:

http://localhost:7874/nxt?requestType=getAccountTransactionIds&account=14862723975094572194&timestamp=0

I get {"errorCode":5,"errorDescription":"Unknown account"}

Why?

http://87.230.14.1/nxt/nxt.cgi?action=3000&acc=14862723975094572194



U r on a wrong branch. I see {"transactionIds":["15609747835883025669"]}


Title: Re: [Nxt] API of Nxt
Post by: datz on December 26, 2013, 07:51:30 PM
For:

http://localhost:7874/nxt?requestType=getAccountTransactionIds&account=14862723975094572194&timestamp=0

I get {"errorCode":5,"errorDescription":"Unknown account"}

Why?

http://87.230.14.1/nxt/nxt.cgi?action=3000&acc=14862723975094572194



U r on a wrong branch. I see {"transactionIds":["15609747835883025669"]}

How do I get on the right branch?


Title: Re: [Nxt] API of Nxt
Post by: datz on December 26, 2013, 07:53:41 PM
I setup from: http://nxtcrypto.wikia.com/wiki/How-To:InstallNRSLinux


Title: Re: [Nxt] API of Nxt
Post by: Come-from-Beyond on December 26, 2013, 07:59:01 PM
How do I get on the right branch?

Delete *.nxt files and launch again.


Title: Re: [Nxt] API of Nxt
Post by: lr127 on December 27, 2013, 11:25:20 AM
Come-from-Beyond

GET-requests to remote peers does not work in version 0.4.7e.
Answer: "Not allowed".
The problem is - "allowedBotHosts" in web.xml & NRS code.

This temporarily or permanently?
I am developing a mobile client and it all seriously hampered. :(

Are there any root hosts that accept such requests and will take them in the future?


Title: Re: [Nxt] API of Nxt
Post by: Come-from-Beyond on December 27, 2013, 11:27:24 AM
Come-from-Beyond

GET-requests to remote peers does not work in version 0.4.7e.
Answer: "Not allowed".
The problem is - "allowedBotHosts" in web.xml & NRS code.

This temporarily or permanently?
I am developing a mobile client and it all seriously hampered. :(

Are there any root hosts that accept such requests and will take them in the future?

U should ask community in main Nxt thread for list of hosts who allow access to API calls.


Title: Re: [Nxt] API of Nxt
Post by: Lubliana on December 27, 2013, 03:52:32 PM
I keep getting {"errorCode":4,"errorDescription":"Incorrect \"timestamp\""}

When trying to use requestType=getAccountTransactionIds

on version 0.4.7e, i tried different timestamps 0, -1, real timestamp

nothing works


Title: Re: [Nxt] API of Nxt
Post by: Come-from-Beyond on December 27, 2013, 03:56:03 PM
I keep getting {"errorCode":4,"errorDescription":"Incorrect \"timestamp\""}

When trying to use requestType=getAccountTransactionIds

on version 0.4.7e, i tried different timestamps 0, -1, real timestamp

nothing works

What exactly ur request is?


Title: Re: [Nxt] API of Nxt
Post by: Lubliana on December 27, 2013, 04:22:28 PM
I keep getting {"errorCode":4,"errorDescription":"Incorrect \"timestamp\""}

When trying to use requestType=getAccountTransactionIds

on version 0.4.7e, i tried different timestamps 0, -1, real timestamp

nothing works

What exactly ur request is?

For example:

http://localhost:7874/nxt?requestType=getAccountTransactionIds&account=6483973064837388393&timestamp=0

This works for me in an earlier version, but not in 0.4.7e

Did you change anything?


Thanks


Title: Re: [Nxt] API of Nxt
Post by: Come-from-Beyond on December 27, 2013, 04:41:30 PM
Did you change anything?

No.

And it works:
Code:
{"transactionIds":["16327828505285932473","7776315672991437607","7478358102654400317","9038949217488707578","5107797978721572291","3056041568658981150","13938595992812911398","5860553720038071526","14088864536744330557","98233104059687517","3708542302478143606","11723261810965383682","8480031398450915391","4637952893059799971","4278983739975323329","11578788549066895383","17355434458110030026","15327384437462965022","11518685970067256485","6225568623338018976","5358668617356551382","7334304928632209196","11321968978650279956","14554751727556954823","96427141454859614"]}

Rename *.bak files to *.nxt, maybe ur copy of blockchain is inconsistent.


Title: Re: [Nxt] API of Nxt
Post by: ferment on December 27, 2013, 07:00:13 PM

Are there any root hosts that accept such requests and will take them in the future?

U should ask community in main Nxt thread for list of hosts who allow access to API calls.

These are open for User and Bot.

node1.nxtbase.com; node11.nxtbase.com; node21.nxtbase.com; node31.nxtbase.com; node41.nxtbase.com; node51.nxtbase.com; node61.nxtbase.com; node71.nxtbase.com; node81.nxtbase.com; node91.nxtbase.com;


Title: Re: [Nxt] API of Nxt
Post by: Lubliana on December 27, 2013, 09:29:55 PM
Did you change anything?

No.

And it works:
Code:
{"transactionIds":["16327828505285932473","7776315672991437607","7478358102654400317","9038949217488707578","5107797978721572291","3056041568658981150","13938595992812911398","5860553720038071526","14088864536744330557","98233104059687517","3708542302478143606","11723261810965383682","8480031398450915391","4637952893059799971","4278983739975323329","11578788549066895383","17355434458110030026","15327384437462965022","11518685970067256485","6225568623338018976","5358668617356551382","7334304928632209196","11321968978650279956","14554751727556954823","96427141454859614"]}

Rename *.bak files to *.nxt, maybe ur copy of blockchain is inconsistent.

You were right, the blockchain was corrupt.

Version 0.4.7e is really stable, good job


Title: Re: [Nxt] API of Nxt
Post by: newcn on December 29, 2013, 02:17:07 AM
hello,
   what does 'numbOfPeers' from getState mean?
   does it mean the total number of nodes that run NRS client?


Title: Re: [Nxt] API of Nxt
Post by: NxtChoice on December 30, 2013, 05:08:05 AM
hello,
   what does 'numbOfPeers' from getState mean?
   does it mean the total number of nodes that run NRS client?

No, I think it's the peers who connect to you or whom you connect to.



Title: Re: [Nxt] API of Nxt
Post by: Come-from-Beyond on December 30, 2013, 05:38:26 AM
hello,
   what does 'numbOfPeers' from getState mean?
   does it mean the total number of nodes that run NRS client?

No, I think it's the peers who connect to you or whom you connect to.



It includes known and blacklisted peers also.


Title: Re: [Nxt] API of Nxt
Post by: omo on December 30, 2013, 08:48:28 AM
hello,
   what does 'numbOfPeers' from getState mean?
   does it mean the total number of nodes that run NRS client?

No, I think it's the peers who connect to you or whom you connect to.



It includes known and blacklisted peers also.

so,numbOfPeers should <= number of all nodes that run NRS client, If all nodes communicate well (they know each other) ,  numbOfPeers == number of all nodes, is that right?


Title: Re: [Nxt] API of Nxt
Post by: Come-from-Beyond on December 30, 2013, 08:52:50 AM
so,numbOfPeers should <= number of all nodes that run NRS client, If all nodes communicate well (they know each other) ,  numbOfPeers == number of all nodes, is that right?

No.
To get more info on a particular peer use http://localhost:7874/nxt?requestType=getPeer&peer=46.20.69.133
Peer state descriptions can be obtained via http://localhost:7874/nxt?requestType=getConstants


Title: Re: [Nxt] API of Nxt
Post by: ^[GS]^ on January 01, 2014, 05:18:48 AM
I think it has changed the protocol to 0.4.8, no longer works for almost any function??


Title: Re: [Nxt] API of Nxt
Post by: Come-from-Beyond on January 01, 2014, 05:48:03 AM
I think it has changed the protocol to 0.4.8, no longer works for almost any function??

No. What the issue do u have?


Title: Re: [Nxt] API of Nxt
Post by: marcus03 on January 01, 2014, 08:39:58 AM
-Can multiple accounts be unlocked against the same NXT server at the same time?

-Further, can I distribute the nxt software with my client to achieve a hassle-free end user experience?

Thanks for your help!


Title: Re: [Nxt] API of Nxt
Post by: Come-from-Beyond on January 01, 2014, 08:45:40 AM
-Can multiple accounts be unlocked against the same NXT server at the same time?

Yes.


-Further, can I distribute the nxt software with my client to achieve a hassle-free end user experience?

Yes.


Title: Re: [Nxt] API of Nxt
Post by: marcus03 on January 01, 2014, 09:55:31 AM
-Can multiple accounts be unlocked against the same NXT server at the same time?

Yes.


-Further, can I distribute the nxt software with my client to achieve a hassle-free end user experience?

Yes.

Thanks!

What is the meaning of numberOfUsers in the result of getState?


Title: Re: [Nxt] API of Nxt
Post by: Come-from-Beyond on January 01, 2014, 09:59:14 AM
What is the meaning of numberOfUsers in the result of getState?

This is number of attempts to open NRS web interface. Each page refresh creates a new user, even if they have the same account.


Title: Re: [Nxt] API of Nxt
Post by: marcus03 on January 01, 2014, 11:35:01 AM
From getConstants:

"peerStates":[{"description":"Non-connected","value":0},{"description":"Connected","value":1},{"description":"Disconnected","value":2}]

What is the difference between Non-connected and Disconnected?

Non-connected: Never was connected to this node.
Disconnected: Was connected, but now disconnected.

Like this?


Title: Re: [Nxt] API of Nxt
Post by: Come-from-Beyond on January 01, 2014, 11:37:54 AM
From getConstants:

"peerStates":[{"description":"Non-connected","value":0},{"description":"Connected","value":1},{"description":"Disconnected","value":2}]

What is the difference between Non-connected and Disconnected?

Non-connected: Never was connected to this node.
Disconnected: Was connected, but now disconnected.

Like this?

Yes.


Title: Re: [Nxt] API of Nxt
Post by: GCInc. on January 01, 2014, 06:58:19 PM
Why is the sendMoney API so slow on 0.4.8 (and most other versions)? It takes over 5 seconds per payment to get the txid, still a high percentage of these is not carried through. 34 peers shown.


Title: Re: [Nxt] API of Nxt
Post by: Come-from-Beyond on January 01, 2014, 07:03:33 PM
Why is the sendMoney API so slow on 0.4.8 (and most other versions)? It takes over 5 seconds per payment to get the txid, still a high percentage of these is not carried through. 34 peers shown.

Speed depends on number of peers it sends data to. Reduce maxNumberOfConnectedPublicPeers, increase pushThreshold, reduce connectTimeout.


Title: Re: [Nxt] API of Nxt
Post by: kjannis on January 01, 2014, 08:54:00 PM
Hi,

whenever I try to do the following:

GET http://localhost:7874/nxt?requestType=getAccountTransactionIds&account=18024643391205620992&timestamp=0&3.19606338E-8

I get an unknown account response.
Happens in 0.4.8, in 0.4.7e I got an incorrect timestamp error, and before everything was fine.

What am I doing wrong?
Do I need to do an unlockaccount request before this one?

Thanks.


Title: Re: [Nxt] API of Nxt
Post by: Come-from-Beyond on January 01, 2014, 09:19:46 PM
Hi,

whenever I try to do the following:

GET http://localhost:7874/nxt?requestType=getAccountTransactionIds&account=18024643391205620992&timestamp=0&3.19606338E-8

I get an unknown account response.
Happens in 0.4.8, in 0.4.7e I got an incorrect timestamp error, and before everything was fine.

What am I doing wrong?
Do I need to do an unlockaccount request before this one?

Thanks.

U don't need to unlock the account.
I see
Code:
{"transactionIds":["15085253524419928473","8112176655741647048","9791683000981722521","17260745815379391255","13480409775214063395","7176052155437098924","8756057990016875314"]}
Send me ur blocks.nxt and transactions.nxt files plz.


Title: Re: [Nxt] API of Nxt
Post by: ferment on January 01, 2014, 11:27:54 PM
Does the response of get_alias_ids include the ids of aliases that have been updated since the timestamp?


Title: Re: [Nxt] API of Nxt
Post by: Come-from-Beyond on January 02, 2014, 07:13:21 AM
Does the response of get_alias_ids include the ids of aliases that have been updated since the timestamp?

Yes.


Title: Re: [Nxt] API of Nxt
Post by: marcus03 on January 02, 2014, 10:49:14 AM

Current list:

assignAlias
broadcastTransaction
decodeHallmark
decodeToken
cancelAskOrder
cancelBidOrder
getAccountId
getAccountTransactionIds
getAlias
getAliasIds
getAliasURI
getAskOrder
getAskOrderIds
getAsset
getAssetIds
getBalance
getBidOrder
getBidOrderIds
getBlock
getConstants
getMyInfo
getPeer
getPeers
getState
getTime
getTransaction
getTransactionBytes
getUnconfirmedTransactionIds
issueAsset
markHost
placeAskOrder
placeBidOrder
sendMoney
transferAsset

Lock/unlock is for client only, this is not API.

Encoding a token - no such API
Generating account id = getAccountId

PS: This is complete list, some calls r absent in 0.3.20 and will be included into 0.4.0 (related to alias system) or disabled for the time being (related to asset exchange)


Can we get a "getCommands" command that returns the list of commands?


Title: Re: [Nxt] API of Nxt
Post by: Come-from-Beyond on January 02, 2014, 10:57:49 AM
Can we get a "getCommands" command that returns the list of commands?

It's quite pointless to have this in core soft if we can have it in Wiki.


Title: Re: [Nxt] API of Nxt
Post by: marcus03 on January 02, 2014, 11:04:02 AM
Can we get a "getCommands" command that returns the list of commands?

It's quite pointless to have this in core soft if we can have it in Wiki.

I would like to write a generic GUI for the API.

My program would call "getCommands", then call each command without a parameter, then look into the error message returned to find the needed parameters and then build a GUI with a command selector and parameter input boxes with their names attached to them.


Title: Re: [Nxt] API of Nxt
Post by: proinside on January 02, 2014, 11:09:31 AM
Can we get a "getCommands" command that returns the list of commands?

It's quite pointless to have this in core soft if we can have it in Wiki.

Just add a help command which gives help and valid commands. After all this is indeed best practise in coding to have an command to get help and/or help to single commands callable. Refusing such a trivial thing is actually not good to get developers on track with you.


Title: Re: [Nxt] API of Nxt
Post by: Come-from-Beyond on January 02, 2014, 11:19:19 AM
We could do it for API v2.


Title: Re: [Nxt] API of Nxt
Post by: proinside on January 02, 2014, 11:42:21 AM
We could do it for API v2.

Would recommend you guys to do it now. Dont be sorry later. Missing CLI help or api help smells like really bad practise and bad documentation...


Title: Re: [Nxt] API of Nxt
Post by: virtualdn on January 02, 2014, 11:44:50 AM
is there a method for uninstalling this? i had to format my computer to do it.


Title: Re: [Nxt] API of Nxt
Post by: Vega on January 02, 2014, 12:03:47 PM
is there a method for uninstalling this? i had to format my computer to do it.

Good job. You should also smash the HDD with a hammer just to be sure.


Title: Re: [Nxt] API of Nxt
Post by: marcus03 on January 02, 2014, 03:41:45 PM
Slightly OT:

If 2680262203532249785 is called the genesis block, what is the account 1739068987193023818 called (the one with the negative balance)?



Title: Re: [Nxt] API of Nxt
Post by: Come-from-Beyond on January 02, 2014, 04:56:40 PM
Slightly OT:

If 2680262203532249785 is called the genesis block, what is the account 1739068987193023818 called (the one with the negative balance)?



It's the genesis account. It's used to destroy coins.


Title: Re: [Nxt] API of Nxt
Post by: landomata on January 02, 2014, 04:58:56 PM
Slightly OT:

If 2680262203532249785 is called the genesis block, what is the account 1739068987193023818 called (the one with the negative balance)?



It's the genesis account. It's used to destroy coins.

are you able to find the thread...it no longer exist?


Title: Re: [Nxt] API of Nxt
Post by: Come-from-Beyond on January 02, 2014, 05:00:20 PM
are you able to find the thread...it no longer exist?

What thread?


Title: Re: [Nxt] API of Nxt
Post by: landomata on January 02, 2014, 05:01:09 PM
are you able to find the thread...it no longer exist?

What thread?

Discendant of bitcoin


Title: Re: [Nxt] API of Nxt
Post by: kjannis on January 02, 2014, 05:14:46 PM
When I start 0.4.8, I get 2 blacklisted peers:
95.85.22.142 and 78.46.63.221

Where can I add new peers?


Title: Re: [Nxt] API of Nxt
Post by: lr127 on January 03, 2014, 07:29:25 AM
Come-from-Beyond
I can not find a way to get a transaction id for an alias. This is not possible? 
I looked at GET & POST APIs. Nothing.


Title: Re: [Nxt] API of Nxt
Post by: Come-from-Beyond on January 03, 2014, 07:31:07 AM
Come-from-Beyond
I can not find a way to get a transaction id for an alias. This is not possible?  
I looked at GET & POST APIs. Nothing.

This can be done with getAccountTransactionIds and getTransaction. getTransaction returns transaction data, u should check ones with type == 1 and subtype == 1.
If u don't know the account then u r supposed to scan the whole blockchain.


Title: Re: [Nxt] API of Nxt
Post by: marcus03 on January 03, 2014, 08:12:13 AM
(Copied over from the main thread for reference.)

How to find the account that will forge the next block.


1. Do http://localhost:7874/nxt?requestType=getState to get value of "lastBlock"
2. Do http://localhost:7874/nxt?requestType=getBlock&block=10621696942372068326 (assuming 10621696942372068326 is the value of "lastBlock")
3. Convert "generationSignature" into binary and append public key bytes returned by getAccountPublicKey
4. Calculate SHA256(generationSignature, publicKey)
5. First 8 bytes as unsigned long in little-endian notation is HIT
6. Value of "baseTarget" multiplied by effective balance of the account is STATIC_TARGET
7. Do steps 3-6 for each account and find the one with lowest HIT/STATIC_TARGET ratio, this account will forge next block



Title: Re: [Nxt] API of Nxt
Post by: newcn on January 04, 2014, 05:21:23 AM
hello,
   I am thinking about a way to secure my account for the time being. If I generate an account ID outside nxt client(just use sha256/curve25519 to generate account id, not logon to the client), and send my NXTs to this account, is it safer or more dangerous than the ordinary way?
   In this case, even the nxt client don't know my privatekey/publickey, it should be safer. However, since the accountid is only 64 bits interger, the probability of collision is much higher than 256 bits publickey. I read from other threads that when a new passphrase is log on, the system will check the publickey to avoid the conincidence of collision. But in my case, I generate the account outside nxt client, there's no corresponding public key exist in the system, what if a person logon later with different passwd but the accountid happen to be the same as mine? does my balance all go to his account?


Title: Re: [Nxt] API of Nxt
Post by: Come-from-Beyond on January 04, 2014, 06:17:13 AM
hello,
   I am thinking about a way to secure my account for the time being. If I generate an account ID outside nxt client(just use sha256/curve25519 to generate account id, not logon to the client), and send my NXTs to this account, is it safer or more dangerous than the ordinary way?
   In this case, even the nxt client don't know my privatekey/publickey, it should be safer. However, since the accountid is only 64 bits interger, the probability of collision is much higher than 256 bits publickey. I read from other threads that when a new passphrase is log on, the system will check the publickey to avoid the conincidence of collision. But in my case, I generate the account outside nxt client, there's no corresponding public key exist in the system, what if a person logon later with different passwd but the accountid happen to be the same as mine? does my balance all go to his account?

Yes, ur balance will go to that account.


Title: Re: [Nxt] API of Nxt
Post by: marcus03 on January 04, 2014, 12:43:11 PM
I plan to implement TF in my client and I have two questions:

1.) There are no transactions that transfer earned fees to an account, right? So, if I would want to calculate the balance for an account, I would need to sum up all transaction from/to this account, plus I would need to look at each block to see if this account is the generator for the block and then add the fees in this block to the account balance. Right?

2.) It was said that an account that has no public key in the BC yet (no outgoing transactions) was more prone to a brute force attack. Could anyone explan why? I didn't get it. My idea is that a brute force attack works like this: dictionary words or random input generates a public and private key pair, the latter being the account number. I see no difference in the chances of finding an existing account number when using this procedure depending on if the public key is in the bc or not.  ???

Thanks for your help!
Marcus


Title: Re: [Nxt] API of Nxt
Post by: Come-from-Beyond on January 04, 2014, 12:50:01 PM
1.) There are no transactions that transfer earned fees to an account, right? So, if I would want to calculate the balance for an account, I would need to sum up all transaction from/to this account, plus I would need to look at each block to see if this account is the generator for the block and then add the fees in this block to the account balance. Right?

Right.


2.) It was said that an account that has no public key in the BC yet (no outgoing transactions) was more prone to a brute force attack. Could anyone explan why? I didn't get it. My idea is that a brute force attack works like this: dictionary words or random input generates a public and private key pair, the latter being the account number. I see no difference in the chances of finding an existing account number when using this procedure depending on if the public key is in the bc or not.  ???

Search space for unrevealed key is only 2^64.


Title: Re: [Nxt] API of Nxt
Post by: marcus03 on January 04, 2014, 01:22:13 PM
2.) It was said that an account that has no public key in the BC yet (no outgoing transactions) was more prone to a brute force attack. Could anyone explan why? I didn't get it. My idea is that a brute force attack works like this: dictionary words or random input generates a public and private key pair, the latter being the account number. I see no difference in the chances of finding an existing account number when using this procedure depending on if the public key is in the bc or not.  ???

Search space for unrevealed key is only 2^64.

Always busy, right.  ;)  Not enough info for me to understand...

No problem  - maybe someone else can jump in?


Title: Re: [Nxt] API of Nxt
Post by: marcus03 on January 04, 2014, 01:34:32 PM
And anothere one:

Account numbers are returned as json strings by the HTTP API, but they are always numbers.

Can I assume they always will be number inside these strings?
Or is it a bug in the API code?


Title: Re: [Nxt] API of Nxt
Post by: Come-from-Beyond on January 04, 2014, 01:39:33 PM
And anothere one:

Account numbers are returned as json strings by the HTTP API, but they are always numbers.

Can I assume they always will be number inside these strings?
Or is it a bug in the API code?

They r always numbers. They r represented as strings coz JS may round them.


Title: Re: [Nxt] API of Nxt
Post by: kjannis on January 04, 2014, 02:40:59 PM
Hi,

I am running a client on a VPS and want to check every x minutes for new transactions.
However I have a feeling it is not downloading the needed data for that account.
How can I make sure my client keeps downloading the data for an account?

Can I force this somehow? Perhaps by using curl every x minutes to a certain url?

Thanks?


Title: Re: [Nxt] API of Nxt
Post by: marcus03 on January 04, 2014, 03:42:19 PM
(Copied over from the main thread for reference.)

How to find the account that will forge the next block.


1. Do http://localhost:7874/nxt?requestType=getState to get value of "lastBlock"
2. Do http://localhost:7874/nxt?requestType=getBlock&block=10621696942372068326 (assuming 10621696942372068326 is the value of "lastBlock")
3. Convert "generationSignature" into binary and append public key bytes returned by getAccountPublicKey
4. Calculate SHA256(generationSignature, publicKey)
5. First 8 bytes as unsigned long in little-endian notation is HIT
6. Value of "baseTarget" multiplied by effective balance of the account is STATIC_TARGET
7. Do steps 3-6 for each account and find the one with lowest HIT/STATIC_TARGET ratio, this account will forge next block



We have a new block about every two minutes, so to always show the account that forges the next block, I need to do this calculation over all accounts again and again? Plus, I need always up-to-date effective balances.

I could implement this and it would currently run, but it will simply not scale with further adoption of NXT.

For now, I'll not implement this. (And I don't see a huge benefit in showing the account forgiung the next block anyway.)


Title: Re: [Nxt] API of Nxt
Post by: Come-from-Beyond on January 04, 2014, 03:49:53 PM
I could implement this and it would currently run, but it will simply not scale with further adoption of NXT.

This is made intentionally.


Title: Re: [Nxt] API of Nxt
Post by: marcus03 on January 04, 2014, 03:52:32 PM
I could implement this and it would currently run, but it will simply not scale with further adoption of NXT.

This is made intentionally.

Then why did you say that clients could support TF? I see no benefit.


Title: Re: [Nxt] API of Nxt
Post by: Come-from-Beyond on January 04, 2014, 03:55:47 PM
I could implement this and it would currently run, but it will simply not scale with further adoption of NXT.

This is made intentionally.

Then why did you say that clients could support TF? I see no benefit.

It's trivial to find who will forge next block among a million accounts, but impossible to predict who will do it in 1440 blocks.


Title: Re: [Nxt] API of Nxt
Post by: marcus03 on January 04, 2014, 04:02:26 PM
I could implement this and it would currently run, but it will simply not scale with further adoption of NXT.

This is made intentionally.

Then why did you say that clients could support TF? I see no benefit.

It's trivial to find who will forge next block among a million accounts, but impossible to predict who will do it in 1440 blocks.

What is the benefit of knowing who will forge the next block? From a client end-user perspective and in general?


Title: Re: [Nxt] API of Nxt
Post by: Come-from-Beyond on January 04, 2014, 04:07:45 PM
What is the benefit of knowing who will forge the next block? From a client end-user perspective and in general?

Users can send transactions directly to the miner. In general this helps to achieve VISA processing volume.


Title: Re: [Nxt] API of Nxt
Post by: marcus03 on January 04, 2014, 04:27:35 PM
What is the benefit of knowing who will forge the next block? From a client end-user perspective and in general?

Users can send transactions directly to the miner. In general this helps to achieve VISA processing volume.

There is no mining in NXT... Just kidding...  :P

Is this supported by the current API? How would I send a transaction to the node that has the account open that will forge the next block?



Title: Re: [Nxt] API of Nxt
Post by: Come-from-Beyond on January 04, 2014, 04:28:37 PM
Is this supported by the current API? How would I send a transaction to the node that has the account open that will forge the next block?

This will be implemented later. ETA is about 6 months.


Title: Re: [Nxt] API of Nxt
Post by: marcus03 on January 04, 2014, 10:40:46 PM
It's trivial to find who will forge next block among a million accounts, but impossible to predict who will do it in 1440 blocks.

It's not trivial for clients, since they will not have all account balances and private keys.

IMHO this should be implemented in the core. If it's really trivial, just add the next forging account as a return value to the getBlock function.


Title: Re: [Nxt] API of Nxt
Post by: joefox on January 05, 2014, 05:09:42 AM
Search space for unrevealed key is only 2^64.

Always busy, right.  ;)  Not enough info for me to understand...

No problem  - maybe someone else can jump in?

The account number is only a piece of the public key (the first 64 bytes, I think?), so the mapping of passphrases to account numbers is not one-to-one.  As soon as you find the first possible combination that unlocks that account, it's yours.  Anyone else who finds another possible passphrase after that point will be denied access to that account number, since it's already "taken".


Title: Re: [Nxt] API of Nxt
Post by: Come-from-Beyond on January 05, 2014, 05:17:08 AM
It's not trivial for clients, since they will not have all account balances and private keys.

IMHO this should be implemented in the core. If it's really trivial, just add the next forging account as a return value to the getBlock function.

Ok.


Title: Re: [Nxt] API of Nxt
Post by: marcus03 on January 05, 2014, 03:52:39 PM
I would need a call to get the Alias ID for an alias, so I can then call getAlias with the ID.

I will need it in the blockchain explorer part of my client when cleaning up the transactions from orphaned blocks.


Title: Re: [Nxt] API of Nxt
Post by: wesleyh on January 06, 2014, 02:36:42 PM
what is type, subtype of transaction? possible values and explanations of them? thx


Title: Re: [Nxt] API of Nxt
Post by: marcus03 on January 06, 2014, 02:39:01 PM
what is type, subtype of transaction? possible values and explanations of them? thx

Look at the output of getConstants or look into source code.


Title: Re: [Nxt] API of Nxt
Post by: marcus03 on January 06, 2014, 06:27:50 PM
Which balance is show in the NRS client? "Unconfirmed balance"?


Title: Re: [Nxt] API of Nxt
Post by: Come-from-Beyond on January 06, 2014, 06:50:34 PM
Which balance is show in the NRS client? "Unconfirmed balance"?

Yes


Title: Re: [Nxt] API of Nxt
Post by: newcn on January 07, 2014, 09:46:21 AM
about the sendMoney API, there's a parameter "referencedTransaction",
the explanation in wiki is"REFTRANSACTION is an option reference to a previous Nxt transaction ID"
can I set it to the previous transaction-ID of the sender account?
Is it ok to left the parameter empty(since it is an option)?


Title: Re: [Nxt] API of Nxt
Post by: Come-from-Beyond on January 07, 2014, 09:50:15 AM
about the sendMoney API, there's a parameter "referencedTransaction",
the explanation in wiki is"REFTRANSACTION is an option reference to a previous Nxt transaction ID"
can I set it to the previous transaction-ID of the sender account?
Is it ok to left the parameter empty(since it is an option)?

U can leave it empty or set to any transaction id. Ur transaction won't be confirmed until the referenced transaction is.


Title: Re: [Nxt] API of Nxt
Post by: newcn on January 07, 2014, 10:09:16 AM
about the sendMoney API, there's a parameter "referencedTransaction",
the explanation in wiki is"REFTRANSACTION is an option reference to a previous Nxt transaction ID"
can I set it to the previous transaction-ID of the sender account?
Is it ok to left the parameter empty(since it is an option)?

U can leave it empty or set to any transaction id. Ur transaction won't be confirmed until the referenced transaction is.

I see, so the referencedTransaction  makes some dependence for the transaction,
if the  referencedTransaction failed, the sendMoney transaction will be canceled, right?
it's a good feature!


Title: Re: [Nxt] API of Nxt
Post by: marcus03 on January 07, 2014, 02:05:22 PM
Are unconfirmed transactions as returned by getUnconfirmedTransactionIds also returned in getAccountTransactionIds (before they have confirmations)?


Title: Re: [Nxt] API of Nxt
Post by: Come-from-Beyond on January 07, 2014, 02:07:31 PM
Are unconfirmed transactions as returned by getUnconfirmedTransactionIds also returned in getAccountTransactionIds (before they have confirmations)?

No.


Title: Re: [Nxt] API of Nxt
Post by: marcus03 on January 07, 2014, 02:13:43 PM
Are unconfirmed transactions as returned by getUnconfirmedTransactionIds also returned in getAccountTransactionIds (before they have confirmations)?

No.

Then this is a request... :-)

Right now, to also show unconfirmed transactions for an account in my client, I would need to constantly call getUnconfirmedTransactionIds, retrieve the transactions returned and check if the clients account number is in these transactions.


Title: Re: [Nxt] API of Nxt
Post by: marcus03 on January 07, 2014, 09:46:53 PM
Is the list of nodes returned by getPeers the complete lists of nodes in the network or are these just the nodes that my node knows about?


Title: Re: [Nxt] API of Nxt
Post by: Come-from-Beyond on January 07, 2014, 09:50:07 PM
Is the list of nodes returned by getPeers the complete lists of nodes in the network or are these just the nodes that my node knows about?

The latter.


Title: Re: [Nxt] API of Nxt
Post by: abuelau on January 08, 2014, 03:53:37 PM
-Can multiple accounts be unlocked against the same NXT server at the same time?

Yes.


-Further, can I distribute the nxt software with my client to achieve a hassle-free end user experience?

Yes.

If multiple accounts are unlocked in the same server, will they all be forging?


Title: Re: [Nxt] API of Nxt
Post by: Come-from-Beyond on January 08, 2014, 03:55:25 PM
If multiple accounts are unlocked in the same server, will they all be forging?

Yes


Title: Re: [Nxt] API of Nxt
Post by: abuelau on January 08, 2014, 04:09:55 PM
Another question: is there a way to make a secure API send from a VPS?

If the API is being called from another VPS, I would need to send the secret in plan text between the 2 VPSs.


Title: Re: [Nxt] API of Nxt
Post by: Come-from-Beyond on January 08, 2014, 04:15:45 PM
Another question: is there a way to make a secure API send from a VPS?

If the API is being called from another VPS, I would need to send the secret in plan text between the 2 VPSs.

Use HTTPS


Title: Re: [Nxt] API of Nxt
Post by: bustingbuster on January 08, 2014, 05:26:41 PM
It would be more easier if the "getBalance" responses with the balance which atleast got 10 confirmations. Mind implementing this asap :) ?

+ If theres a command to move nxt instantly btw two accounts within a client like the bitcoins "move" rpc command. It would be very good.

The above two commands help very much to develop online marketplaces and wallets for nxt.

-Thanks-


Title: Re: [Nxt] API of Nxt
Post by: marcus03 on January 09, 2014, 07:59:31 AM
I've noticed I am not sure about some terms:

What does NRS actually stand for?
Is NRS only the bundled web client or the complete nxt software?
What is the server part called?
Does the bundled web client have a name?


Title: Re: [Nxt] API of Nxt
Post by: Come-from-Beyond on January 09, 2014, 08:28:49 AM
I've noticed I am not sure about some terms:

What does NRS actually stand for?
Is NRS only the bundled web client or the complete nxt software?
What is the server part called?
Does the bundled web client have a name?

NRS = Nxt Reference Software, it's the whitepaper written in Java.
It has 2 parts - server (as a Java servlet) and client (as HTML-files).


Title: Re: [Nxt] API of Nxt
Post by: ferment on January 09, 2014, 12:45:12 PM

NRS = Nxt Reference Software, it's the whitepaper written in Java.
It has 2 parts - server (as a Java servlet) and client (as HTML-files).

What do you call the parts of the Servlet that support the HTML like getInitialData, unLockAccount, etc?

I see 3 parts really: NRS, Client Servlet, and Client HTML.


Title: Re: [Nxt] API of Nxt
Post by: Come-from-Beyond on January 09, 2014, 12:48:37 PM

NRS = Nxt Reference Software, it's the whitepaper written in Java.
It has 2 parts - server (as a Java servlet) and client (as HTML-files).

What do you call the parts of the Servlet that support the HTML like getInitialData, unLockAccount, etc?

I see 3 parts really: NRS, Client Servlet, and Client HTML.


Client HTTP requests.


Title: Re: [Nxt] API of Nxt
Post by: ferment on January 09, 2014, 12:55:53 PM

NRS = Nxt Reference Software, it's the whitepaper written in Java.
It has 2 parts - server (as a Java servlet) and client (as HTML-files).

What do you call the parts of the Servlet that support the HTML like getInitialData, unLockAccount, etc?

I see 3 parts really: NRS, Client Servlet, and Client HTML.


Client HTTP requests.

Is there a plan for NRS APIs that handle these things?

-remove a peer
-handle block generation
-generate tokens






Title: Re: [Nxt] API of Nxt
Post by: Come-from-Beyond on January 09, 2014, 12:59:45 PM
-remove a peer
-handle block generation
-generate tokens

We r planning to create other API. Old API will be called Legacy API and become obsolete. New API will be split to 2 parts - Low-level API and High-level API. If u r planning to write a client software u could start a thread to discuss what LL and HL API calls u need.


Title: Re: [Nxt] API of Nxt
Post by: abuelau on January 09, 2014, 01:37:42 PM
-remove a peer
-handle block generation
-generate tokens

We r planning to create other API. Old API will be called Legacy API and become obsolete. New API will be split to 2 parts - Low-level API and High-level API. If u r planning to write a client software u could start a thread to discuss what LL and HL API calls u need.

What's the ETA for these new APIs?


Title: Re: [Nxt] API of Nxt
Post by: ferment on January 09, 2014, 02:02:27 PM

We r planning to create other API. Old API will be called Legacy API and become obsolete. New API will be split to 2 parts - Low-level API and High-level API. If u r planning to write a client software u could start a thread to discuss what LL and HL API calls u need.

https://bitcointalk.org/index.php?topic=406839


Title: Re: [Nxt] API of Nxt
Post by: Come-from-Beyond on January 09, 2014, 02:03:43 PM
What's the ETA for these new APIs?

Depends on how fast client devs decide what they need and how this should look.


Title: Re: [Nxt] API of Nxt
Post by: marcus03 on January 09, 2014, 03:19:51 PM
What would be a good approach to cleanup orphan blocks and their transactions on the client side?

Right now, I would make a list of all blocks, then walk down the chain from the highest block and remove these blocks in the chain from my list.
The remaining blocks in the list would be the orphan blocks and would need to be deleted.

Is there a better approach? Like is there or could there been an API call that would return all block ids that NRS knows are orphans?


Title: Re: [Nxt] API of Nxt
Post by: Come-from-Beyond on January 09, 2014, 03:22:20 PM
What would be a good approach to cleanup orphan blocks and their transactions on the client side?

Right now, I would make a list of all blocks, then walk down the chain from the highest block and remove these blocks in the chain from my list.
The remaining blocks in the list would be the orphan blocks and would need to be deleted.

Is there a better approach? Like is there or could there been an API call that would return all block ids that NRS knows are orphans?

Post this idea in that new thread plz.


Title: Re: [Nxt] API of Nxt
Post by: marcus03 on January 10, 2014, 08:55:33 AM
I'm posting this here again, since I would really like to have this implemented in the v1 API in one of the next NRS versions and not wait until v2 of the API.

What takes most of the time is when my client updates from NRS is getting the updated confirmation counts for transactions with less than 720 confirmations, because there are lots of back and forth calls since you have to call getTransaction again and again over a lot of transactions.

Would be nice to have some kind of batch mode, so e.g. send me all confirmations counts for all transactions that are in block x. Or block x to y. Or block x,y,z, etc. with just one request.



Title: Re: [Nxt] API of Nxt
Post by: marcus03 on January 11, 2014, 09:43:36 AM
Can the number of transaction confirmations only change when there is a new block? Or can it change "between blocks"?


Title: Re: [Nxt] API of Nxt
Post by: Come-from-Beyond on January 11, 2014, 09:46:02 AM
Can the number of transaction confirmations only change when there is a new block? Or can it change "between blocks"?

Only new blocks or chain reorgs can change the number.


Title: Re: [Nxt] API of Nxt
Post by: hiksush2 on January 12, 2014, 04:08:41 AM
Is there a way to get a list of all the accounts?

Thanks!

Yes, this can be done via blockchain scanning. :)

Let me know if u need a special API call for that.

I'd definitely like an API call that would return all accounts.  For blockchain scanning, what is the process to get all accounts?  A quick look at blocks.nxt (12MB) shows only ~300 unique generatorPublicKey's, and transactions.nxt (also 12MB) has about ~3500 unique accounts.  The blockchain explorer says "Accounts: 13919" and lists lots of new accounts being added though.


Title: Re: [Nxt] API of Nxt
Post by: ferment on January 12, 2014, 12:51:44 PM
Is there a way to get a list of all the accounts?

Thanks!

Yes, this can be done via blockchain scanning. :)

Let me know if u need a special API call for that.

I'd definitely like an API call that would return all accounts.  For blockchain scanning, what is the process to get all accounts?  A quick look at blocks.nxt (12MB) shows only ~300 unique generatorPublicKey's, and transactions.nxt (also 12MB) has about ~3500 unique accounts.  The blockchain explorer says "Accounts: 13919" and lists lots of new accounts being added though.

Get a unique list of the recipients of all transactions of all blocks.


Title: Re: [Nxt] API of Nxt
Post by: abuelau on January 12, 2014, 01:30:01 PM
Given a transaction, what is the best way to know if that transaction is related to an ALIAS or AM?


Title: Re: [Nxt] API of Nxt
Post by: Come-from-Beyond on January 12, 2014, 01:30:57 PM
Given a transaction, what is the best way to know if that transaction is related to an ALIAS or AM?

"subtype"


Title: Re: [Nxt] API of Nxt
Post by: abuelau on January 12, 2014, 02:14:01 PM
Given a transaction, what is the best way to know if that transaction is related to an ALIAS or AM?

"subtype"

Is the AM subtype = 2?


Title: Re: [Nxt] API of Nxt
Post by: Come-from-Beyond on January 12, 2014, 02:33:22 PM
Given a transaction, what is the best way to know if that transaction is related to an ALIAS or AM?

"subtype"

Is the AM subtype = 2?

= 0

PS: type = 1


Title: Re: [Nxt] API of Nxt
Post by: abuelau on January 12, 2014, 03:33:46 PM
Given a transaction, what is the best way to know if that transaction is related to an ALIAS or AM?

"subtype"

Is the AM subtype = 2?

= 0

PS: type = 1

So is this right:

Regular Tx: type=type=0, subtype=0
Alias Tx: type= type=1, subtype=1
AM Tx: type=1, subtype=0



Title: Re: [Nxt] API of Nxt
Post by: Come-from-Beyond on January 12, 2014, 03:35:52 PM
Given a transaction, what is the best way to know if that transaction is related to an ALIAS or AM?

"subtype"

Is the AM subtype = 2?

= 0

PS: type = 1

So is this right:

Regular Tx: type=type=0, subtype=0
Alias Tx: type= type=1, subtype=1
AM Tx: type=1, subtype=0



Yes, http://localhost:7874/nxt?requestType=getConstants gives description.


Title: Re: [Nxt] API of Nxt
Post by: marcus03 on January 13, 2014, 06:11:42 PM
I'm having  some trouble with the secretPhrase parameter. How should parameters be encoded?

I'm using UTF-8 and URL encoding so, e.g. the secret öäü (german umlaut characters) would be öäü in UTF-8 and that would be urlencoded to %C3%83%C2%B6%C3%83%C2%A4%C3%83%C2%BC resulting in:

http://..../nxt?requestType=sendMoney&secretPhrase=%C3%83%C2%B6%C3%83%C2%A4%C3%83%C2%BC&recipient=...

Anything wrong with that?


Title: Re: [Nxt] API of Nxt
Post by: marcus03 on January 13, 2014, 07:04:40 PM
I'm having  some trouble with the secretPhrase parameter. How should parameters be encoded?

I'm using UTF-8 and URL encoding so, e.g. the secret öäü (german umlaut characters) would be öäü in UTF-8 and that would be urlencoded to %C3%83%C2%B6%C3%83%C2%A4%C3%83%C2%BC resulting in:

http://..../nxt?requestType=sendMoney&secretPhrase=%C3%83%C2%B6%C3%83%C2%A4%C3%83%C2%BC&recipient=...

Anything wrong with that?

Got it to work. Had a problem with in my URL encoder.


Title: Re: [Nxt] API of Nxt
Post by: l8orre on January 13, 2014, 08:11:47 PM
hoi marcus03
- as you mention urlencoder - I am using python 'requests' - works nice. What are you using?

Cheers


Title: Re: [Nxt] API of Nxt
Post by: GCInc. on January 13, 2014, 11:50:07 PM
We have made a bunch of transactions that have received the transactionbytes. Deadline 7200 minutes, not even near of expiring, yet somehow these transactions are not pushed through even when others are. They receive the same transaction id and transactionbytes every time for days but do not go through. We are wary of resending them before deadline instead of rebroadcasting for the fear of double spending. Any ideas?


Title: Re: [Nxt] API of Nxt
Post by: rriky92 on January 14, 2014, 01:25:24 AM
what are the Arbitrary Message API?


Title: Re: [Nxt] API of Nxt
Post by: Vega on January 14, 2014, 01:36:59 AM
what are the Arbitrary Message API?

http://localhost:7874/nxt?requestType=sendMessage&secretPhrase=123&recipient=0&fee=1&deadline=1440&message=HEX_STRING


Title: Re: [Nxt] API of Nxt
Post by: Come-from-Beyond on January 14, 2014, 06:27:11 AM
We have made a bunch of transactions that have received the transactionbytes. Deadline 7200 minutes, not even near of expiring, yet somehow these transactions are not pushed through even when others are. They receive the same transaction id and transactionbytes every time for days but do not go through. We are wary of resending them before deadline instead of rebroadcasting for the fear of double spending. Any ideas?

Send me one of these transaction bytes, I'll check what is wrong.


Title: Re: [Nxt] API of Nxt
Post by: rriky92 on January 14, 2014, 01:58:28 PM
{"errorCode":7,"errorDescription":"Not allowed"}

But i can access the local client from browser


Title: Re: [Nxt] API of Nxt
Post by: Come-from-Beyond on January 14, 2014, 02:07:31 PM
{"errorCode":7,"errorDescription":"Not allowed"}

But i can access the local client from browser

Put * into allowedBotHosts.


Title: Re: [Nxt] API of Nxt
Post by: GCInc. on January 14, 2014, 05:54:38 PM
Sending you one through PM for txid: 17352005608016332505

Is it safe to use transactionbytes publicly?

We have made a bunch of transactions that have received the transactionbytes. Deadline 7200 minutes, not even near of expiring, yet somehow these transactions are not pushed through even when others are. They receive the same transaction id and transactionbytes every time for days but do not go through. We are wary of resending them before deadline instead of rebroadcasting for the fear of double spending. Any ideas?

Send me one of these transaction bytes, I'll check what is wrong.


Title: Re: [Nxt] API of Nxt
Post by: marcus03 on January 14, 2014, 06:02:18 PM
Sending you one through PM for txid: 17352005608016332505

Is it safe to use transactionbytes publicly?

http://localhost:7874/nxt?requestType=getTransactionBytes&transaction=17352005608016332505

Yes. ;-)


Title: Re: [Nxt] API of Nxt
Post by: hiksush2 on January 14, 2014, 06:35:29 PM
Is there a way to get a list of all the accounts?

Thanks!

Yes, this can be done via blockchain scanning. :)

Let me know if u need a special API call for that.

I'd definitely like an API call that would return all accounts.  For blockchain scanning, what is the process to get all accounts?  A quick look at blocks.nxt (12MB) shows only ~300 unique generatorPublicKey's, and transactions.nxt (also 12MB) has about ~3500 unique accounts.  The blockchain explorer says "Accounts: 13919" and lists lots of new accounts being added though.

Get a unique list of the recipients of all transactions of all blocks.

That's what I figured, but a quick check shows only ~7000 unique recipients in transactions.nxt vs. 14,000 accounts in the blockchain explorer:

Code:
$ java -jar jdeserialize-1.2.jar nxt/transactions.nxt | grep -E "recipient: [0-9-]+" | awk '{ print $2 }' | sort | uniq | wc -l
7105


Title: Re: [Nxt] API of Nxt
Post by: Come-from-Beyond on January 14, 2014, 06:41:34 PM
That's what I figured, but a quick check shows only ~7000 unique recipients in transactions.nxt vs. 14,000 accounts in the blockchain explorer:

Code:
$ java -jar jdeserialize-1.2.jar nxt/transactions.nxt | grep -E "recipient: [0-9-]+" | awk '{ print $2 }' | sort | uniq | wc -l
7105

R recipients with negative value included?


Title: Re: [Nxt] API of Nxt
Post by: hiksush2 on January 14, 2014, 09:17:50 PM
That's what I figured, but a quick check shows only ~7000 unique recipients in transactions.nxt vs. 14,000 accounts in the blockchain explorer:

Code:
$ java -jar jdeserialize-1.2.jar nxt/transactions.nxt | grep -E "recipient: [0-9-]+" | awk '{ print $2 }' | sort | uniq | wc -l
7105

R recipients with negative value included?

Yes, "recipient: [0-9-]+" matches all lines containing "recipient" except for the first one (structure definition).


Title: Re: [Nxt] API of Nxt
Post by: Come-from-Beyond on January 14, 2014, 09:39:46 PM
Yes, "recipient: [0-9-]+" matches all lines containing "recipient" except for the first one (structure definition).

No idea, looks like it doesn't count recipients with "-" sign.


Title: Re: [Nxt] API of Nxt
Post by: ^[GS]^ on January 14, 2014, 11:05:49 PM
I think it is necessary to use the same mode of representing the amounts in API's.

I personally think the right should be getBalance():

URL: http://localhost:7874/nxt?requestType=getBalance&account=9415965710853847055
RETURN: {"balance":217500,"effectiveBalance":217500,"unconfirmedBalance":217500}

217500 / 100 = 2175.00 NXT   All right!

However when we see a transaction with GetTransaction().

URL: http://localhost:7874/nxt?requestType=getTransaction&transaction=7613663286249813916
RETURN: {"sender":"16999902190493953875","fee":1,"amount":1,"timestamp":3150358,"referencedTransaction":"0","confirmations":12580,"subtype":0,
"block":"2365176096112318374", "senderPublicKey":"66538....77a579","type":0,"deadline":1000,
"signature":"e9619.....937639","recipient":"9415965710853847055"}

It this is wrong! should return:

RETURN: {"sender":"16999902190493953875","fee":100,"amount":100,"timestamp":3150358,"referencedTransaction":"0","confirmations":12580,"subtype":0,
"block":"2365176096112318374", "senderPublicKey":"66538....77a579","type":0,"deadline":1000,
"signature":"e9619.....937639","recipient":"9415965710853847055"}

I hope they correct, and then we could soon be able to use decimals!

This problem occurs also in...

* sendMoney() = URL http://localhost:7874/nxt?requestType=sendMoney&secretPhrase=IWontTellYou&recipient=398532577100249608&amount=1500&fee=1&deadline=900&referencedTransaction=...

* getBlock() = RETURN {"transactions":["14664591317056179258"],"blockSignature":"8e679e....5b5333","payloadLength":189,"numberOfTransactions":1,"version":1,
"timestamp":3196925,"previousBlock":"11012395561676092121","payloadHash":"3a4c.....a1e55b","height":29207,"totalFee":1,
"baseTarget":"490243708","generationSignature":"d5fc85......2e08","totalAmount":0,"generator":"4071545868996394636"}

* assignAlias() = URL http://localhost:7874/nxt?requestType=assignAlias&secretPhrase=hola&alias=hola&uri=&fee=1&deadline=1000

* sendMessage() = URL http://localhost:7874/nxt?requestType=sendMessage&secretPhrase=123&recipient=398532577100249608&fee=1&deadline=1440&message=b8a7a5...h381a3


Title: Re: [Nxt] API of Nxt
Post by: Come-from-Beyond on January 15, 2014, 06:31:55 AM
Good idea. We can't change existing API calls, but next API will follow ur proposal.


Title: Re: [Nxt] API of Nxt
Post by: marcus03 on January 15, 2014, 01:29:23 PM
There is nothing in the core that prevents me sending NXT or messages from one sender address to the same recipient address.

Is it ok, if I make use of this? Or will this be forbidden in the future?


Title: Re: [Nxt] API of Nxt
Post by: Come-from-Beyond on January 15, 2014, 02:14:03 PM
There is nothing in the core that prevents me sending NXT or messages from one sender address to the same recipient address.

Is it ok, if I make use of this? Or will this be forbidden in the future?

It's ok.


Title: Re: [Nxt] API of Nxt
Post by: marcus03 on January 15, 2014, 02:22:36 PM
It would be cool if getBalance would accept a timestamp parameter so that you could get an account balance at a certain point in time.


Title: Re: [Nxt] API of Nxt
Post by: rigel on January 16, 2014, 10:47:30 AM
When Nxt price will skyrocket we'll have to change the APIs to allow fee expressed in Nxt-cents or transactions will cost too much.

I think it's easier make now such an incompatible change than later when there will be a larger userbase...

It might be useful add more decimals than just 2.


Title: Re: [Nxt] API of Nxt
Post by: ferment on January 16, 2014, 01:22:04 PM
It would be cool if getBalance would accept a timestamp parameter so that you could get an account balance at a certain point in time.

You can do it with getAccountTransactionIds and getAccountBlockIds with a timestamp.


Title: Re: [Nxt] API of Nxt
Post by: Come-from-Beyond on January 16, 2014, 01:29:33 PM
It would be cool if getBalance would accept a timestamp parameter so that you could get an account balance at a certain point in time.

You can do it with getAccountTransactionIds and getAccountBlockIds with a timestamp.

Also getGuaranteedBalance could be used.


Title: Re: [Nxt] API of Nxt
Post by: marcus03 on January 16, 2014, 02:13:22 PM
It would be cool if getBalance would accept a timestamp parameter so that you could get an account balance at a certain point in time.

You can do it with getAccountTransactionIds and getAccountBlockIds with a timestamp.

Thanks, that'll work. Not handy, but ok.


Title: Re: [Nxt] API of Nxt
Post by: l8orre on January 18, 2014, 11:53:48 AM
 
NRS question -

maybe someone who knows (probably one of the core edevelopers) can give me a liitle hint here in respect to the blockchain operations:

as I understand the blockchain is an implementain of a Merkle tree, as is with Bitcoin.
Am I right with the assumption that the blockchain of NXT works in a similar manner as the blockchain of Bitcoin (hence the quick appearance of NXT blockchain explorers, etc),
and that the significant difference between NXT and bitcoin lies in the crypto (curve25519, incl PoS & transparent forging) BEHIND the blockchain?

So that if I want to get a grip on the internals of NXT, I could start out by getting a grip on the blockchain operations, which I could do by consulting Bitcoin blockchain documentation?  Grin

Cheers,
l8orre

[ or is there a special thread for this that I may have missed?    ??? posted this to the general thread, but it seems to be getting lost a bit there..]
   


Title: Re: [Nxt] API of Nxt
Post by: Come-from-Beyond on January 18, 2014, 11:55:47 AM

NRS question -

maybe someone who knows (probably one of the core edevelopers) can give me a liitle hint here in respect to the blockchain operations:

as I understand the blockchain is an implementain of a Merkle tree, as is with Bitcoin.
Am I right with the assumption that the blockchain of NXT works in a similar manner as the blockchain of Bitcoin (hence the quick appearance of NXT blockchain explorers, etc),
and that the the difference between NXT and bitcoin lies in the crypto (curve25519, incl PoS & transparent forging) BEHIND the blockchain?

So that if I want to get a grip on the internals of NXT, I could start out by getting a grip on the blockchain operations, which I could do by consulting Bitcoin blockchain documentation?  Grin

Cheers,
l8orre

[ or is there a special thread for this that I may have missed?    ??? posted this to the general thread, but it seems to be getting lost a bit there..]
   

Nxt does NOT use Merkle tree. Payload hash is calculated by sorting all transactions in ascending order according to their IDs represented as SIGNED 64bit numbers.


Title: Re: [Nxt] API of Nxt
Post by: l8orre on January 18, 2014, 01:10:58 PM


ah - I seem to have made a misconception there from the 'Diffie–Hellman–Merkle key exchange' definition, which has Merkle's name in it, but appears to be different form a Merkle tree.  :o
Thanks!


Title: Re: [Nxt] API of Nxt
Post by: opticalcarrier on January 21, 2014, 08:55:03 PM
Im testing the Asset Exchange using my CLI based API interface and there doesnt appear to be a way currently to determine which assets are owned by which accounts.  Also, Ive found something odd with how get bid/ask order ID API works:

#  ncli getBidOrder holms.cloudapp.net 4771732437964521054

    account: 16155265664111966451
    asset: 7126304194855053556
    price: 1
    quantity: 10

but then you cannot look up that asset 7126304194855053556:

ncli getAsset holms.cloudapp.net 7126304194855053556

    errorCode: 5
    errorDescription: Unknown asset

Come to find out that 7126304194855053556 that gets returned as "asset" from getBidOrder is really the account that issued the asset in question:

# foobar getAsset holms.cloudapp.net 7527606552308067548

    account: 7126304194855053556
    description: nxTestAsset
    name: nxTest
    quantity: 60000


Ive implemented 40 APIs in my bash script that lets you run CLI commands:

Usage:  ncli APIcmd server option1 option2...
where server is IP/DNS or use l to query localhost and options are APIcmd specific

It uses http not https due to limitation of curl.  http://pastebin.com/JAzy5RuX

EDIT:  Ive hardcoded the testnet port 6874 in there for the assetexchange APIs commands.  all others are 7874


Title: Re: [Nxt] API of Nxt
Post by: Come-from-Beyond on January 21, 2014, 09:06:24 PM
but then you cannot look up that asset 7126304194855053556:

ncli getAsset holms.cloudapp.net 7126304194855053556

    errorCode: 5
    errorDescription: Unknown asset

Come to find out that 7126304194855053556 that gets returned as "asset" from getBidOrder is really the account that issued the asset in question:

This is coz u placed an order with asset set to 7126304194855053556:

http://holms.cloudapp.net:6874/nxt?requestType=getTransaction&transaction=4771732437964521054

{"sender":"16155265664111966451","fee":1,"amount":0,"timestamp":5039362,"referencedTransaction":"0","confirmations":1,"subtype":3,"block":"1624353333851565570","attachment":{"price":1,"asset":"7126304194855053556","quantity":10},"senderPublicKey":"0db87c178e62699c467a8e90977fb2e95782dfafc7dee65ffa6ba5143743023e","type":2,"deadline":100,"signature":"38483a6099ff71b103defcead8c42195e0e10b8492d2e5bc5004a9c4fe95390f94b976315343106 7005312431118d611373516194c7b2372c101a2f01e89aac1","recipient":"1739068987193023818"}


Title: Re: [Nxt] API of Nxt
Post by: opticalcarrier on January 21, 2014, 11:54:21 PM
ah. I backtraced and found where/how I did a copy/paste error.

ok so the system doesnt prevent you from doing anything dumb.  will this be fixed in the future?

And it really would be useful to see the balance of assets, not just of NXT.


Title: Re: [Nxt] API of Nxt
Post by: Come-from-Beyond on January 22, 2014, 06:33:02 AM
ah. I backtraced and found where/how I did a copy/paste error.

ok so the system doesnt prevent you from doing anything dumb.  will this be fixed in the future?

And it really would be useful to see the balance of assets, not just of NXT.

Core doesn't prevent from doing dumb things, client soft is supposed to do it.

I'll add asset balance API.


Title: Re: [Nxt] API of Nxt
Post by: l8orre on January 22, 2014, 09:08:44 AM

C-f-B or Klee:

I am a bit slow to catch up here - things are moving fast. I know a bit about CME commodities futures trading, and the FIX API: http://en.wikipedia.org/wiki/Financial_Information_eXchange

In principal, asset exchange functions like this:

There are TWO fundamental order types: Market Orders and Limit Orders.

Limit Orders have a guaranteed price - hence 'limit order', but they don't have guaranteed execution: if there is no counteraprty at that price, the order will just hang there until it expires (if ever)

Market Orders have a guaranteed fast execution, but no guaranteed price. You get your execution 'immediately', for 'next best' price, whatever that may be.

So a market BUY order is matched againt the next best limit SELL order - i.e. the LOWEST sell price, and a market SELL order is matched against the HIGHEST buy order.

The LOWEST sell price is one tick above the HIGHEST buy price. The difference between these two is the 'spread'. Now if there are only limit orders, nothing much happens. The HIGHEST limit buy order does not just suddenly jump up on its own and buys for the LOWEST sell price - it can't, because it is a limit order. It may be that a new limit order or is entered, that crosses up or down to where another limit order of the opposite order book happens to lurking around - but that is rather rare.

The real action comes from the interplay between market orders and limit orders, and the fact that a trade is always sort of an annihilation of opposing particles: SellOrder + BuyOrder ->TradeExecution. Sort of like positron+electron -> photon


Apologies if I should be preaching to the choir here - I have no idea about you guys backgrounds. But latching on to opticalcarriers question there, I'd also be interersted in getting to know how to use MARKET orders and create assets ledgers and stuff like that in order to make a powerful asset exchange on nxt ...
 





Title: Re: [Nxt] API of Nxt: asset exchange
Post by: l8orre on January 22, 2014, 09:24:50 AM

an asset exchange needs a 'matching engine' with rules coded into it, that determine how buy and sell orders are matched and assets are transferred.

I don't know if anything such like is already in place or planned for the nxt asset exchange.  ???  :o

Please enter coments and discussion here !


Title: Re: [Nxt] API of Nxt: asset exchange
Post by: Come-from-Beyond on January 22, 2014, 09:44:15 AM

an asset exchange needs a 'matching engine' with rules coded into it, that determine how buy and sell orders are matched and assets are transferred.

I don't know if anything such like is already in place or planned for the nxt asset exchange.  ???  :o

Please enter coments and discussion here !

Matching engine is launched each time someone places an order.


Title: Re: [Nxt] API of Nxt
Post by: l8orre on January 22, 2014, 09:50:56 AM

mwoa.. what are the matching engine rules? how does it work? now I am getting really curious and excited! 


Title: Re: [Nxt] API of Nxt
Post by: Come-from-Beyond on January 22, 2014, 09:53:34 AM

mwoa.. what are the matching engine rules? how does it work? now I am getting really curious and excited! 

Standard matching algo:

Code:
    static void matchOrders(long assetId) {

        TreeSet<AskOrder> sortedAskOrders = Nxt.sortedAskOrders.get(assetId);
        TreeSet<BidOrder> sortedBidOrders = Nxt.sortedBidOrders.get(assetId);

        while (!sortedAskOrders.isEmpty() && !sortedBidOrders.isEmpty()) {

            AskOrder askOrder = sortedAskOrders.first();
            BidOrder bidOrder = sortedBidOrders.first();

            if (askOrder.price > bidOrder.price) {

                break;

            }

            int quantity = askOrder.quantity < bidOrder.quantity ? askOrder.quantity : bidOrder.quantity;
            long price = askOrder.height < bidOrder.height || (askOrder.height == bidOrder.height && askOrder.id < bidOrder.id) ? askOrder.price : bidOrder.price;

            if ((askOrder.quantity -= quantity) == 0) {

                askOrders.remove(askOrder.id);
                sortedAskOrders.remove(askOrder);

            }

            askOrder.account.addToBalanceAndUnconfirmedBalance(quantity * price);

            if ((bidOrder.quantity -= quantity) == 0) {

                bidOrders.remove(bidOrder.id);
                sortedBidOrders.remove(bidOrder);

            }

            bidOrder.account.addToAssetAndUnconfirmedAssetBalance(assetId, quantity);

        }

    }


Title: Re: [Nxt] API of Nxt
Post by: l8orre on January 22, 2014, 10:21:23 AM

Thanks!


Title: Re: [Nxt] API of Nxt
Post by: l8orre on January 22, 2014, 10:36:22 AM

quick question re. balance: what's the deal about these three different replies:

effectiveBalance - 0
unconfirmedBalance - 791500
balance - 791500

is the 'effectiveBalance' something old that should be dropped?



Title: Re: [Nxt] API of Nxt
Post by: Come-from-Beyond on January 22, 2014, 10:37:37 AM

quick question re. balance: what's the deal about these three different replies:

effectiveBalance - 0
unconfirmedBalance - 791500
balance - 791500

is the 'effectiveBalance' something old that should be dropped?



Effective balance shows ur forging power.


Title: Re: [Nxt] API of Nxt
Post by: opticalcarrier on January 22, 2014, 02:33:29 PM
Core doesn't prevent from doing dumb things, client soft is supposed to do it.

I'll add asset balance API.

Also the API for this asset exchange test system doesnt allow most API commands.  for example, we cannot even get balance or view transaction details.  Im assuming that there will be details available for asset exchange transactions to the level that there are of the regular API of getTransaction where account to/from is  shown as well as the amount transferred and fee, etc?


Title: Re: [Nxt] API of Nxt
Post by: Come-from-Beyond on January 22, 2014, 04:36:46 PM
Also the API for this asset exchange test system doesnt allow most API commands.  for example, we cannot even get balance or view transaction details.

It does. U can.


Title: Re: [Nxt] API of Nxt
Post by: opticalcarrier on January 22, 2014, 04:50:37 PM
Also the API for this asset exchange test system doesnt allow most API commands.  for example, we cannot even get balance or view transaction details.

It does. U can.

yes it does.  sorry for my herrrp and derrp


Title: Re: [Nxt] API of Nxt
Post by: abuelau on January 23, 2014, 07:58:34 PM
I know this has been asked before but I can't find the answer. How do I retrieve AMs?

I sent myself an AM that reads "this is a test". Here: http://localhost:7874/nxt?requestType=getTransactionBytes&transaction=5483638297221124474

This returns:

Quote
{"bytes":"010090844f00a00565dc6bacf933e912af02076f1c84fff1549708aeeb979024bdc689ee6476295 f919b203dd7d5be7d00000000010000000000000000000000453405b0c89ab0a748d2c7cadabc07 23cffb311eea5bc17583b61d06864ef104b7dc4e58e38faa2b7c88a219baaa723d2a5ec34334c08 474aefd74a8de8220421400000048656c6c6f207468697320697320612074657374","confirmations":12}

However the "bytes" part has a bunch of stuff in the beginning that is not my message. How do I know where my message starts in "bytes"?


Title: Re: [Nxt] API of Nxt
Post by: btc2nxt on January 24, 2014, 03:52:33 AM
bug:cannnot locate the asset

step 1:
http://holms.cloudapp.net:6874/nxt?requestType=issueAsset&secretPhrase=myphrasez&amount=10&fee=1001&deadline=900&name=Dog&quantity=10
{"transaction":"14069547964793243165"}

so issue asset is ok

but
step2 :
getAssetIds don't contain 14069547964793243165
and getAsset
{"errorCode":5,"errorDescription":"Unknown asset"}

now i repeat step 1
{"errorCode":8,"errorDescription":"\"Dog\" is already used"}
 

know details about api, please visit here :
http://wiki.nxtcrypto.org/wiki/Nxt_API


Title: Re: [Nxt] API of Nxt
Post by: l8orre on January 24, 2014, 08:39:08 AM
I have a question for our nxt GuiGurus here (cross post from main thread, which is meandering around a lot of other things) ..

I have the nxt api implementation for my nxTrader fairly well under control now, and I am working on the operations model of the client.

Please bear with my - I started late on this, only 1 week ago.

As I understand the nxt operations mode is as follows - please drop me a line if I have any misunderstandings there:


1 - information percolates through the network by the new blocks being generated (in rare cases they do not contain any transactions).

2 - when a new block is generated, it is broadcast through the network. the 'block' contains a bunch of metadata about itself, plus a payload. The payload is a list of transactions.

3 - a client is constantly on the lookout for new blocks. it does that by regularly polling an NRS server with the 'getState' query.
     the 'getSTate' query contains information about the network status, including the last block number. when that last block number changes from one poll to the next, that number will be the new block then.

4 - when that happens, the client has to 'getBlock' that new block, peel out the transactions therein, and analyze the transactions by type: 0,1,2 : transaction, messaging, coloredCoins, and subtypes. descritption of subtypes can be found with 'getConstants'.

5 - the client can do whatever it wants with the informaion about those transactions. it may disregard some, it displays different ones in different manners.

6 - the history of transactions is in the blockchain and transactions. also, the transactions for a specific account are always available via 'getAccountTransactionIds', so the client does not need to sift through    the whole history of the nxtNetwork every time it starts, it only needs to grab the transactions every time a new account number is entered.




Issue: I am (mostly) using a raspi to run my NRS. The raspi seems to have SIGNIFICANT problems to keep up with a polling freqency of even 1 second. I am using a QTimer - if I go to  something between 2 and 5 seconds, I don't have problem. But 1 second seems way too fast for the raspi, because it keeps returning only every 2 or three seconds (I have a clock that displays the time of return)


Questions:

1 - why does the raspi seem to have such problems with that?

2 - when I maintain that overload, i.e. query once per second: do the queries queue up and crash the raspi?

3 - this does not only concern the raspi: since I have a QTimer in my poll button, I can just as well query with  1 millisecond. If there is such an issue,  could I be able to bomb any NRS into oblivion with that?
    @CfB, Klee - would it make sense to test that on the testnet?

4 -  what exactly does the 'broadcastTransaction' do? if I 'sendMoney' , the transaction is sent into the network automatically, isn't it? so why (re?) - 'broadcastTransaction' ??

cheers,
l8orre



Title: Re: [Nxt] API of Nxt
Post by: Come-from-Beyond on January 24, 2014, 08:41:20 AM
I know this has been asked before but I can't find the answer. How do I retrieve AMs?

I sent myself an AM that reads "this is a test". Here: http://localhost:7874/nxt?requestType=getTransactionBytes&transaction=5483638297221124474

This returns:

Quote
{"bytes":"010090844f00a00565dc6bacf933e912af02076f1c84fff1549708aeeb979024bdc689ee6476295 f919b203dd7d5be7d00000000010000000000000000000000453405b0c89ab0a748d2c7cadabc07 23cffb311eea5bc17583b61d06864ef104b7dc4e58e38faa2b7c88a219baaa723d2a5ec34334c08 474aefd74a8de8220421400000048656c6c6f207468697320697320612074657374","confirmations":12}

However the "bytes" part has a bunch of stuff in the beginning that is not my message. How do I know where my message starts in "bytes"?

Use getTransaction.


Title: Re: [Nxt] API of Nxt
Post by: l8orre on January 24, 2014, 08:42:21 AM
I know this has been asked before but I can't find the answer. How do I retrieve AMs?

I sent myself an AM that reads "this is a test". Here: http://localhost:7874/nxt?requestType=getTransactionBytes&transaction=5483638297221124474

This returns:

Quote
{"bytes":"010090844f00a00565dc6bacf933e912af02076f1c84fff1549708aeeb979024bdc689ee6476295 f919b203dd7d5be7d00000000010000000000000000000000453405b0c89ab0a748d2c7cadabc07 23cffb311eea5bc17583b61d06864ef104b7dc4e58e38faa2b7c88a219baaa723d2a5ec34334c08 474aefd74a8de8220421400000048656c6c6f207468697320697320612074657374","confirmations":12}

However the "bytes" part has a bunch of stuff in the beginning that is not my message. How do I know where my message starts in "bytes"?


I think the 'bytes' part is s.t. else - the message as you sent it is accessible with its tTxId

MESSAGE SENT with apiCall:

https://192.168.178.24:7875/nxt?/nxt?&fee=1&secretPhrase=19letmyheartbestillamoment23&requestType=sendMessage&deadline=12&message=aaaaaaaaaaaabbbbbeeeeee1111&recipient=8208788471056955193

->message=aaaaaaaaaaaabbbbbeeeeee1111

transaction - 2440562297891784938
bytes - 0100a48a4f000c00390e4daf114f5628ed4d3cdb2f6dfbf41cc21c34b8c9bdca59a8fd612a84a63 b39f7ab559f79eb7100000000010000000000000000000000ca3153d90a91748d37b82eff79c5ef dd83e409d00d64c55d20414f1c3539e0029d6d96c690dd0a7075cd361e1baa0546ad75f21c95530 71642178b1d1710431c0d000000aaaaaaaaaaaabbbbbeeeeee111

                                                                                  in fact,  the message IS contained in 'BYTES' - interesting:   ^^^^^^^^^^^^^^^^^^



MSG RECVD on another account:

https://192.168.178.24:7875/nxt?/nxt?&requestType=getBlock&block=12844324000325204771

BLOCK:

payloadLength - 401
generator - 482115092852324318
transactions - [u'2440562297891784938', u'2896977874553576073', u'4889772855603033753']
timestamp - 5212956
numberOfTransactions - 3
previousBlock - 8946974642773827749
payloadHash - 15a5d862af5d1f65f6a905ff08fae9f2fa444c30c8cc9889993d346cd42652b1
baseTarget - 1532426424
version - 2
totalAmount - 1185
previousBlockHash - a520f6d4080a2a7c75a89a25a5267e8065e0ac1fab56fcca141bb4d9fd6d1dd4
height - 48473
blockSignature - 437d8ccf4bb1e6903cf877bfe6655c402ec0b100336cf1d224b74522d950cc0721793ea8da6697b 4c905a5a198be833003a34eb6263453289c8f39b7a89470b6
totalFee - 3
generationSignature - f233e37e16793f0a21f645da6e829220f6bfb561eb5690932ace4b68a38c500f



https://192.168.178.24:7875/nxt?/nxt?&requestType=getTransaction&transaction=2440562297891784938

Tx:

recipient - 8208788471056955193
fee - 1
sender - 8737506522730586553
timestamp - 5212836
senderPublicKey - 390e4daf114f5628ed4d3cdb2f6dfbf41cc21c34b8c9bdca59a8fd612a84a63b
subtype - 0
amount - 0
confirmations - 1
deadline - 12
attachment - {u'message': u'aaaaaaaaaaaabbbbbeeeeee111'}
signature - ca3153d90a91748d37b82eff79c5efdd83e409d00d64c55d20414f1c3539e0029d6d96c690dd0a7 075cd361e1baa0546ad75f21c9553071642178b1d1710431c
referencedTransaction - 0
type - 1
block - 12844324000325204771



Title: Re: [Nxt] API of Nxt
Post by: Come-from-Beyond on January 24, 2014, 08:44:28 AM
bug:cannnot locate the asset

step 1:
http://holms.cloudapp.net:6874/nxt?requestType=issueAsset&secretPhrase=myphrasez&amount=10&fee=1001&deadline=900&name=Dog&quantity=10
{"transaction":"14069547964793243165"}

so issue asset is ok

but
step2 :
getAssetIds don't contain 14069547964793243165
and getAsset
{"errorCode":5,"errorDescription":"Unknown asset"}

now i repeat step 1
{"errorCode":8,"errorDescription":"\"Dog\" is already used"}
 

know details about api, please visit here :
http://wiki.nxtcrypto.org/wiki/Nxt_API

http://holms.cloudapp.net:6874/nxt?requestType=getAsset&asset=7849724807799454521


Title: Re: [Nxt] API of Nxt
Post by: btc2nxt on January 26, 2014, 02:35:29 AM
1. assetid 15328485893864579482
{"description":"ImagineFairness","name":"NEX","account":"16155265664111966451","quantity":1000000000}

2. askorder
http://holms.cloudapp.net:6874/nxt?requestType=placeAskOrder&secretPhrase=myphrase&asset=15328485893864579482&quantity=21&price=12&fee=2&deadline=8440

{"errorCode":6,"errorDescription":"Not enough funds"}

3. this is my balance
{"balance":1798600,"effectiveBalance":1798600,"unconfirmedBalance":1798600}

4.
use another assetid 14269709746849295412
return
{"errorCode":6,"errorDescription":"Not enough funds"} too

5.placebidorder
ok
{"transaction":"9414020448077975079"}




Title: Re: [Nxt] API of Nxt
Post by: l8orre on January 26, 2014, 10:01:01 AM
1. assetid 15328485893864579482
{"description":"ImagineFairness","name":"NEX","account":"16155265664111966451","quantity":1000000000}

2. askorder
http://holms.cloudapp.net:6874/nxt?requestType=placeAskOrder&secretPhrase=myphrase&asset=15328485893864579482&quantity=21&price=12&fee=2&deadline=8440

{"errorCode":6,"errorDescription":"Not enough funds"}

3. this is my balance
{"balance":1798600,"effectiveBalance":1798600,"unconfirmedBalance":1798600}

4.
use another assetid 14269709746849295412
return
{"errorCode":6,"errorDescription":"Not enough funds"} too

5.placebidorder
ok
{"transaction":"9414020448077975079"}




yes, I keep getting things like that also. first guess would be that it is s-t- related to the testnet ...


Title: Re: [Nxt] API of Nxt
Post by: l8orre on January 26, 2014, 10:33:50 AM

so ... what does the NRS do when the client is sending queries faster than it can answer? discard them, or put them into a queue?


Title: Re: [Nxt] API of Nxt
Post by: Come-from-Beyond on January 28, 2014, 02:13:10 PM

so ... what does the NRS do when the client is sending queries faster than it can answer? discard them, or put them into a queue?

Depends on Jetty settings. I think it has a backlog.


Title: Re: [Nxt] API of Nxt
Post by: BaiMangal on January 28, 2014, 02:39:33 PM
Posted this earlier in the main "messy" thread but will put it in here too:

______________________________________________________________
Issue:
I don't think the deadline in placing BID_ASK orders works.
I created some orders 2-3 days ago and they are still available. Then I created one today with deadline 5mins

Here is the API call
http://holms.cloudapp.net:6874/nxt?requestType=placeAskOrder&secretPhrase=PASSPHRASE&asset=2514416012262277241&quantity=888&price=88&fee=1&deadline=5

Result:
{"transaction":"15792899347256983572"}

here is the order
http://holms.cloudapp.net:6874/nxt?requestType=getAskOrder&order=15792899347256983572
Result:
{"price":88,"asset":"2514416012262277241","account":"4432258843260249105","quantity":888}

is it a bug? maybe deadline has another meaning if so can we have some sort of expiry of the Orders?

Also do you think we should be able to see the deadline (expiry time left) for the order when we do getAskOrder?

______________________________________________________________

Can we have an API that can return the asset qty owned by an account?
I am thinking in terms of our gateway. When we transfer asset to someone how can he then check he got the asset an API would be cool.






Title: Re: [Nxt] API of Nxt
Post by: Come-from-Beyond on January 28, 2014, 02:40:43 PM
Orders don't expire. Deadline means deadline of a transaction.


Title: Re: [Nxt] API of Nxt
Post by: Come-from-Beyond on January 28, 2014, 02:43:15 PM
Can we have an API that can return the asset qty owned by an account?
I am thinking in terms of our gateway. When we transfer asset to someone how can he then check he got the asset an API would be cool.

I already implemented this API request. I'm waiting for other requests info to implement and release them. I don't have time to read all posts, could u guys cooperate and send me the "total" list?


Title: Re: [Nxt] API of Nxt
Post by: bootch on January 28, 2014, 05:36:56 PM
Is there full documentation for API in one place?


Title: Re: [Nxt] API of Nxt
Post by: Come-from-Beyond on January 28, 2014, 05:38:05 PM
Is there full documentation for API in one place?

Check http://wiki.nxtcrypto.org/wiki/Nxt_API


Title: Re: [Nxt] API of Nxt
Post by: l8orre on January 29, 2014, 02:05:42 PM
too much blablabla and talking about the color of the coin,thats all

U should add that we talk about color of the coins for 3 months already.

hey CfB - sorry, this is going quite quickly.

Do you have 'getAccountAssets' call on your list? Sort of an inventory that lists which assets and how much of it an account has? Was mentioned before, just asking to make sure becasue it seems essential to me!

Aslo, there is the questions of conditional BUY/SELL offers: Can you make a BUY or SELL l
limit order, that has th efollowing properties:

1: the issuer can NOT revoke it
2: it expires at a certain point in time if it is not matched
3: it is coded to a SPECIFIC account OR to a SPECIFIC key, and only the owner of the account / holder of the key can execute it

I think it could be possible with the present NRS infrastructre, and this would provide an extremely powerful method to issue options on virtual assets.

ALSO: in certail combinations, this might allow schemes to implement SMART ESCROW - not sure yet, but there might be a way to do this.

Think of the utility value of these two things that can be done with options contracts!

I am just posing these here in case it goes too fast, but I'll also put it over to the API dev thread..
 


Title: Re: [Nxt] API of Nxt
Post by: opticalcarrier on January 29, 2014, 04:01:21 PM
2: it expires at a certain point in time if it is not matched

I wish I had thought of this when I submitted my list to CfB on requested asset exchange APIs.  maybe it can make it in.


Title: Re: [Nxt] API of Nxt
Post by: Come-from-Beyond on January 29, 2014, 04:05:10 PM
2: it expires at a certain point in time if it is not matched

I wish I had thought of this when I submitted my list to CfB on requested asset exchange APIs.  maybe it can make it in.

Current orders don't expire.


Title: Re: [Nxt] API of Nxt
Post by: l8orre on January 29, 2014, 05:40:19 PM
2: it expires at a certain point in time if it is not matched

I wish I had thought of this when I submitted my list to CfB on requested asset exchange APIs.  maybe it can make it in.

Current orders don't expire.

guess those go on the wishlist for API2 - hey kids, don't unwrap your presents all at once  ;D

but really: consider the potential of this stuff  :o


Title: Re: [Nxt] API of Nxt
Post by: alpha_one_x86 on January 31, 2014, 12:10:52 PM
I have always:
{"errorCode":7,"errorDescription":"Not allowed"}
Or access denied, client runing at cli
I try:
wget 'http://localhost:7874/nxt?request=getBalance&account=398532577100249608' -O - -q


Title: Re: [Nxt] API of Nxt
Post by: Come-from-Beyond on January 31, 2014, 12:12:20 PM
I have always:
{"errorCode":7,"errorDescription":"Not allowed"}
Or access denied, client runing at cli
I try:
wget 'http://localhost:7874/nxt?request=getBalance&account=398532577100249608' -O - -q

Put "*" into "allowedBotHosts" in "web.xml".


Title: Re: [Nxt] API of Nxt
Post by: alpha_one_x86 on January 31, 2014, 12:49:17 PM
I have always:
{"errorCode":7,"errorDescription":"Not allowed"}
Or access denied, client runing at cli
I try:
wget 'http://localhost:7874/nxt?request=getBalance&account=398532577100249608' -O - -q

Put "*" into "allowedBotHosts" in "web.xml".
Why it work? Because the destination is well 127.0.0.1, and source too, then <param-value>127.0.0.1; localhost; 0:0:0:0:0:0:0:1;</param-value> is correct.
With:
wget -O - -q 'http://localhost:7874/nxt?user=0.8690339662134647&requestType=unlockAccount&secretPhrase=toto&0.7187995600979775'
I have:
{"responses":[{"response":"denyAccess"}]}
And:
wget -O - -q 'http://localhost:7874/nxt?requestType=unlockAccount&secretPhrase=toto'
{"errorCode":1,"errorDescription":"Incorrect request"}


Title: Re: [Nxt] API of Nxt
Post by: Come-from-Beyond on January 31, 2014, 12:51:25 PM
I have always:
{"errorCode":7,"errorDescription":"Not allowed"}
Or access denied, client runing at cli
I try:
wget 'http://localhost:7874/nxt?request=getBalance&account=398532577100249608' -O - -q

Put "*" into "allowedBotHosts" in "web.xml".
Why it work? Because the destination is well 127.0.0.1, and source too, then <param-value>127.0.0.1; localhost; 0:0:0:0:0:0:0:1;</param-value> is correct.
With:
wget -O - -q 'http://localhost:7874/nxt?user=0.8690339662134647&requestType=unlockAccount&secretPhrase=toto&0.7187995600979775'
I have:
{"responses":[{"response":"denyAccess"}]}
And:
wget -O - -q 'http://localhost:7874/nxt?requestType=unlockAccount&secretPhrase=toto'
{"errorCode":1,"errorDescription":"Incorrect request"}

If u add "user" HTTP parameter then allowedUserHosts works.


Title: Re: [Nxt] API of Nxt
Post by: alpha_one_x86 on January 31, 2014, 01:11:58 PM
But I have too: <param-value>127.0.0.1; localhost; 0:0:0:0:0:0:0:1;</param-value>
Replace by * will work, but it's not correct. I use 127.0.0.1, and it's into the list

And what about?:
wget -O - -q 'http://localhost:7874/nxt?requestType=unlockAccount&secretPhrase=toto'
{"errorCode":1,"errorDescription":"Incorrect request"}


Title: Re: [Nxt] API of Nxt
Post by: Come-from-Beyond on January 31, 2014, 01:20:23 PM
And what about?:
wget -O - -q 'http://localhost:7874/nxt?requestType=unlockAccount&secretPhrase=toto'
{"errorCode":1,"errorDescription":"Incorrect request"}

There is no unlockAccount API call. It's part of web interface.


Title: Re: [Nxt] API of Nxt
Post by: alpha_one_x86 on January 31, 2014, 01:32:39 PM
But I have too: <param-value>127.0.0.1; localhost; 0:0:0:0:0:0:0:1;</param-value>
Replace by * will work, but it's not correct. I use 127.0.0.1, and it's into the list


Title: Re: [Nxt] API of Nxt
Post by: Come-from-Beyond on January 31, 2014, 01:38:52 PM
But I have too: <param-value>127.0.0.1; localhost; 0:0:0:0:0:0:0:1;</param-value>
Replace by * will work, but it's not correct. I use 127.0.0.1, and it's into the list

What is returned by http://yourserver:7874/nxt?requestType=getMyInfo ?


Title: Re: [Nxt] API of Nxt
Post by: alpha_one_x86 on January 31, 2014, 02:16:07 PM
You are in right, it's what I need. My Ip is 127.X.X.X not 127.0.0.1.
I can open on 2 client my account to forging? Because my computer have internet problem, but on my server I can forge.


Title: Re: [Nxt] API of Nxt
Post by: Come-from-Beyond on January 31, 2014, 02:22:28 PM
I can open on 2 client my account to forging? Because my computer have internet problem, but on my server I can forge.

U can.


Title: Re: [Nxt] API of Nxt
Post by: opticalcarrier on January 31, 2014, 03:21:30 PM
whoa....


where can I get more info on this '&requestType=unlockAccount' thing.  I must have missed something.  Where is this request type and all its options documented at?


Title: Re: [Nxt] API of Nxt
Post by: GCInc. on February 01, 2014, 03:25:48 PM
Are transactions rebroadcast automatically in regular intervals in the network once they're sent their way? Source account had insufficient funds while broadcasting last night, but 16 hours later as it was funded, the pending transaction left by itself right after without any interaction with the NXT client.


Title: Re: [Nxt] API of Nxt
Post by: Come-from-Beyond on February 01, 2014, 04:14:15 PM
Are transactions rebroadcast automatically in regular intervals in the network once they're sent their way? Source account had insufficient funds while broadcasting last night, but 16 hours later as it was funded, the pending transaction left by itself right after without any interaction with the NXT client.

Yes, now transactions r rebroadcasted.


Title: Re: [Nxt] API of Nxt
Post by: opticalcarrier on February 03, 2014, 10:05:36 PM
can we get explicit info on the getPeer API?

the downloadedVolume:  is that figure the amount other peers have downloaded from the node returning the data, or is it the amount that peer has downloaded from other peers?

And is it bytes or packets or what?


Title: Re: [Nxt] API of Nxt
Post by: Come-from-Beyond on February 03, 2014, 10:24:35 PM
can we get explicit info on the getPeer API?

the downloadedVolume:  is that figure the amount other peers have downloaded from the node returning the data, or is it the amount that peer has downloaded from other peers?

And is it bytes or packets or what?


It's bytes. Downloaded by the node from that one peer.


Title: Re: [Nxt] API of Nxt
Post by: opticalcarrier on February 04, 2014, 01:30:43 AM
on getState, can someone explain more detail of the following 3?  The Wiki page is very basic.

cumulativeDifficulty:
I dont understand cumulative difficulty in NXT at all (or in bitcoin; I should educate myself here) I expect what I need here is a very long explanation, so perhaps you could recommend a good site that can break it down from a beginner level?

numberOfPeers
The Wiki says "NUMPEERS is the number of peers on the network" but is this the node's best guess of total number of all active peers across the entire network? Even including peers that are maybe 10 hops away?

totalEffectiveBalance
Is this the total amount of NXT participating in the forging process?


Title: Re: [Nxt] API of Nxt
Post by: btc2nxt on February 05, 2014, 07:44:45 AM
@ AE client devs:

Do u need any other API calls related to Asset Exchange?

Get current account order IDs
Obtain current order IDs for bid or ask orders for a specific account, optionally filtered by an an assetID. Implemented in version 0.5.9.
Request
http://localhost:7874/nxt?     requestType=GET_BID_OR_ASK&     account=ACCOUNT&     asset=ASSETID
-------------
1. can we get order by asssetid, need not contain account no, because i want to know who bid/ask my asset
2. there are only 12 assets now , if 10k or more,  it is difficult find a asset, maybe a
  asset type, brand are needed when isssue them, for example:   crypto coin, nxt;crypto,doge
        car,honda;computer, lenovo

this is test picture. i only get a bid order, there is not any ask orders . i tried doing askorder but failed.
https://i.imgur.com/WLITgh2.jpg




Title: Re: [Nxt] API of Nxt
Post by: Come-from-Beyond on February 05, 2014, 11:34:16 AM
@ AE client devs:

Do u need any other API calls related to Asset Exchange?

Get current account order IDs
Obtain current order IDs for bid or ask orders for a specific account, optionally filtered by an an assetID. Implemented in version 0.5.9.
Request
http://localhost:7874/nxt?     requestType=GET_BID_OR_ASK&     account=ACCOUNT&     asset=ASSETID
-------------
1. can we get order by asssetid, need not contain account no, because i want to know who bid/ask my asset
2. there are only 12 assets now , if 10k or more,  it is difficult find a asset, maybe a
  asset type, brand are needed when isssue them, for example:   crypto coin, nxt;crypto,doge
        car,honda;computer, lenovo

this is test picture. i only get a bid order, there is not any ask orders . i tried doing askorder but failed.
https://i.imgur.com/WLITgh2.jpg




Have u taken a look at getAccountCurrentAskOrderIds and getAccountCurrentBidOrderIds?


Title: Re: [Nxt] API of Nxt
Post by: btc2nxt on February 06, 2014, 07:58:19 AM
1. http://holms.cloudapp.net:6874/nxt?requestType=getAccountCurrentBidOrderIds&asset=14269709746849295412
{"errorCode":3,"errorDescription":"\"account\" not specified"}

can't get order from  getAccountCurrentBidOrderIds/ask api, with only assetid provided

2. wiki has a mistake in api
Get order IDs
http://localhost:7874/nxt?
     requestType=GET_BID_OR_ASK

http://holms.cloudapp.net:6874/nxt?requestType=getAskOrderIds
{"errorCode":3,"errorDescription":"\"asset\" not specified"}

http://holms.cloudapp.net:6874/nxt?requestType=getAskOrderIds
&asset=14269709746849295412
{"errorCode":3,"errorDescription":"\"timestamp\" not specified"}

http://holms.cloudapp.net:6874/nxt?requestType=getAskOrderIds&asset=14269709746849295412&timestamp=0
{"askOrderIds":[]}
http://holms.cloudapp.net:6874/nxt?requestType=getBidOrderIds&asset=14269709746849295412&timestamp=0
{"bidOrderIds":["17077867597681716581","16241672625542691626"]}

corrett api is
requestType=getBidOrderIds&asset=&timestamp=

from this api ,can get orderids by only asset, not including account


btw, to cfb: how to answer the bid/ask order , then finish orders?



Title: Re: [Nxt] API of Nxt
Post by: Come-from-Beyond on February 06, 2014, 08:56:54 AM
1. http://holms.cloudapp.net:6874/nxt?requestType=getAccountCurrentBidOrderIds&asset=14269709746849295412
{"errorCode":3,"errorDescription":"\"account\" not specified"}

can't get order from  getAccountCurrentBidOrderIds/ask api, with only assetid provided

This call returns orders of a particular account, u r supposed to provide account id.


btw, to cfb: how to answer the bid/ask order , then finish orders?

Just place an opposite order, Nxt will match them automatically.


Title: Re: [Nxt] API of Nxt
Post by: marcus03 on February 09, 2014, 06:45:37 PM
Quick question while getting familiar with AE API calls:

Besided showing orders, there is no way to get the actual trades that happened, right? Because I think we need a way to show the current price of an asset, don't we?


Title: Re: [Nxt] API of Nxt
Post by: Come-from-Beyond on February 09, 2014, 06:56:01 PM
Quick question while getting familiar with AE API calls:

Besided showing orders, there is no way to get the actual trades that happened, right? Because I think we need a way to show the current price of an asset, don't we?

Use getTrades


Title: Re: [Nxt] API of Nxt
Post by: marcus03 on February 09, 2014, 07:24:45 PM
Quick question while getting familiar with AE API calls:

Besided showing orders, there is no way to get the actual trades that happened, right? Because I think we need a way to show the current price of an asset, don't we?

Use getTrades

That isn't in the Wiki. I'll peek into the decompiled source to get all calls.

EDIT: Oh no... of course I can't... It's only in testnet, right? What other calls are in testnet that are not in production?


Title: Re: [Nxt] API of Nxt
Post by: Come-from-Beyond on February 09, 2014, 07:26:45 PM
Quick question while getting familiar with AE API calls:

Besided showing orders, there is no way to get the actual trades that happened, right? Because I think we need a way to show the current price of an asset, don't we?

Use getTrades

That isn't in the Wiki. I'll peek into the decompiled source to get all calls.

Use asset, firstIndex and lastIndex parameters. Indices set range of trades in the history. If omitted 0 and 2^32-1 default values r used.


Title: Re: [Nxt] API of Nxt
Post by: l8orre on February 10, 2014, 06:56:25 AM
Quick question while getting familiar with AE API calls:

Besided showing orders, there is no way to get the actual trades that happened, right? Because I think we need a way to show the current price of an asset, don't we?

Use getTrades

That isn't in the Wiki. I'll peek into the decompiled source to get all calls.

Use asset, firstIndex and lastIndex parameters. Indices set range of trades in the history. If omitted 0 and 2^32-1 default values r used.

Well, that is a new one to me - certainly very important function call. I'll have to include that in my client.

Since when has that been in  :o  ???




Title: Re: [Nxt] API of Nxt
Post by: Come-from-Beyond on February 10, 2014, 07:28:39 AM
Since when has that been in  :o  ???

~1 week


Title: Re: [Nxt] API of Nxt
Post by: marcus03 on February 10, 2014, 12:45:15 PM
Quick question while getting familiar with AE API calls:

Besided showing orders, there is no way to get the actual trades that happened, right? Because I think we need a way to show the current price of an asset, don't we?

Use getTrades

That isn't in the Wiki. I'll peek into the decompiled source to get all calls.

Use asset, firstIndex and lastIndex parameters. Indices set range of trades in the history. If omitted 0 and 2^32-1 default values r used.

Thanks!

And more questions:

What would I need to do to calculate the quantity of an asset in an account by going through the transaction list?

If an asset is issued, initially the quantity of assets created belong to the account the asset was created in, right?

If transferAsset is used, I can add/substract the quantity from the balance.

What if a trade happens? Will there be a "Asset transfer" transaction for the trade without transferAsset being explicilty called?


EDIT: The attachment in an "issue asset" transaction should definetly include the assetID.


Title: Re: [Nxt] API of Nxt
Post by: Come-from-Beyond on February 10, 2014, 01:10:13 PM
What would I need to do to calculate the quantity of an asset in an account by going through the transaction list?

U can't get the correct quantity of an asset easily coz u have to emulate order matching engine.


If an asset is issued, initially the quantity of assets created belong to the account the asset was created in, right?

Right


If transferAsset is used, I can add/substract the quantity from the balance.

Yes

What if a trade happens? Will there be a "Asset transfer" transaction for the trade without transferAsset being explicilty called?

Alice places an ask order 10 USD @ 2 NXT/USD. Her USD asset balance is adjusted by minus 10 USD.
Bob places a bid order 7 USD @ 2 NXT/USD. His balance is adjusted by minus 14 NXT.
System matches the orders. Alice gets +14 NXT. Bob gets +7 USD.
Alice cancels her order. Her USD asset balance is adjusted by plus 3 USD.

No an "Asset transfer" transaction happens.


Title: Re: [Nxt] API of Nxt
Post by: marcus03 on February 10, 2014, 02:16:28 PM
Thanks again. So no way to implement it in a lighter way in my client.

Somewhere I read a few days ago about new API call like getBalance which returns NXT and asset balances for an account, but I can't find it any longer. What's that API call again?


Title: Re: [Nxt] API of Nxt
Post by: marcus03 on February 10, 2014, 03:01:27 PM
Thanks again. So no way to implement it in a lighter way in my client.

Somewhere I read a few days ago about new API call like getBalance which returns NXT and asset balances for an account, but I can't find it any longer. What's that API call again?

Ok, found it: nxt?requestType=getAccount&account=...


Title: Re: [Nxt] API of Nxt
Post by: marcus03 on February 10, 2014, 05:13:49 PM
Out of curiosity:

Alice places an ask order 10 USD @ 3 NXT/USD. (Alice wants 10 USD for 30 NXT)
Bob places a bid order 10 USD @ 2 NXT/USD. (Bob sells 10 USD for 20 NXT)
No other open orders.

How does the system match these orders? 2, 3 or 2.5 NXT/USD trade price?


Title: Re: [Nxt] API of Nxt
Post by: Come-from-Beyond on February 10, 2014, 06:17:31 PM
Out of curiosity:

Alice places an ask order 10 USD @ 3 NXT/USD. (Alice wants 10 USD for 30 NXT)
Bob places a bid order 10 USD @ 2 NXT/USD. (Bob sells 10 USD for 20 NXT)
No other open orders.

How does the system match these orders? 2, 3 or 2.5 NXT/USD trade price?

Price depends on order the orders confirmed.


Title: Re: [Nxt] API of Nxt
Post by: marcus03 on February 10, 2014, 06:27:44 PM
Out of curiosity:

Alice places an ask order 10 USD @ 3 NXT/USD. (Alice wants 10 USD for 30 NXT)
Bob places a bid order 10 USD @ 2 NXT/USD. (Bob sells 10 USD for 20 NXT)
No other open orders.

How does the system match these orders? 2, 3 or 2.5 NXT/USD trade price?

Price depends on order the orders confirmed.

So in the example above, if Alice's order was confirmed first, she will get 10 USD for 20 NTX?


Title: Re: [Nxt] API of Nxt
Post by: Come-from-Beyond on February 10, 2014, 06:30:28 PM
Out of curiosity:

Alice places an ask order 10 USD @ 3 NXT/USD. (Alice wants 10 USD for 30 NXT)
Bob places a bid order 10 USD @ 2 NXT/USD. (Bob sells 10 USD for 20 NXT)
No other open orders.

How does the system match these orders? 2, 3 or 2.5 NXT/USD trade price?

Price depends on order the orders confirmed.

So in the example above, if Alice's order was confirmed first, she will get 10 USD for 20 NTX?

The price will be 3 NXT.


Title: Re: [Nxt] API of Nxt
Post by: marcus03 on February 11, 2014, 01:11:16 PM

These

http://holms.cloudapp.net:6874/nxt?requestType=getAskOrderIds&asset=14714270022348648277&timestamp=6829746
http://holms.cloudapp.net:6874/nxt?requestType=getAskOrderIds&asset=14714270022348648277&timestamp=20000
http://holms.cloudapp.net:6874/nxt?requestType=getAskOrderIds&asset=14714270022348648277&timestamp=0

all return the same AskOrderIds. Is the timestamp parameter ignored?


Title: Re: [Nxt] API of Nxt
Post by: Come-from-Beyond on February 11, 2014, 01:13:48 PM

These

http://holms.cloudapp.net:6874/nxt?requestType=getAskOrderIds&asset=14714270022348648277&timestamp=6829746
http://holms.cloudapp.net:6874/nxt?requestType=getAskOrderIds&asset=14714270022348648277&timestamp=20000
http://holms.cloudapp.net:6874/nxt?requestType=getAskOrderIds&asset=14714270022348648277&timestamp=0

all return the same AskOrderIds. Is the timestamp parameter ignored?

Yes


Title: Re: [Nxt] API of Nxt
Post by: marcus03 on February 12, 2014, 11:52:28 AM
From the wiki:

Place order
Places an "ask" or "bid" order for an asset onto the exchange.
Request
http://localhost:7874/nxt?
     requestType=BID_OR_ASK&
     secretPhrase=SECRET&
     asset=ASSETID&
     quantity=QTY&
     price=PRICE&
     fee=FEE&
     deadline=DEADLINE&
     referencedTransaction=REFTXID
Where:
BID_OR_ASK is either "placeAskOrder" or "placeBidOrder"
SECRET is the secret passphrase of the account issuing the transaction
ASSETID is the assetID of the asset being ordered
QTY is the amount of the asset being ordered
PRICE is the bid/ask price, expressed in Nxt-cents (i.e. "145" is "1.45 Nxt")
FEE is the fee for the transaction

Is this still correct or are prices in full NXT only?



Title: Re: [Nxt] API of Nxt
Post by: Come-from-Beyond on February 12, 2014, 11:56:13 AM
Is this still correct or are prices in full NXT only?

In cents.


Title: Re: [Nxt] API of Nxt
Post by: xchrix on February 12, 2014, 12:57:00 PM
guys i am a huge fan of NXT and saw that the asset exchange feature is coming alive!
checked the API documentation and looks like its easy to get a list of assets, their orderbook and the trades.
i want to make a completely new section on cryptocoincharts.info . beside cryptocoins and exchanges i want to show charts for assets. and i want to start with NXT assets as a promotion.

is somebody here willing to help me implementing this? i dont have deep knowledge of the NXT api so it would be good if somebody could implement the cronjobs which are polling the orderbook/trades of an asset and my part is doing the charts and info pages.
please contact me at office@cryptocoincharts.info if you want to help.
thank and keep up the good work!!!


Title: Re: [Nxt] API of Nxt
Post by: marcus03 on February 12, 2014, 02:27:37 PM
guys i am a huge fan of NXT and saw that the asset exchange feature is coming alive!
checked the API documentation and looks like its easy to get a list of assets, their orderbook and the trades.
i want to make a completely new section on cryptocoincharts.info . beside cryptocoins and exchanges i want to show charts for assets. and i want to start with NXT assets as a promotion.

is somebody here willing to help me implementing this? i dont have deep knowledge of the NXT api so it would be good if somebody could implement the cronjobs which are polling the orderbook/trades of an asset and my part is doing the charts and info pages.
please contact me at office@cryptocoincharts.info if you want to help.
thank and keep up the good work!!!

Sorry Chris, but I have no time left currently. I hope somebody else can jump in and help you.


Title: Re: [Nxt] API of Nxt
Post by: marcus03 on February 12, 2014, 02:31:04 PM
I was trying to get the account number of buyers and sellers by calling  getAskOrder/getBidOrder on the orderIDs that are returned with getTrades, but they are no longer available.

Fullfilled orders are immediately deleted from the system, right? So no way to show the seller and buyer account for a trade?


Title: Re: [Nxt] API of Nxt
Post by: bitcoinpaul on February 12, 2014, 03:32:50 PM
guys i am a huge fan of NXT and saw that the asset exchange feature is coming alive!
checked the API documentation and looks like its easy to get a list of assets, their orderbook and the trades.
i want to make a completely new section on cryptocoincharts.info . beside cryptocoins and exchanges i want to show charts for assets. and i want to start with NXT assets as a promotion.

is somebody here willing to help me implementing this? i dont have deep knowledge of the NXT api so it would be good if somebody could implement the cronjobs which are polling the orderbook/trades of an asset and my part is doing the charts and info pages.
please contact me at office@cryptocoincharts.info if you want to help.
thank and keep up the good work!!!

Very nice!

https://bitcointalk.org/index.php?topic=345619.msg5101634#msg5101634


Title: Re: [Nxt] API of Nxt
Post by: xchrix on February 12, 2014, 04:33:35 PM
guys i am a huge fan of NXT and saw that the asset exchange feature is coming alive!
checked the API documentation and looks like its easy to get a list of assets, their orderbook and the trades.
i want to make a completely new section on cryptocoincharts.info . beside cryptocoins and exchanges i want to show charts for assets. and i want to start with NXT assets as a promotion.

is somebody here willing to help me implementing this? i dont have deep knowledge of the NXT api so it would be good if somebody could implement the cronjobs which are polling the orderbook/trades of an asset and my part is doing the charts and info pages.
please contact me at office@cryptocoincharts.info if you want to help.
thank and keep up the good work!!!

Very nice!

https://bitcointalk.org/index.php?topic=345619.msg5101634#msg5101634

thx. sent a message :)


Title: Re: [Nxt] API of Nxt
Post by: Come-from-Beyond on February 12, 2014, 04:36:20 PM
Fullfilled orders are immediately deleted from the system, right? So no way to show the seller and buyer account for a trade?

Right. Use getTransaction and feed orderId as transactionId.


Title: Re: [Nxt] API of Nxt
Post by: marcus03 on February 12, 2014, 05:16:19 PM
Fullfilled orders are immediately deleted from the system, right? So no way to show the seller and buyer account for a trade?

Right. Use getTransaction and feed orderId as transactionId.

Works! :-) Thanks again!


Title: Re: [Nxt] API of Nxt
Post by: newcn on February 13, 2014, 03:29:21 AM
about  getAccountTransactionIds,
when I use this API to get all transactions of account 6483973064837388393, I only got 86 transactions:
http://localhost:7874/nxt?requestType=getAccountTransactionIds&account=6483973064837388393&timestamp=0
but from http://87.230.14.1/nxt/nxt.cgi?action=3000&acc=6635869272840226493
there're more than 10k transactions
is it a bug?


Title: Re: [Nxt] API of Nxt
Post by: Come-from-Beyond on February 13, 2014, 05:30:59 AM
about  getAccountTransactionIds,
when I use this API to get all transactions of account 6483973064837388393, I only got 86 transactions:
http://localhost:7874/nxt?requestType=getAccountTransactionIds&account=6483973064837388393&timestamp=0
but from http://87.230.14.1/nxt/nxt.cgi?action=3000&acc=6635869272840226493
there're more than 10k transactions
is it a bug?

Yes, u use different accounts in ur requests.


Title: Re: [Nxt] API of Nxt
Post by: newcn on February 13, 2014, 06:30:16 AM
about  getAccountTransactionIds,
when I use this API to get all transactions of account 6483973064837388393, I only got 86 transactions:
http://localhost:7874/nxt?requestType=getAccountTransactionIds&account=6483973064837388393&timestamp=0
but from http://87.230.14.1/nxt/nxt.cgi?action=3000&acc=6635869272840226493
there're more than 10k transactions
is it a bug?

Yes, u use different accounts in ur requests.

I'm sorry for the mistake! I checked it and it's ok.
another question:
Is there a way to get blockid by block_height directly?
sometimes I need to start from the genenesis block to access each block in an increasing order, currently I have to start from the most recent block and follow the "previousBlock" to reach the genesis block, store all blockids in an array, and then restart the loop.
this can also be solved by adding an alternative parameter to getBlock request: getBlock&blockheight=XXX


Title: Re: [Nxt] API of Nxt
Post by: Come-from-Beyond on February 13, 2014, 06:39:51 AM
Is there a way to get blockid by block_height directly?

Not sure, have to check it.


Title: Re: [Nxt] API of Nxt
Post by: marcus03 on February 14, 2014, 07:38:47 AM
Can you give as a preview of the changes in the existing API for using fees smaller than 1 NTX?

Currently only the API result for balances and the API parameters for asset prices are in cent.

Will all amounts (fees, nxt amounts) change to cents in the API calls and results or just the fees?

Will you introduce new requestTypes like "sendMessage2" that accepts the fee in cents or will the meaning of the fee in the old requestTypes actually change?


Title: Re: [Nxt] API of Nxt
Post by: Come-from-Beyond on February 14, 2014, 07:43:16 AM
Can you give as a preview of the changes in the existing API for using fees smaller than 1 NTX?

Currently only the API result for balances and the API parameters for asset prices are in cent.

Will all amounts (fees, nxt amounts) change to cents in the API calls and results or just the fees?

Will you introduce new requestTypes like "sendMessage2" that accepts the fee in cents or will the meaning of the fee in the old requestTypes actually change?

I don't know how Jean-Luc will solve this problem.


Title: Re: [Nxt] API of Nxt
Post by: syjrmswx on February 16, 2014, 01:00:50 AM
mark


Title: Re: [Nxt] API of Nxt
Post by: roslinpl on February 16, 2014, 01:06:03 AM
Is there a way to get blockid by block_height directly?

Not sure, have to check it.

Didnt found any way yet .. did you?


Title: Re: [Nxt] API of Nxt
Post by: Come-from-Beyond on February 16, 2014, 08:25:45 AM
Is there a way to get blockid by block_height directly?

Not sure, have to check it.

Didnt found any way yet .. did you?

No, Jean-Luc rewritten the code completely. I need more time to become familiar with the code.


Title: Re: [Nxt] API of Nxt
Post by: abuelau on February 20, 2014, 10:14:32 AM
Questions regarding the BroadCastTransaction API:

1) Can I use to it SEND NXT?
2) If I can use it to send Nxt, if the broadcast bytes are intercepted can the attacker figure out the account password from the bytes?
3) Where can I find information on how to use the BroadCastTransaction API (i.e. how to prepare the bytes??)
4) Is there any examples in javascript that show how to prepare the bytes to be sent using BroadCastTransaction?

Many thanks!


Title: Re: [Nxt] API of Nxt
Post by: Come-from-Beyond on February 20, 2014, 10:39:02 AM
Questions regarding the BroadCastTransaction API:

1) Can I use to it SEND NXT?
2) If I can use it to send Nxt, if the broadcast bytes are intercepted can the attacker figure out the account password from the bytes?
3) Where can I find information on how to use the BroadCastTransaction API (i.e. how to prepare the bytes??)
4) Is there any examples in javascript that show how to prepare the bytes to be sent using BroadCastTransaction?

Many thanks!

1. Yes
2. No
3. I'll add prepareTransaction and sendTransaction to be used for that
4. Bytes r returned by sendMoney, sendMessage, etc.


Title: Re: [Nxt] API of Nxt
Post by: abuelau on February 20, 2014, 11:16:43 AM
Questions regarding the BroadCastTransaction API:

1) Can I use to it SEND NXT?
2) If I can use it to send Nxt, if the broadcast bytes are intercepted can the attacker figure out the account password from the bytes?
3) Where can I find information on how to use the BroadCastTransaction API (i.e. how to prepare the bytes??)
4) Is there any examples in javascript that show how to prepare the bytes to be sent using BroadCastTransaction?

Many thanks!

1. Yes
2. No
3. I'll add prepareTransaction and sendTransaction to be used for that
4. Bytes r returned by sendMoney, sendMessage, etc.

I was actually trying to figure out if there's a way for me to prepare a transaction on the client browser (using javascript) and then broadcast the transaction bytes without ever having to call the NRS API (apart of course to broadcast the transaction).

So I gather that's not possible?


Title: Re: [Nxt] API of Nxt
Post by: Come-from-Beyond on February 20, 2014, 11:41:18 AM
Questions regarding the BroadCastTransaction API:

1) Can I use to it SEND NXT?
2) If I can use it to send Nxt, if the broadcast bytes are intercepted can the attacker figure out the account password from the bytes?
3) Where can I find information on how to use the BroadCastTransaction API (i.e. how to prepare the bytes??)
4) Is there any examples in javascript that show how to prepare the bytes to be sent using BroadCastTransaction?

Many thanks!

1. Yes
2. No
3. I'll add prepareTransaction and sendTransaction to be used for that
4. Bytes r returned by sendMoney, sendMessage, etc.

I was actually trying to figure out if there's a way for me to prepare a transaction on the client browser (using javascript) and then broadcast the transaction bytes without ever having to call the NRS API (apart of course to broadcast the transaction).

So I gather that's not possible?

U can do it but u have to build transaction bytes by urself. What types/subtypes of transactions do u need?


Title: Re: [Nxt] API of Nxt
Post by: abuelau on February 20, 2014, 12:51:20 PM
Questions regarding the BroadCastTransaction API:

1) Can I use to it SEND NXT?
2) If I can use it to send Nxt, if the broadcast bytes are intercepted can the attacker figure out the account password from the bytes?
3) Where can I find information on how to use the BroadCastTransaction API (i.e. how to prepare the bytes??)
4) Is there any examples in javascript that show how to prepare the bytes to be sent using BroadCastTransaction?

Many thanks!

1. Yes
2. No
3. I'll add prepareTransaction and sendTransaction to be used for that
4. Bytes r returned by sendMoney, sendMessage, etc.

I was actually trying to figure out if there's a way for me to prepare a transaction on the client browser (using javascript) and then broadcast the transaction bytes without ever having to call the NRS API (apart of course to broadcast the transaction).

So I gather that's not possible?

U can do it but u have to build transaction bytes by urself. What types/subtypes of transactions do u need?

The only one I need right now is SEND NXT.


Title: Re: [Nxt] API of Nxt
Post by: Come-from-Beyond on February 20, 2014, 02:06:48 PM
The only one I need right now is SEND NXT.

All numbers r little-endian.

01 B - type (00)
01 B - subtype (00)
04 B - timestamp (671e7400)
02 B - deadline (3c00)
32 B - sender public key (b1c9e22befa06aee2eb0ac2d13ad03df02abf7cdd5fb8c9903b74f65819eb84d)
08 B - recipient (252ab2f000b58ef7)
04 B - amount (e8030000)
04 B - fee (01000000)
08 B - referenced transaction (0000000000000000)
64 B - signature (a56d7368c792df694c72fcaf731544c4b710c9de4e906105cdb25b15fc10d1052c9fac66383c553 6500cea0782db28535c25095758029cb4d465b13f8850cf1e)

I used transaction 1360173339660761930 as the example (http://localhost:7874/nxt?requestType=getTransactionBytes&transaction=1360173339660761930)

NB: Before signing u must replace signature with ZEROs and sign the whole 128 bytes.


Title: Re: [Nxt] API of Nxt
Post by: abuelau on February 20, 2014, 02:11:46 PM
The only one I need right now is SEND NXT.

All numbers r little-endian.

01 B - type (00)
01 B - subtype (00)
04 B - timestamp (671e7400)
02 B - deadline (3c00)
32 B - sender public key (b1c9e22befa06aee2eb0ac2d13ad03df02abf7cdd5fb8c9903b74f65819eb84d)
08 B - recipient (252ab2f000b58ef7)
04 B - amount (e8030000)
04 B - fee (01000000)
08 B - referenced transaction (0000000000000000)
64 B - signature (a56d7368c792df694c72fcaf731544c4b710c9de4e906105cdb25b15fc10d1052c9fac66383c553 6500cea0782db28535c25095758029cb4d465b13f8850cf1e)

I used transaction 1360173339660761930 as the example (http://localhost:7874/nxt?requestType=getTransactionBytes&transaction=1360173339660761930)

NB: Before signing u must replace signature with ZEROs and sign the whole 128 bytes.

Excellent, thanks.

How do I sign the whole thing (which algo)?


Title: Re: [Nxt] API of Nxt
Post by: Come-from-Beyond on February 20, 2014, 02:12:30 PM
Excellent, thanks.

How do I sign the whole thing (which algo)?

Do u need Java or JavaScript?


Title: Re: [Nxt] API of Nxt
Post by: abuelau on February 20, 2014, 02:26:32 PM
Excellent, thanks.

How do I sign the whole thing (which algo)?

Do u need Java or JavaScript?

Javascript


Title: Re: [Nxt] API of Nxt
Post by: Come-from-Beyond on February 20, 2014, 02:32:47 PM
Javascript

This thread contains links to the code - https://bitcointalk.org/index.php?topic=404321.0


Title: Re: [Nxt] API of Nxt
Post by: marcus03 on February 22, 2014, 08:07:23 PM
Is the broadcastTransaction API call functional?

I've implemented the client-side signing. My transaction verifies successfull against my Curve code, and it is accepted by NRS:

Code:
[2014-02-22 21:03:50.839] DEBUG: Broadcasted new transaction 5198035352813641840

However, the transaction never shows up in my client or in BC Explorer online.



Title: Re: [Nxt] API of Nxt
Post by: Come-from-Beyond on February 22, 2014, 09:02:50 PM
Is the broadcastTransaction API call functional?

I've implemented the client-side signing. My transaction verifies successfull against my Curve code, and it is accepted by NRS:

Code:
[2014-02-22 21:03:50.839] DEBUG: Broadcasted new transaction 5198035352813641840

However, the transaction never shows up in my client or in BC Explorer online.



What r the bytes?


Title: Re: [Nxt] API of Nxt
Post by: marcus03 on February 22, 2014, 09:28:31 PM
Is the broadcastTransaction API call functional?

I've implemented the client-side signing. My transaction verifies successfull against my Curve code, and it is accepted by NRS:

Code:
[2014-02-22 21:03:50.839] DEBUG: Broadcasted new transaction 5198035352813641840

However, the transaction never shows up in my client or in BC Explorer online.



What r the bytes?

Found the problem. The signature bytes were all zero. It now works and I just sent my first client signed transaction. :-)


Title: Re: [Nxt] API of Nxt
Post by: marcus03 on February 23, 2014, 11:57:38 AM
Can you point me to the transaction format for the asset exchange transactions (issueAsset, transferAsset, placeAskOrder, placeBidOrder, cancelAskOrder and cancelBidOrder)?

EDIT: Also, with my own Curve implementation, how do I get the account number for a secret, so that I don't have to use "getAccountId&secretPhrase=..." any longer? Is it an operation on the account's publicKey?

EDIT2: found the answer to my 2nd question. PUBLIC KEY -> SHA256 -> (TAKE LOWER 8 BYTES) -> 64bit Account ID


Still need the asset exchange transaction formats. :-)

EDIT3:

Decompiled the Java code and I got issueAsset to work.

transferAsset transaction in the testnet does not show up in the network. Here's an example:

Asset transfer - From Sender: 13266890203335482459 Recipient: 100000 Asset: 18018524522923576964 Quantity: 2 Fee: 1 Deadline: 1440

Bytes:
020134467800A0055AE68D12CEC8065BED3B2502EDBF41D6FE0C05CD106C8607C637F94FB69E433 DA0860100000000000000000001000000000000000000000053CE6520A8C3B1DD03640106564166 662BD514C1B2B421E3378A56BE9C11BF0DE73E819021C7EDBDA6D391354ECB44F166D90E5914484 3B63BEBA4D288D25C2B844E865D96A80EFA02000000





Title: Re: [Nxt] API of Nxt
Post by: roslinpl on February 23, 2014, 07:56:32 PM
Is the broadcastTransaction API call functional?

I've implemented the client-side signing. My transaction verifies successfull against my Curve code, and it is accepted by NRS:

Code:
[2014-02-22 21:03:50.839] DEBUG: Broadcasted new transaction 5198035352813641840

However, the transaction never shows up in my client or in BC Explorer online.



What r the bytes?

Found the problem. The signature bytes were all zero. It now works and I just sent my first client signed transaction. :-)

solved ! Great!


Title: Re: [Nxt] API of Nxt
Post by: Come-from-Beyond on February 23, 2014, 09:33:20 PM
Bytes:
020134467800A0055AE68D12CEC8065BED3B2502EDBF41D6FE0C05CD106C8607C637F94FB69E433 DA0860100000000000000000001000000000000000000000053CE6520A8C3B1DD03640106564166 662BD514C1B2B421E3378A56BE9C11BF0DE73E819021C7EDBDA6D391354ECB44F166D90E5914484 3B63BEBA4D288D25C2B844E865D96A80EFA02000000



Maybe "Not enough funds" error? What debuging shows?


Title: Re: [Nxt] API of Nxt
Post by: marcus03 on February 23, 2014, 09:42:10 PM
Bytes:
020134467800A0055AE68D12CEC8065BED3B2502EDBF41D6FE0C05CD106C8607C637F94FB69E433 DA0860100000000000000000001000000000000000000000053CE6520A8C3B1DD03640106564166 662BD514C1B2B421E3378A56BE9C11BF0DE73E819021C7EDBDA6D391354ECB44F166D90E5914484 3B63BEBA4D288D25C2B844E865D96A80EFA02000000



Maybe "Not enough funds" error? What debuging shows?

NRS returns a transaction ID, so it's not "Not enough funds".

I can only run this in testnet, so I don't see the debugging output...


Title: Re: [Nxt] API of Nxt
Post by: Come-from-Beyond on February 23, 2014, 10:05:29 PM
NRS returns a transaction ID, so it's not "Not enough funds".

I can only run this in testnet, so I don't see the debugging output...

NRS would return id in any case. Well, let's wait for the update and check again.


Title: Re: [Nxt] API of Nxt
Post by: marcus03 on February 24, 2014, 11:49:35 AM
NRS returns a transaction ID, so it's not "Not enough funds".

I can only run this in testnet, so I don't see the debugging output...

NRS would return id in any case. Well, let's wait for the update and check again.

Got it to work.

The assetID 18018524522923576964 maps to these bytes in the transaction: 844e865d96a80efa

I had to typecast the uInt64 asset ID to int64 to get this hex representation.


Title: Re: [Nxt] API of Nxt
Post by: marcus03 on February 24, 2014, 03:21:55 PM
Bug in 0.8.0e:

http://127.0.0.1:7876/nxt?requestType=getPeer&peer=node45.nxtbase.com

returns:

{"platform":"22k.io","application":"NRS","weight":78879,"hallmark":nxt.peer.Hallmark@1e85e47e,"state":1,"announcedAddress":"node45.nxtbase.com","downloadedVolume":3084,"version":"0.7.6","uploadedVolume":7320}

This is malformatted json, due to the hallmark value.

Edit: Also in 0.8.1.e.


Title: Re: [Nxt] API of Nxt
Post by: Come-from-Beyond on February 24, 2014, 04:31:25 PM
Bug in 0.8.0e:

http://127.0.0.1:7876/nxt?requestType=getPeer&peer=node45.nxtbase.com

returns:

{"platform":"22k.io","application":"NRS","weight":78879,"hallmark":nxt.peer.Hallmark@1e85e47e,"state":1,"announcedAddress":"node45.nxtbase.com","downloadedVolume":3084,"version":"0.7.6","uploadedVolume":7320}

This is malformatted json, due to the hallmark value.

I'm not sure if Jean-Luc reads this thread. U should point him to this bug, coz I don't work on experimental builds.


Title: Re: [Nxt] API of Nxt
Post by: abuelau on February 24, 2014, 10:58:31 PM
Is there a limit on how many accounts can forge on the same NRS using the http://localhost:7876/nxt?requestType=START_OR_STOP&secretPhrase=SECRET?


Title: Re: [Nxt] API of Nxt
Post by: marcus03 on February 26, 2014, 07:41:40 AM
API, Latency and batch mode:

I've been rewriting my client to do client-side signing and connect to a random public node and I am now running into latency problems.

E.g. for showing a detailed list of peers I need to call getPeers and the cycle over all returned peers and call getPeer&peer=PEERNAME.

For long running public nodes like nodeX1.nxtbase.com getPeers returns 1000, 2000 or more peers and my client has to do that many back and fourth requests. This was no problem when running NRS locally, but it is a problem with remote hosts.

This might not be a a huge problem for peers (I could simply drop the peer list in my client), but it will be a problem for getting account transactions, asset trades and asset orders. This will simply not scale.

Proposal:

Offer batch mode API calls, e.g.:

getPeersDetail returning

{"peers":
  [{"shareAddress":true,"platform":"PC","application":"NRS","weight":0,"state":2,"announcedAddress":"199.217.117.152","downloadedVolume":379,"version":"0.7.3","uploadedVolume":12647},
  ...
  ]
}

For peers it might make sense to add a filter option like "state=1" to only get the connected peers.

Similiar batch calls would make sense for getting account transactions, orders and trades, probably together with startIndex/endIndex or startDate/endDate where applicable.


Title: Re: [Nxt] API of Nxt
Post by: opticalcarrier on February 26, 2014, 02:54:39 PM
API, Latency and batch mode:

I've been rewriting my client to do client-side signing and connect to a random public node and I am now running into latency problems.

E.g. for showing a detailed list of peers I need to call getPeers and the cycle over all returned peers and call getPeer&peer=PEERNAME.

For long running public nodes like nodeX1.nxtbase.com getPeers returns 1000, 2000 or more peers and my client has to do that many back and fourth requests. This was no problem when running NRS locally, but it is a problem with remote hosts.

This might not be a a huge problem for peers (I could simply drop the peer list in my client), but it will be a problem for getting account transactions, asset trades and asset orders. This will simply not scale.

Proposal:

Offer batch mode API calls, e.g.:

getPeersDetail returning

{"peers":
  [{"shareAddress":true,"platform":"PC","application":"NRS","weight":0,"state":2,"announcedAddress":"199.217.117.152","downloadedVolume":379,"version":"0.7.3","uploadedVolume":12647},
  ...
  ]
}

For peers it might make sense to add a filter option like "state=1" to only get the connected peers.

Similiar batch calls would make sense for getting account transactions, orders and trades, probably together with startIndex/endIndex or startDate/endDate where applicable.


yes, I concur with the &state=1 modification to the getPeers API.  IF only to support light-clients.


Title: Re: [Nxt] API of Nxt
Post by: marcus03 on February 26, 2014, 04:33:11 PM
yes, I concur with the &state=1 modification to the getPeers API.  IF only to support light-clients.

Well, peers are nice to look at, but not vital. Transactions, orders and trades are.

Just like a new user, I've just added an existing account in my client and retrieving the ~6000 acount transactions for the first time took like 20 minutes... This is not going to fly...

I've tried this with a nextbase node running 0.7.6 and my own remote node on 0.8.2e with roughly the same result. Getting these transactions from a local node takes around 14 seconds.  :o


Title: Re: [Nxt] API of Nxt
Post by: wesleyh on March 01, 2014, 12:15:12 PM
yes, I concur with the &state=1 modification to the getPeers API.  IF only to support light-clients.

Well, peers are nice to look at, but not vital. Transactions, orders and trades are.

Just like a new user, I've just added an existing account in my client and retrieving the ~6000 acount transactions for the first time took like 20 minutes... This is not going to fly...

I've tried this with a nextbase node running 0.7.6 and my own remote node on 0.8.2e with roughly the same result. Getting these transactions from a local node takes around 14 seconds.  :o

Load on demand, you need not get all 6000 transactions at once. Only if the user scrolls to the end of the table, you can fetch new ones. So limit to 100 transactions at start or something. You can also cache transactions with more than > 1440 ?  confirmations.


Title: Re: [Nxt] API of Nxt
Post by: btc2nxt on March 01, 2014, 01:17:20 PM
bug reports

1. assetid= 9458407878065988264 AuroraCoin ( other tester issued this asset)
quantity=90, price=100 (other tester placed this ask order)

2. i place a bid order
quantity=120, price=100

3. left quantity is ok in bid order
quantity=30, price=100

4. cancel this bid order
quantity=30, price=100

5. but ask order show like this
quantity=30, price=100
i think should show noting


btw, i have trouble getting my balance detail, i don't know how many assets matched from api.
if api can return matched quantity and price, get balance detail may be simple.

there are subtype values in asset  api
type =2
subtype=1 issue asset
             2 ask order
             3 bid order
             4 cancel ask order
             5 cancel bid order




Title: Re: [Nxt] API of Nxt
Post by: marcus03 on March 01, 2014, 01:47:13 PM
yes, I concur with the &state=1 modification to the getPeers API.  IF only to support light-clients.

Well, peers are nice to look at, but not vital. Transactions, orders and trades are.

Just like a new user, I've just added an existing account in my client and retrieving the ~6000 acount transactions for the first time took like 20 minutes... This is not going to fly...

I've tried this with a nextbase node running 0.7.6 and my own remote node on 0.8.2e with roughly the same result. Getting these transactions from a local node takes around 14 seconds.  :o

Load on demand, you need not get all 6000 transactions at once. Only if the user scrolls to the end of the table, you can fetch new ones. So limit to 100 transactions at start or something. You can also cache transactions with more than > 1440 ?  confirmations.

I am caching existing transactions with more than 720 confirmations. The problem I described is only with getting transactions for the first time.

The solution you describe is more of a workaround. I would need to define how many transactions to fetch for the user and then use

getAccountTransactionIds&account=<accountid>&timestamp=<timestamp>

with varying timestamps to get roughly as many transactionIDs as I want and then fetch the details for these IDs. There is no order defined in the list of transactionsIDs returned with getAccountTransactionIds, so I can't just fetch the details for the first X transactions.

The timestamp parameter is more for getting new transactions since the last fetch.

Again, this is a workaround and I suggest to look at how all the exchanges implemented their APIs. They make no separation between getting IDs first and then fetching trade/order details, but you simply specify index values and/or timestamp values and receive all details in one batch reply with one call. This does scale nicely.



Title: Re: [Nxt] API of Nxt
Post by: marcus03 on March 01, 2014, 02:14:30 PM
Maybe I am making a false assumption here.

Is there an order defined on the transactionsIDs returned by

getAccountTransactionIds&account=<accountid>&timestamp=<timestamp>

?

If so, always, even with <timestamp>=0?


Title: Re: [Nxt] API of Nxt
Post by: btc2nxt on March 02, 2014, 04:08:42 AM
http://holms.cloudapp.net:6874/nxt?requestType=getAccountTransactionIds&account=1562462127635514638&timestamp=0

i always do with timestamp=0


Title: Re: [Nxt] API of Nxt
Post by: jcrubino on March 02, 2014, 05:38:24 AM
Does a javascript transactions lib exist, ala bitcoinjs?


Title: Re: [Nxt] API of Nxt
Post by: l8orre on March 02, 2014, 03:41:13 PM
hey Guys - I seem to be having an issue with getting proper POST requests to work...

I can connect on localhost, but any remote connect does not work, e.g. on the testnet or on raspi in my local net ...

I know I am missing something obvious here, but as I say, I am a science programmer, and not so much a web programmer

Do I have to use http or https?
 
as far as I understand, the entry '*' in the conf should be enough to connect



#### API SERVER ####

# Accept http/json API requests.
nxt.enableAPIServer=true

# Hosts from which to allow http/json API requests, if enabled.
nxt.allowedBotHosts=*
 
# Port for http/json API requests.
nxt.apiServerPort=7876


In my localnet, I can connect to my raspi at http://192.168.178.24:7876

when I try https I get: requests.exceptions.SSLError: [SSL: UNKNOWN_PROTOCOL] unknown protocol (_ssl.c:548)


when I try testnet, the python just dies - what is different on the testnet???






Title: Re: [Nxt] API of Nxt
Post by: opticalcarrier on March 02, 2014, 04:16:19 PM
you have to specifically enable SSL.  and when you do that, you MUST use SSL.  also when you do that, I believe you MUST EITHER create your own self-signed cert or you must purchase a signed cert.  I dont believe the NRS version  comes with the old 2008 SSL cert it used to come with
  look in wiki howto for guide on certs


Title: Re: [Nxt] API of Nxt
Post by: l8orre on March 02, 2014, 05:13:08 PM
you have to specifically enable SSL.  and when you do that, you MUST use SSL.  also when you do that, I believe you MUST EITHER create your own self-signed cert or you must purchase a signed cert.  I dont believe the NRS version  comes with the old 2008 SSL cert it used to come with
  look in wiki howto for guide on certs

thanks for the hint - I created a cert according to the wiki, but the most pat is for running a node yourself and how to set up NRS to ACCEPT connections.

So now I am trying to get my requests(POST) to use the cert to connect to the testnet - I'll keep trying


sorry guys - I am not getting anywhere. is the testnet API connect running on port 6876?

do I have to use a local cert that I supply in my local nxtClient folder?

 I don't want to clog up the main thread, so I'll try to posting here - maybe some of you other client devs can give me a few hints:
 
Am I correct with assuming that to connect with the testnet, I have to use and port 6876 ? as in my local net it is http://192.168.178.24:7876/ , but what confuses me is that in the local net it is http - surely that is set in the conf file, and a node open to the net will not

use http - but then again I am stuck with the problem of constructing proper POST requests. Does my requests lib have to provide a user cert? There are hooks for that in the lib..

seems most of my issues were related to the testnet  -  debugging can also be often a learning experience - unpleasant, but now pain no gain  ;D


Title: Re: [Nxt] API of Nxt
Post by: opticalcarrier on March 14, 2014, 04:26:32 PM
Do you devs yet have any ideas on the APIs that will be involved in leasing effectiveBalance?  In order to assist with remediation, hopefully there will be something more than just leasing and recalling your effectiveBalance.  From the leasee's perspective, upon generating a block and receiving fees, it will be necessary to determine each individual effectiveBalance it is leasing as of 1440 blocks before the pool's generated block, and to then make sure that each effectiveBalance never went down during the next 1440 blocks.

So Ill propose an API to allow an account to request a list of all accounts leased out to it as of a certain block.  Or if you are feeling generous, with this info, also provide the effectiveBalance of each account at that certain block.  Or possibly even something similar to guaranteedBalance that lists a guaranteedEffectiveBalance of 1440 blocks as of a certain block of all effectiveBalance's that you are leasing.  Now that would be IDEAL


Title: Re: [Nxt] API of Nxt
Post by: rlh on April 24, 2014, 08:53:44 PM
Is this the best place for all information associated with the API?  Is there a better resource for all updates and calls to the API?


Title: Re: [Nxt] API of Nxt
Post by: freigeist on April 25, 2014, 12:21:40 AM
Is this the best place for all information associated with the API?  Is there a better resource for all updates and calls to the API?


Hello.

There is also another thread regarding NXT API.
Check this one:
https://bitcointalk.org/index.php?topic=406839.0

or maybe is better that you go to the nxt forum at
https://nxtforum.org/

Almost all NXT discussion has moved there.




Title: Re: [Nxt] API of Nxt
Post by: rlh on April 25, 2014, 02:38:19 AM
Thank you.  I found the info on the Wiki (doh!)

See here: http://wiki.nxtcrypto.org/wiki/Nxt_API


Title: Re: [Nxt] API of Nxt
Post by: kwilliams on April 29, 2014, 02:08:11 AM
Hey guys, what is the POST equivalent of this call:

curl "http://my-host.com/nxt?requestType=getAccountId&secretPhrase=whatever-is-clever"


I've tried:

curl --data-binary '{"requestType": "getAccountId", "secretPhrase":"whatever-is-clever"}' http://my-host.com/nxt

but it does not work


Title: Re: [Nxt] API of Nxt
Post by: kwilliams on April 29, 2014, 02:13:42 AM
Never mind, found it.It turns out I just had to change the request type to POST, the parameters still travel via URL (this is silly). In case you wonder the full command is:

curl --data-binary '' "http://my-host.com/nxt?requestType=getAccountId&secretPhrase=whatever-is-clever"


Title: Re: [Nxt] API of Nxt
Post by: paradigmflux on August 01, 2014, 03:05:09 PM
ah. I backtraced and found where/how I did a copy/paste error.

ok so the system doesnt prevent you from doing anything dumb.  will this be fixed in the future?

And it really would be useful to see the balance of assets, not just of NXT.

Core doesn't prevent from doing dumb things, client soft is supposed to do it.

I'll add asset balance API.
Was this ever done?


Title: Re: [Nxt] API of Nxt
Post by: ChuckOne on August 01, 2014, 04:20:03 PM
ah. I backtraced and found where/how I did a copy/paste error.

ok so the system doesnt prevent you from doing anything dumb.  will this be fixed in the future?

And it really would be useful to see the balance of assets, not just of NXT.

Core doesn't prevent from doing dumb things, client soft is supposed to do it.

I'll add asset balance API.
Was this ever done?

Go here: http://localhost:7876/test and look for "getAccount".


Title: Re: [Nxt] API of Nxt
Post by: pocesar on September 11, 2014, 06:59:48 AM
I created one, just finishing browser support https://github.com/pocesar/node-nxt-api


Title: Re: [Nxt] API of Nxt
Post by: rriky92 on September 16, 2014, 11:10:12 PM
We need stake holder API (AE)  ;D


Title: Re: [Nxt] API of Nxt
Post by: beitris.dwlul on October 02, 2014, 05:33:55 PM
the blockchain was corrupt  >:(


Title: Re: [Nxt] API of Nxt
Post by: rriky92 on October 03, 2014, 09:19:30 AM
the blockchain was corrupt  >:(

?? When?