Bitcoin Forum
December 11, 2017, 06:03:27 PM *
News: Latest stable version of Bitcoin Core: 0.15.1  [Torrent].
 
   Home   Help Search Donate Login Register  
Pages: « 1 2 3 4 5 6 7 8 9 10 11 12 13 [14] 15 16 17 18 19 20 »  All
  Print  
Author Topic: [Nxt] API of Nxt  (Read 36773 times)
Come-from-Beyond
Legendary
*
Offline Offline

Activity: 1792

Newbie


View Profile
January 18, 2014, 11:55:47 AM
 #261


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?    Huh 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.
Advertised sites are not endorsed by the Bitcoin Forum. They may be unsafe, untrustworthy, or illegal in your jurisdiction. Advertise here.
1513015407
Hero Member
*
Offline Offline

Posts: 1513015407

View Profile Personal Message (Offline)

Ignore
1513015407
Reply with quote  #2

1513015407
Report to moderator
1513015407
Hero Member
*
Offline Offline

Posts: 1513015407

View Profile Personal Message (Offline)

Ignore
1513015407
Reply with quote  #2

1513015407
Report to moderator
l8orre
Legendary
*
Offline Offline

Activity: 928


View Profile
January 18, 2014, 01:10:58 PM
 #262



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.  Shocked
Thanks!
opticalcarrier
Full Member
***
Offline Offline

Activity: 238



View Profile
January 21, 2014, 08:55:03 PM
 #263

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
Come-from-Beyond
Legendary
*
Offline Offline

Activity: 1792

Newbie


View Profile
January 21, 2014, 09:06:24 PM
 #264

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"}
opticalcarrier
Full Member
***
Offline Offline

Activity: 238



View Profile
January 21, 2014, 11:54:21 PM
 #265

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.
Come-from-Beyond
Legendary
*
Offline Offline

Activity: 1792

Newbie


View Profile
January 22, 2014, 06:33:02 AM
 #266

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.
l8orre
Legendary
*
Offline Offline

Activity: 928


View Profile
January 22, 2014, 09:08:44 AM
 #267


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 ...
 



l8orre
Legendary
*
Offline Offline

Activity: 928


View Profile
January 22, 2014, 09:24:50 AM
 #268


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.  Huh  Shocked

Please enter coments and discussion here !
Come-from-Beyond
Legendary
*
Offline Offline

Activity: 1792

Newbie


View Profile
January 22, 2014, 09:44:15 AM
 #269


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.  Huh  Shocked

Please enter coments and discussion here !

Matching engine is launched each time someone places an order.
l8orre
Legendary
*
Offline Offline

Activity: 928


View Profile
January 22, 2014, 09:50:56 AM
 #270


mwoa.. what are the matching engine rules? how does it work? now I am getting really curious and excited! 
Come-from-Beyond
Legendary
*
Offline Offline

Activity: 1792

Newbie


View Profile
January 22, 2014, 09:53:34 AM
 #271


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);

        }

    }
l8orre
Legendary
*
Offline Offline

Activity: 928


View Profile
January 22, 2014, 10:21:23 AM
 #272


Thanks!
l8orre
Legendary
*
Offline Offline

Activity: 928


View Profile
January 22, 2014, 10:36:22 AM
 #273


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?

Come-from-Beyond
Legendary
*
Offline Offline

Activity: 1792

Newbie


View Profile
January 22, 2014, 10:37:37 AM
 #274


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.
opticalcarrier
Full Member
***
Offline Offline

Activity: 238



View Profile
January 22, 2014, 02:33:29 PM
 #275

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?
Come-from-Beyond
Legendary
*
Offline Offline

Activity: 1792

Newbie


View Profile
January 22, 2014, 04:36:46 PM
 #276

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.
opticalcarrier
Full Member
***
Offline Offline

Activity: 238



View Profile
January 22, 2014, 04:50:37 PM
 #277

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
abuelau
Hero Member
*****
Offline Offline

Activity: 686


www.coinschedule.com


View Profile
January 23, 2014, 07:58:34 PM
 #278

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"?

Know what's happening in cryptoworld: www.coinschedule.com
btc2nxt
Full Member
***
Offline Offline

Activity: 231


View Profile
January 24, 2014, 03:52:33 AM
 #279

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
l8orre
Legendary
*
Offline Offline

Activity: 928


View Profile
January 24, 2014, 08:39:08 AM
 #280

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

Pages: « 1 2 3 4 5 6 7 8 9 10 11 12 13 [14] 15 16 17 18 19 20 »  All
  Print  
 
Jump to:  

Sponsored by , a Bitcoin-accepting VPN.
Powered by MySQL Powered by PHP Powered by SMF 1.1.19 | SMF © 2006-2009, Simple Machines Valid XHTML 1.0! Valid CSS!