grondilu (OP)
Legendary
Offline
Activity: 1288
Merit: 1080
|
![](https://bitcointalk.org/Themes/custom1/images/post/xx.gif) |
December 26, 2010, 12:38:42 PM Last edit: December 28, 2010, 07:17:45 AM by grondilu |
|
The thread http://bitcointalk.org/index.php?topic=2459.0make me feel like suggesting a full shell implementation of bitcoin. I've actually been thinking about this for some time but I'd like to see if other people would be interested in such a crazy project. Here is the kind of architecture I'd like to see : - nodes communicate transactions via IRC, XMPP or similar (a shell script communicating with such a protocol should be easy to implement) ; - each node publishes its blocks via its own http server (possibly via a TOR hidden service to avoid NAT traversal problems) ; - each node also publishes the list of nodes it is currently connected to ; - nodes store their blocks using GnuNet or maybe a NoSQL database such as MongoDB (easily scripted) ; - cryptographic functions are performed via the openssl command line ; - blocks and wallets are stored in an human readable ASCII format ;
|
|
|
|
BioMike
Legendary
Offline
Activity: 1658
Merit: 1001
|
![](https://bitcointalk.org/Themes/custom1/images/post/xx.gif) |
December 27, 2010, 03:10:28 PM |
|
That would be one big dependency hell...
|
|
|
|
MoonShadow
Legendary
Offline
Activity: 1708
Merit: 1010
|
![](https://bitcointalk.org/Themes/custom1/images/post/xx.gif) |
December 27, 2010, 03:16:58 PM |
|
At least it would be trivial to have small CL tools to perform bitcoin operations in this system, such as tools to import and export transactions, blocks and keypairs to/from normal files. *nix CL shells, such as Bash, are centered around the manipulation of data streams as files, and it's an incredibly powerful model.
|
"The powers of financial capitalism had another far-reaching aim, nothing less than to create a world system of financial control in private hands able to dominate the political system of each country and the economy of the world as a whole. This system was to be controlled in a feudalist fashion by the central banks of the world acting in concert, by secret agreements arrived at in frequent meetings and conferences. The apex of the systems was to be the Bank for International Settlements in Basel, Switzerland, a private bank owned and controlled by the world's central banks which were themselves private corporations. Each central bank...sought to dominate its government by its ability to control Treasury loans, to manipulate foreign exchanges, to influence the level of economic activity in the country, and to influence cooperative politicians by subsequent economic rewards in the business world."
- Carroll Quigley, CFR member, mentor to Bill Clinton, from 'Tragedy And Hope'
|
|
|
grondilu (OP)
Legendary
Offline
Activity: 1288
Merit: 1080
|
![](https://bitcointalk.org/Themes/custom1/images/post/xx.gif) |
December 27, 2010, 09:34:55 PM |
|
At least it would be trivial to have small CL tools to perform bitcoin operations in this system, such as tools to import and export transactions, blocks and keypairs to/from normal files. *nix CL shells, such as Bash, are centered around the manipulation of data streams as files, and it's an incredibly powerful model.
Exactly. I also wonder if all communications could not be done using HTTP. Blocks would be published via http GET method (giving the hash of the preceding block), and transactions could be sent via POST method. One advantage of using http would be that it would be very hard for governments to forbid.
|
|
|
|
jgarzik
Legendary
Offline
Activity: 1596
Merit: 1099
|
![](https://bitcointalk.org/Themes/custom1/images/post/xx.gif) |
December 27, 2010, 10:35:14 PM |
|
Shell script would be fine for a connect-work-disconnect method of working.
But it is grossly ineffective for maintaining a long-running P2P network node, where long-lasting TCP connections are preferred.
|
Jeff Garzik, Bloq CEO, former bitcoin core dev team; opinions are my own. Visit bloq.com / metronome.io Donations / tip jar: 1BrufViLKnSWtuWGkryPsKsxonV2NQ7Tcj
|
|
|
bitcoinex
|
![](https://bitcointalk.org/Themes/custom1/images/post/xx.gif) |
December 28, 2010, 03:04:15 AM |
|
also, Kademlia network works fine without kickstarters and other things like this
|
New bitcoin lottery: probiwon.com- Moжeт, ты eщё и в Heвидимyю Pyкy Pынкa вepyeшь? - Зaчeм жe вepoвaть в тo, чтo мoжнo нaблюдaть нeпocpeдcтвeннo?
|
|
|
jgarzik
Legendary
Offline
Activity: 1596
Merit: 1099
|
![](https://bitcointalk.org/Themes/custom1/images/post/xx.gif) |
December 28, 2010, 04:30:38 AM |
|
also, Kademlia network works fine without kickstarters and other things like this
Do you mean bootstrapping? Kademlia network needs bootstrapping, just like other P2P networks.
|
Jeff Garzik, Bloq CEO, former bitcoin core dev team; opinions are my own. Visit bloq.com / metronome.io Donations / tip jar: 1BrufViLKnSWtuWGkryPsKsxonV2NQ7Tcj
|
|
|
MoonShadow
Legendary
Offline
Activity: 1708
Merit: 1010
|
![](https://bitcointalk.org/Themes/custom1/images/post/xx.gif) |
December 28, 2010, 04:32:26 AM |
|
Shell script would be fine for a connect-work-disconnect method of working.
There is a growing demand for a client that can function disconnected from the Internet. This might be a step in this direction.
|
"The powers of financial capitalism had another far-reaching aim, nothing less than to create a world system of financial control in private hands able to dominate the political system of each country and the economy of the world as a whole. This system was to be controlled in a feudalist fashion by the central banks of the world acting in concert, by secret agreements arrived at in frequent meetings and conferences. The apex of the systems was to be the Bank for International Settlements in Basel, Switzerland, a private bank owned and controlled by the world's central banks which were themselves private corporations. Each central bank...sought to dominate its government by its ability to control Treasury loans, to manipulate foreign exchanges, to influence the level of economic activity in the country, and to influence cooperative politicians by subsequent economic rewards in the business world."
- Carroll Quigley, CFR member, mentor to Bill Clinton, from 'Tragedy And Hope'
|
|
|
pj
Newbie
Offline
Activity: 24
Merit: 0
|
![](https://bitcointalk.org/Themes/custom1/images/post/xx.gif) |
December 28, 2010, 11:49:39 AM |
|
Shell script would be fine for a connect-work-disconnect method of working.
But it is grossly ineffective for maintaining a long-running P2P network node, where long-lasting TCP connections are preferred.
One could work around that inefficiency in at least a couple of ways: 1) Background a task that has a file descriptor open back to the active shell, that can manipulate and communicate with sockets, or 2) Use a shell that provides this builtin, such as the net/socket module in zsh as described at http://www.cims.nyu.edu/cgi-systems/info2html?%28zsh%29The%2520zsh%2Fnet%2Fsocket%2520Module
|
|
|
|
davout
Legendary
Offline
Activity: 1372
Merit: 1007
1davout
|
![](https://bitcointalk.org/Themes/custom1/images/post/xx.gif) |
December 28, 2010, 12:40:26 PM |
|
Could anyone educate me about the interest of coding a bitcoin client in shell script ? (protip : "just for fun" is a valid answer:) )
|
|
|
|
pj
Newbie
Offline
Activity: 24
Merit: 0
|
![](https://bitcointalk.org/Themes/custom1/images/post/xx.gif) |
December 28, 2010, 12:50:11 PM |
|
Could anyone educate me about the interest of coding a bitcoin client in shell script ? (protip : "just for fun" is a valid answer:) )
Someone else asked the question, so I can just guess from what they said. My guess is that the interest is not so much in coding the guts of the client in shell script (not exactly a high performance engine for computationally intensive tasks), but rather in exposing the data flows and stores to shell script manipulation. In other words, as I have often done myself in other tasks, write several tools that each have specific capabilities, and which have interfaces that work well when combined in shell scripts with each other and other *nix utilities. One shot commands are handled in that environment by forking/execing a command that is passed command line arguments, environment variables and files or file descriptors to read or write. Higher performance for repetitive tasks is obtained by using commands in a series of filters, operating on a stream of line oriented text. The new, individual tools would each be written in C or Python or some other such language that provided adequate performance and library support for their particular purpose.
|
|
|
|
grondilu (OP)
Legendary
Offline
Activity: 1288
Merit: 1080
|
![](https://bitcointalk.org/Themes/custom1/images/post/xx.gif) |
January 06, 2011, 02:16:42 AM |
|
I'm trying to implement the base58 functions. I'm almost there but I have difficulties with the checksum. #!/bin/bash
base58=({1..9} {A..H} {J..N} {P..Z} {a..k} {m..z})
EncodeBase58() { # 58 =0x3A bc <<<"ibase=16; n=${1^^}; while(n>0) { n%3A ; n/=3A }" | tac | while read n do echo -n ${base58[n]} done }
Hash160ToAddress() { ADDRESSVERSION=00 EncodeBase58 "${ADDRESSVERSION}$1$(Checksum "$1")" }
Checksum() { xxd -p -r <<<"$1" | openssl dgst -sha256 -binary | openssl dgst -sha256 -hex | cut -d\ -f2 | sed -r "s/^.*((..){4})/\1/" }
Hash160() { echo -n "$1" | openssl dgst -sha256 -binary | openssl dgst -rmd160 -hex | cut -d\ -f2 }
H=0057b0dc5aac7c215a9a458d6c3c85cd21089af8 Hash160ToAddress $H # I should get 112p3sLidyEptFEfx3C2RCvFoRPK89HyBT # I actually get 2p3sLidyEptFEfx3C2RCvFoRPK7JQWdq
|
|
|
|
grondilu (OP)
Legendary
Offline
Activity: 1288
Merit: 1080
|
![](https://bitcointalk.org/Themes/custom1/images/post/xx.gif) |
January 06, 2011, 02:52:51 AM Last edit: January 06, 2011, 03:17:44 AM by grondilu |
|
Yes ! It works ![Cheesy](https://bitcointalk.org/Smileys/default/cheesy.gif) #!/bin/bash # # Requires bc, openssl, xxd #
base58=({1..9} {A..H} {J..N} {P..Z} {a..k} {m..z})
EncodeBase58() { # 58 =0x3A bc <<<"ibase=16; n=${1^^}; while(n>0) { n%3A ; n/=3A }" | tac | while read n do echo -n ${base58[n]} done }
Hash160ToAddress() { printf %34s $(EncodeBase58 "00$1$(checksum "00$1")")| sed "s/ /1/g" }
checksum() { xxd -p -r <<<"$1" | openssl dgst -sha256 -binary | openssl dgst -sha256 -hex | cut -d\ -f2 | sed -r "s/^((..){4}).*/\1/" }
Hash160() { openssl dgst -sha256 -binary | openssl dgst -rmd160 -hex | cut -d\ -f2 }
PubKeyToAdress() { Hash160ToAddress $(tail -c 65 |Hash160) ; }
|
|
|
|
davux
|
![](https://bitcointalk.org/Themes/custom1/images/post/xx.gif) |
January 06, 2011, 05:16:48 PM |
|
I like the idea: having a series of small tools that do one task, do it well, and can work together through stdin/stdout, the filesystem, sockets, etc.
I'd start off with strict sh compatibility, though, not bash, unless there's really a big advantage of requiring bash over lighter posix-compliant sh implementations (e.g. dash).
|
1DavuxH9tLqU4c7zvG387aTG4mA7BcRpp2 México (Oaxaca) – France - Leeds
|
|
|
grondilu (OP)
Legendary
Offline
Activity: 1288
Merit: 1080
|
![](https://bitcointalk.org/Themes/custom1/images/post/xx.gif) |
January 06, 2011, 05:47:09 PM |
|
I'd start off with strict sh compatibility, though, not bash, unless there's really a big advantage of requiring bash over lighter posix-compliant sh implementations (e.g. dash).
Writing in POSIX is much less fun. To me GNU is a better standard de facto. Also, what's the point of those excellent GNU tools if we can never use them ?
|
|
|
|
mikegogulski
|
![](https://bitcointalk.org/Themes/custom1/images/post/xx.gif) |
January 06, 2011, 07:39:31 PM |
|
I'd start off with strict sh compatibility, though, not bash, unless there's really a big advantage of requiring bash over lighter posix-compliant sh implementations (e.g. dash).
Not that I've got any skin in this game, but it would be worth considering targeting the more limited toolset offered by Busybox: http://busybox.net/The profusion of embedded linux devices these days means Busybox is everywhere.
|
|
|
|
grondilu (OP)
Legendary
Offline
Activity: 1288
Merit: 1080
|
![](https://bitcointalk.org/Themes/custom1/images/post/xx.gif) |
January 07, 2011, 04:20:10 AM Last edit: January 07, 2011, 05:36:17 PM by grondilu |
|
I've added two functions : decodeBase68 and checkBitcoinAddress. I think it might be usefull to check the validity of a bitcoin address in pure bash. Requires "dc", the unix desk calculator. Few people use this reverse polish notation calcultor but it's much easier to handle in scripts. #!/bin/bash # # Requires bc, dc, openssl, xxd #
base58=({1..9} {A..H} {J..N} {P..Z} {a..k} {m..z}) bitcoinregex="^[$(printf "%s" "${base58[@]}")]{34}$"
decodeBase58() { s=$1 for i in {0..57} do s="${s//${base58[i]}/ $i}" done dc <<< "16o0d${s// /+58*}+f" }
encodeBase58() { # 58 =0x3A bc <<<"ibase=16; n=${1^^}; while(n>0) { n%3A ; n/=3A }" | tac | while read n do echo -n ${base58[n]} done }
checksum() { xxd -p -r <<<"$1" | openssl dgst -sha256 -binary | openssl dgst -sha256 -hex | sed 's/^.* //' | head -c 8 }
checkBitcoinAddress() { if [[ "$1" =~ $bitcoinregex ]] then h=$(decodeBase58 "$1") checksum "00${h::${#h}-8}" | grep -qi "^${h: -8}$" else return 2 fi }
hash160() { openssl dgst -sha256 -binary | openssl dgst -rmd160 -hex | sed 's/^.* //' }
hash160ToAddress() { printf %34s "$(encodeBase58 "00$1$(checksum "00$1")")" | sed "y/ /1/" }
publicKeyToAddress() { hash160ToAddress $( openssl ec -pubin -pubout -outform DER 2>/dev/null | tail -c 65 | hash160 ) }
|
|
|
|
grondilu (OP)
Legendary
Offline
Activity: 1288
Merit: 1080
|
![](https://bitcointalk.org/Themes/custom1/images/post/xx.gif) |
January 15, 2011, 01:51:54 PM Last edit: January 15, 2011, 02:03:08 PM by grondilu |
|
I have modified dirtyfilthy's program so that it can export the whole wallet in an ascii format. http://github.com/grondilu/bc_keyJust use "ALL" instead of a particular bitcoin address. Be careful with this command, for it shows all your private keys in clear ! In particular, you should never redirect the output of this program to a file. Unless you use an encrypted file system. Anyway, I'll add a few bash functions that can be used to create a new address, sign a transaction, and so on... Here is a function to create a new address already : #!/bin/bash
. base58.sh
wallet="$HOME/.bitcoin-bash/wallet.dat"
generateNewAddress() {
privkey="$(openssl ecparam -name secp256k1 -genkey)"
openssl ec -pubout <<<"$privkey" 2>&- | publicKeyToAddress 2>&- | if [[ -f "$wallet" ]] then tee -a "$wallet" # storing and showing the address printf "%s" "$privkey" >> "$wallet" # storing the private key else # showing address and private key cat printf "%s" "$privkey" fi
}
|
|
|
|
grondilu (OP)
Legendary
Offline
Activity: 1288
Merit: 1080
|
![](https://bitcointalk.org/Themes/custom1/images/post/xx.gif) |
February 24, 2011, 11:30:27 AM |
|
I know a bit about this software and I think it's pretty cool. I really would like to see an implementation of bitcoin using this as a database handler. One of the reason why I think it would fit bitcoin nicely is the fact that mongodb uses JSON directly to represent data. An other reason is that it is very easy to connect to an other mongodb on the net. Thus, the network handling would be easy. Also, it's very easy to handle from a bash script. www.mongodb.org
|
|
|
|
Nefario
|
![](https://bitcointalk.org/Themes/custom1/images/post/xx.gif) |
February 24, 2011, 01:34:59 PM |
|
What is it with you and bash scripts? ![Roll Eyes](https://bitcointalk.org/Smileys/default/rolleyes.gif) Can you do nothing else?
|
PGP key id at pgp.mit.edu 0xA68F4B7C To get help and support for GLBSE please email support@glbse.com
|
|
|
|