Bitcoin Forum
March 26, 2017, 08:41:41 PM *
News: Latest stable version of Bitcoin Core: 0.14.0  [Torrent]. (New!)
 
   Home   Help Search Donate Login Register  
Pages: [1]
  Print  
Author Topic: [ANN][Library][v0.4.0] PyBC Generic Blockchain Library (and coin!)  (Read 6408 times)
interfect
Full Member
***
Offline Offline

Activity: 139


View Profile
July 08, 2013, 07:46:26 AM
 #1

New in 0.4: not locking up while downloading blocks, and much more efficient fork switching.


This new release is compatible with old blockchain data and peers, but not the stored wallet or blockchain files.

To update to 0.4:

Code:
pip install --upgrade --user pybc

If you want to keep your private key(s) from 0.2 or earlier, you can (probably) use this script to import them:
Code:
#!/usr/bin/env python2.7
"""
Script to import a Wallet to the 0.3+ format.

PyBC must be installed in a place where it can be imported.
The old wallet should be named keys.wallet.old.
The new wallet should be named keys.wallet.new.

"""

import shelve
from pybc.sqliteshelf import SQLiteShelf

old_wallet = shelve.open("keys.wallet.old")

new_wallet = SQLiteShelf("keys.wallet.new", table="wallet")

for key, value in old_wallet:
    new_wallet[key] = value
    
old_wallet.close()
new_wallet.close()

What is this?

I've been working on a Python module, PyBC, that implements a peer-to-peer distributed blockchain (as in Bitcoin or any altcoin) with easily definable rules for block validity. On top of this library, I have implemented a (very simple) altcoin: PyBC Coin. To my knowledge, this toy coin is the first altcoin not based on the Bitcoin source (if we don't count Ripple), and the only SHA-512-based altcoin.

The library is available from a couple of places:

PyPI

BitBucket

To play around with PyBC Coin, assuming you have pip and .local/bin is in your PATH, run:

Code:
pip install --user pybc

pybc_cointk blockchain.blocks keys.wallet seen.peers

You can use the GUI to get a base64 receiving address and your current balance, and send and receive (indivisible) coins. If you want to generate blocks, use the --generate option. Specify another peer to connect to with the --peer_host and --peer_port options. The default port is 8008, and can be changed with the --port option. If you specify a host name or IP with the --host option, you will announce yourself to your peers.

The toy currency is currently set to retarget every 10 blocks to a generation rate of a minute per block. The generation reward is 50 indivisible coins forever, and the transaction fee that all the miners charge by default is 1 coin. Naturally, this can all be changed around fairly easily.

Hopefully this library will eventually be useful for the rapid development and prototyping of altcoins. Make your own currency, no compiling needed! It's also intended to be useful for non-currency blockchains.

Does anyone have any design suggestions, or ideas on how to mitigate the fairly obvious opportunities for low-difficulty-block or transaction or peer flooding attacks that the library currently has?

Would anyone be kind enough to run a publicly-accessible pybc_coinserver node for larger-scale testing? If so, please post here. The UI code needs substantial revisions, but what constitutes a valid block is unlikely to change in a backwards-incompatible way, so if you think my test currency is going to be the next Bictoin you can get a head start on mining.

I'm very excited to see the first serious altcoin based on this library. Also, please send BitBucket pull requests; the whole thing is MIT licensed, and contributions are accepted under the same license.

Advertised sites are not endorsed by the Bitcoin Forum. They may be unsafe, untrustworthy, or illegal in your jurisdiction. Advertise here.
1490560901
Hero Member
*
Offline Offline

Posts: 1490560901

View Profile Personal Message (Offline)

Ignore
1490560901
Reply with quote  #2

1490560901
Report to moderator
1490560901
Hero Member
*
Offline Offline

Posts: 1490560901

View Profile Personal Message (Offline)

Ignore
1490560901
Reply with quote  #2

1490560901
Report to moderator
coinerd
Full Member
***
Offline Offline

Activity: 196


View Profile
July 08, 2013, 07:52:33 AM
 #2

