Bitcoin Forum

Bitcoin => Development & Technical Discussion => Topic started by: hi-entropy on August 18, 2013, 03:46:48 AM



Title: Bitcoin nanopayments library in Node
Post by: hi-entropy on August 18, 2013, 03:46:48 AM
I'm working on a probabilistic nanopayments library in Node: https://github.com/hi-entropy/bitcoin-nanopayment

It's an implementation of jevon's idea from this thread: https://bitcointalk.org/index.php?topic=62558.0

It's still very much alpha-stage, but it should be usable if anyone wants to start developing applications that make use of nanopayments.  I would love any feedback on documentation clarity, bugs, feature requests, or anything else about it!  So, yeah... have at it!  :D


Title: Re: Bitcoin nanopayments library in Node
Post by: jgarzik on August 19, 2013, 12:23:37 PM
FYI,
https://github.com/gasteve/node-base58
https://github.com/gasteve/node-libcoin

Should be no need to create/duplicate base58 or bitcoin code, in node.js applications.



Title: Re: Bitcoin nanopayments library in Node
Post by: TierNolan on August 19, 2013, 04:40:45 PM
It's still very much alpha-stage, but it should be usable if anyone wants to start developing applications that make use of nanopayments.  I would love any feedback on documentation clarity, bugs, feature requests, or anything else about it!  So, yeah... have at it!  :D

According to the thread, the same functionality can be achieved using the micro-payment channels system?

Apparently not, that refers to the OP's version.

So,

Bob creates a transaction that pays 0.01 BTC from himself to <public key> which has a hash of H.

Bob says to Alice "Create a transaction which pays 1 BTC to me and is paid from <tx-hash> output 0" and also signs it with "anyone can pay".   <tx-hash> can be any in the range from S to S + N, when S = H - rand(N).

With "anyone can pay", Alice can add extra inputs without invalidating Bob's signature, but she can't change the output (sending the money to Bob).

Alice sends the transaction to Bob.

If <tx-hash> matches, then Bob can submit both his transactions to the network.

The risk is that Alice will submit a transaction spending the input at the same time she sends the transaction to Bob.  However, she doesn't know which of the 1000 transactions is the valid one.

Cost to double spend: f (since you have to pay the BTC fee to add the transaction in the block-chain)
Benefit of double spend: V / N (since that is the expected loss of not double spending)

As long as f > V / N, then it isn't worth double spending.  The means that N has to increase as the value goes up.  Ironically, the transaction fee makes this service useful and also adds to its security.

That's pretty cool.


Title: Re: Bitcoin nanopayments library in Node
Post by: hi-entropy on August 21, 2013, 04:39:28 AM
Hi Jeff, thanks for taking a look!  I will definitely switch to use those libraries; they look much better than the current solution that I have shitpatched together.


Title: Re: Bitcoin nanopayments library in Node
Post by: Mike Hearn on August 21, 2013, 05:29:02 PM
Very interesting work and neat protocol, congrats.


Title: Re: Bitcoin nanopayments library in Node
Post by: hi-entropy on August 22, 2013, 01:16:10 AM
Thanks Mike! Jevon and Casascius pretty much came up with the protocol, I just implemented it. I'll take credit for that though! ;)