Bitcoin Forum

Bitcoin => Project Development => Topic started by: mocacinno on November 05, 2018, 01:57:07 PM



Title: websocket node access: gauging intrest
Post by: mocacinno on November 05, 2018, 01:57:07 PM
I'm currently developing websocket access to some of the functions of my full node. For a small fee, a developer, site owner or private person could use a secure websocket connection to execute most of the not-wallet-related node functions. This way, he or she get access to some core functionality without having to maintain a full node, he or she can even use javascript to include functionality on webpages on very limited shared hosting formulas.

In the beginning, i was thinking about creating such a websocket daemon for private use and throw away most of the outdated code on mocacinno.com and use a websocket connection instead... However, i tought by myself: maybe somebody else would be interested in such a websocket connection to?

Without further comments, here's a dev console view of the initial test of my websocket daemon... Be advised, only a very small part of the functionality i want to include is currently included:

https://193.70.78.148:9090/node

You'll need a private key in order to complete the handshake and testdrive the websocket... If you're interested in testing it out, send me a PM and i'll give you a testkey :)
I've modified my code for now, anybody connected is now automatically authenticated for the time being :)

Currently implemented
Authentication to the websocket:
  • Starting the authentication process
  • Completing the authentication process
  • Querying the authentication status

Blockchain queries:
  • Query the current best block hash
  • Find a block using a blockhash
  • Get the latest block
  • Get blockchain info
  • Get the current block count
  • Query the blockhash for height x

Todo
Blockchain queries:
  • get getblockheader for blockhash
  • get chaintxstats
  • get current difficulty
  • get all the mempool info for a certain tx (ancestors, descendants, entry)
  • list all tx's in the mempool

Mining:
  • get block template (for whatever you'd use it)
  • get mining info
  • get network hash ps
  • submit block

Network:
  • get connection count
  • get net totals
  • get network info

Raw transactions:
  • decode raw transaction
  • decode script
  • get raw transaction
  • send raw transaction

Util:
  • estimate fee
  • estimate smart fee
  • validate address
  • verify message

Custom:
  • analyse unconfirmed transaction
  • Have a timestamped message signed by me (an independant partie)
  • Calculate optimal fee at this point in time


Title: Re: websocket node access: gauging intrest
Post by: Kouiao on November 05, 2018, 03:06:43 PM
What stack are your WS implementation ? Do you need help with development ?


Title: Re: websocket node access: gauging intrest
Post by: mocacinno on November 06, 2018, 07:46:34 AM
What stack are your WS implementation ? Do you need help with development ?

I'm actually using websocketd (http://websocketd.com/), so the language of the script itself doesn't really matter ;)
Thanks for your offer to help with the development, but at the moment i can handle it... I'm just gauging intrest to see if i'll only develop the functions i need for myself or if i need to develop the full range of functions.



Title: Re: websocket node access: gauging intrest
Post by: HeRetiK on November 06, 2018, 09:51:49 AM
For more complex projects I'd probably run a node myself, but I'll still keep an eye on this thread to see how it evolves.

FYI:

Code:
{"method": "getlatestblock"}

returns invalid JSON  :-X

Code:
{u'merkleroot': u'ae60086ad3d9d53c3213a271c1117449f77f70d89ff7536beb194b5009a12543', u'nonce': 1580982470, [...]

(eg. u'merkleroot' should be "merkleroot")


Title: Re: websocket node access: gauging intrest
Post by: mocacinno on November 06, 2018, 09:56:00 AM
For more complex projects I'd probably run a node myself, but I'll still keep an eye on this thread to see how it evolves.

FYI:

Code:
{"method": "getlatestblock"}

returns invalid JSON  :-X

Code:
{u'merkleroot': u'ae60086ad3d9d53c3213a271c1117449f77f70d89ff7536beb194b5009a12543', u'nonce': 1580982470, [...]

(eg. u'merkleroot' should be "merkleroot")

Thanks for notifying me... It's indeed an invalid json, i'll fix it tomorrow morning :)

EDIT: had some time, fixed it right away! Thanks for the heads up!
BTW: it's perfectly normal to use your own node, even for smaller projects. As a matter of fact, i'd encourage anybody to use their own node. Using my service requires trust... I could easily modify the respons i send to any query, my node can lag, my node can be the victim of an attack...
That being said: i don't offer wallet services, you can't create desposit addresses, sign transactions,... By keeping these sensitive services away, i kind of mitigate the problem (afaik).

This service is just an easy sollution for anybody who wants medium-complex core functions without running core, probably even from a shared server without any functionality (you can create static pages and use javascript to communicate with an open socket, thus add dynamic functionality without any server side scripts).