...To my knowledge, this toy coin is the first altcoin not based on the Bitcoin source (if we don't count Ripple)...

Depends on your definition of "alt coin".
Snail2
Legendary
*
Offline Offline

Activity: 1134



View Profile
July 08, 2013, 07:56:36 AM
 #3

Wow ! Congratulations! Really nice to see some real innovation Smiley.

freedomno1
Legendary
*
Offline Offline

Activity: 1162


Activity: 9001 == OP


View Profile WWW
July 09, 2013, 07:29:22 AM
 #4

Hmm interesting enough

xchrix
Hero Member
*****
Offline Offline

Activity: 903



View Profile WWW
July 09, 2013, 09:32:36 PM
 #5

very good work! i am excited how far this development will go

www.cryptocoincharts.info - long term charts for 800+ coins like BTC, LTC, NXT, DOGE
www.cryptoassetcharts.info - charts for decentralized assets like NXT AE, XCP, MSC, ...
BTC donations: 1DRVMYRMFafdtXJF1tivwyoR1SF8LDNKWj
Bitrated user: cryptocoinchart.
hanzac
Sr. Member
****
Offline Offline

Activity: 334


View Profile
August 05, 2013, 04:50:12 AM
 #6

Nice software component.
yourofl10
Full Member
***
Offline Offline

Activity: 168


View Profile
August 05, 2013, 04:58:48 AM
 #7

When running the 2nd command, I get:

pybc_coinserver: command not found


EDIT: Just got 50 coins. Cheesy Is it possible to trade them?

yourofl10
Full Member
***
Offline Offline

Activity: 168


View Profile
August 05, 2013, 05:19:11 AM
 #8

100 coins to donate now.  Shocked  Smiley

interfect
Full Member
***
Offline Offline

Activity: 139


View Profile
August 09, 2013, 08:49:40 AM
 #9

Hello all!

I've decided to make this the official thread. I had another thread for 0.2, but that seemed like it could get spammy pretty fast.

Anyway, I have a new version out, 0.3.1, which can actually handle the blockchain of 3,722 blocks that you guys have mined, and download it at a reasonable speed without deadlocking halfway through.

Be sure to use the script in the first post or something similar to upgrade your wallet file to the new corruption-resistant SQLite-based format.

I didn't bother with an upgrader script for stored blockchains; just re-download them from an old-version peer.

Also be aware that pybc_coinserver and pybc_cointk have two new arguments: a required argument for a persistent peer database, and an optional --host argument to enable announcement of an internet-visible host name or address to the network periodically.

Let me know if there are any issues.
interfect
Full Member
***
Offline Offline

Activity: 139


View Profile
August 10, 2013, 08:03:28 AM
 #10

Another new release!

It turns out the way I got the state of the blockchain in the past to verify fork blocks was a huge bottleneck, so I fixed it by adding some caching logic. I've also added some more queuing and deferring to prevent the client from locking up while verifying a batch of downloaded blocks.

Hence 0.4.

There's actually a reasonable 3,843-block blockchain going, on which I will pay 50 coins to anyone who posts their address and is running a client to receive them. Eventually.
interfect
Full Member
***
Offline Offline

Activity: 139


View Profile
August 17, 2013, 08:07:48 PM
 #11

So it turns out when we get to around 10k blocks, the coin system starts to slow down. I suspect it's because it has to copy the State (which includes a list of every unspent output) for every new block, and I'm going to try to change that when I get a chance. In the mean time, try not to need to download the blockchain for the toy coin.
digitalindustry
Hero Member
*****
Offline Offline

Activity: 770


Add meaning to your comparmentalized life.


View Profile WWW
November 02, 2013, 03:02:38 PM
 #12

I'm not a coder, {let me say that first}

but can I ask , why Python ?

is this a "just becasue you can" exercise ?

I like this innovation , but for example does Python provide a say , Security benefit in any manner conceptual, argumentative or abstract ?

and if so , shoot with some or all.


**

I mean for example why not , say assembly language?

these people made an OS http://kolibrios.org/en/

that boots in seconds - with FASM assembly language.

learn about comedy you are a part of it. we are children.
- https://voat.co/v/Contact/    @Kolin_Quark
jago25_98
Hero Member
*****
Offline Offline

Activity: 871


http://moneybutnofixedabode.blogspot.com


View Profile WWW
November 10, 2013, 02:48:26 PM
 #13

I'm not a coder, {let me say that first}

but can I ask , why Python ?

I'm not a coder either.

Here's a good reason - rapid prototyping. Assembly language is a nice example. I had a friend learning assembly at school. Suffice to say... it's very very slow to knock up ideas...
the best way to approach the problem (bear in mind I'm not a programmer) that I've seen in practice is a library call written in a .dll/.so written in assembly where speed is required.

This system is the best development I've seen for cryptocurrencies in a long while. Hopefully multisig can be added - or a way to exchange value through different coins/blockchains? aka - no more exchanges.
digitalindustry
Hero Member
*****
Offline Offline

Activity: 770


Add meaning to your comparmentalized life.


View Profile WWW
November 10, 2013, 03:45:29 PM
 #14

I'm not a coder, {let me say that first}

but can I ask , why Python ?

I'm not a coder either.

Here's a good reason - rapid prototyping. Assembly language is a nice example. I had a friend learning assembly at school. Suffice to say... it's very very slow to knock up ideas...
the best way to approach the problem (bear in mind I'm not a programmer) that I've seen in practice is a library call written in a .dll/.so written in assembly where speed is required.

This system is the best development I've seen for cryptocurrencies in a long while. Hopefully multisig can be added - or a way to exchange value through different coins/blockchains? aka - no more exchanges.

Im right there with you , any multisig or " atomic exchange" is great,  innovation is great, but does Python provide a effective advantage over C++ ?

I understand , I think , that assembly is more work for superior results , but , dam did you see that OS boot ?

Im not saying use this , I was just trying to make a point , or ask a question .

learn about comedy you are a part of it. we are children.
- https://voat.co/v/Contact/    @Kolin_Quark
jago25_98
Hero Member
*****
Offline Offline

Activity: 871


http://moneybutnofixedabode.blogspot.com


View Profile WWW
November 10, 2013, 07:41:08 PM
 #15


Im right there with you , any multisig or " atomic exchange" is great,  innovation is great, but does Python provide a effective advantage over C++ ?

I understand , I think , that assembly is more work for superior results , but , dam did you see that OS boot ?

Im not saying use this , I was just trying to make a point , or ask a question .

I've heard c++ tends to be quicker but you know...
 I don't really see it that much personally. Computers are pretty quick anyway these days. Google for compiled python program vs c++ speed?

 Python is a very nice language, I know that much. By balance it is the most in use of these more readble \"higher level"? languages. The most established of these. You have many libraries at your fingertips. Electrum is coded in python, so easy to install cross platform with pip. Gentoo linux is python.

 I did a quick search:
http://blog.udacity.com/2012/05/learning-to-program-why-python.html
Quote
Language Interoperability, Documentation System, Hierarchical Module System, Available Libraries, Testing Framework, Readability,

 It's a language that has often motivated me to try to learn how to program but even this wasn't enough to get me past my stupidity.
Pages: [1]
  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!