Bitcoin Forum

Bitcoin => Project Development => Topic started by: keverw on June 24, 2012, 12:24:52 PM



Title: Port client to node.js?
Post by: keverw on June 24, 2012, 12:24:52 PM
Hey. I was wondering if anyone would be interested in porting the client in to node.js, and have a really nice simple rest api. Not sure how long something like this could take, also it could store multiple wallets. Like in requests, you could be like wallet=walletname. obviously this client would want to run on a local network, with a firewall and not port forwarded. Also a way to confirm the small 0.005 tx fees. like you would do wallet=Kevin&pay=ADDRESS&amount=0.01

and it would then reply with a json object, saying a fee, the app using the API would then decide to pay it and do wallet=Kevin&pay=ADDRESS&amount=0.01&allowfee=0.005

Just an idea. Would something like this be valuable to the community? I myself, would like to see this project happen. But I wouldn't want to go about it alone, and this client would be open source also.


Title: Re: Port client to node.js?
Post by: Stephen Gornick on June 24, 2012, 09:44:31 PM
Here's a project that appears to have stalled:

 - https://github.com/gasteve/node-bitcoin-p2p


Title: Re: Port client to node.js?
Post by: keverw on June 24, 2012, 11:53:00 PM
Here's a project that appears to have stalled:

 - https://github.com/gasteve/node-bitcoin-p2p


Looks like it uses it's own DB, I would prefer the one I have an idea for to use the same database files as the QT wallet. Just copy in to a dir and it would work. Might be worth trying to fork and updating.


Title: Re: Port client to node.js?
Post by: Red Emerald on June 25, 2012, 04:14:58 AM
Here's a project that appears to have stalled:

 - https://github.com/gasteve/node-bitcoin-p2p


Looks like it uses it's own DB, I would prefer the one I have an idea for to use the same database files as the QT wallet. Just copy in to a dir and it would work. Might be worth trying to fork and updating.
I don't think there is a BDB adapter for JS, so this would likely be a large undertaking.


Title: Re: Port client to node.js?
Post by: keverw on June 25, 2012, 04:56:19 AM
Here's a project that appears to have stalled:

 - https://github.com/gasteve/node-bitcoin-p2p


Looks like it uses it's own DB, I would prefer the one I have an idea for to use the same database files as the QT wallet. Just copy in to a dir and it would work. Might be worth trying to fork and updating.
I don't think there is a BDB adapter for JS, so this would likely be a large undertaking.

Not sure. Googled it. Would https://github.com/mcavage/node-bdb, be it?


Title: Re: Port client to node.js?
Post by: Andrew Vorobyov on June 25, 2012, 05:58:55 AM
http://bitcoinjs.org/


Title: Re: Port client to node.js?
Post by: Red Emerald on June 25, 2012, 04:38:30 PM
Here's a project that appears to have stalled:

 - https://github.com/gasteve/node-bitcoin-p2p


Looks like it uses it's own DB, I would prefer the one I have an idea for to use the same database files as the QT wallet. Just copy in to a dir and it would work. Might be worth trying to fork and updating.
I don't think there is a BDB adapter for JS, so this would likely be a large undertaking.

Not sure. Googled it. Would https://github.com/mcavage/node-bdb, be it?
I stand corrected.  However that adapter hasn't been worked on in a year it looks like there is still more to work on.

Quote
However, there are a few important notes to be aware of with the node environment; since node is written to abstract away concurrency from you, and BDB is written to assume you have complete control over your concurrency model, there are some complications:

Since environment/database open/close can only be done by one thread of control, these bindings don't have an asynchronous open/close. Best practice is to open everything at startup time (e.g., before you do a listen()).
Transactions can't be active in more than one thread at a time. That pretty much screws the pooch for node, unless I did something like what the erlang driver does, and maintain a thread pool that "routes" any request involving a transaction to the same thread. Possible, but that's going to bring a lot of context switches, and I would need a compelling reason to add in all that complexity. For now, all operations in DB are protected by a transaction (assuming you opened the DB transactionally), and I plan on adding a conditionalUpdate API in the near future.
Because of transactional complications, there is not yet cursor support. This is on my list to add with something like an EventEmitter.

http://bitcoinjs.org/

Maybe you could use node-bdb to import the wallet.dat into the wallet format that bitcoinjs uses.  Then the concurrency issues won't be a problem since you are only reading from the satoshi wallet.



Title: Re: Port client to node.js?
Post by: keverw on June 25, 2012, 05:31:25 PM
hmm. Yeah. I was thinking more of a way to "jumpstart" the block database, just copy the block chain and go. That's why I was thinking same format, but importing would work also I guess.

http://bitcoinjs.org/

That looks promising. Might give it a try when my project is in the stage where I need to add a wallet. Still working on getting the basics out of the way.