Giter Club home page Giter Club logo

mojocoin-faucet's Introduction

Mojocoin::Faucet has been discontinued and kept here for historical reasons

Mojocoin::Faucet - Bitcoin Faucet Implementation

Mojocoin::Faucet is a lightweight implementation of a Bitcoin faucet in Perl. It is built on top of the popular Mojolicious web framework and uses Redis as an in-memory key/value data store. Mojocoin::Faucet delegates most bitcoin-related tasks to the original Satoshi bitcoind client. We use bootstrap from twitter for CSS designs. Here is a wrap up of the technologies used:

Frameworks & Tools

Mojolicious is a cooperative multitasking web framework as it runs on a single-process event loop (usually EV). You can leverage the power of GNU/Linux pre-forking using the built-in Hypnotoad web server.

Mojolicious is an asynchronous web framework. The programming style is mostly callback-oriented. You install listeners on the event loop and provide callbacks for specifying your program continuations. This shouldn't been too alien if you have some javascript or node.js background.

To make asynchronous programming easier with Mojolicious, we designed the Continuum framework. It allows us to run asynchronous commands in parallel and provide merge-point callbacks very easily. This should be fairly simple to understand:

    use Continuum;
    use Continuum::BitcoinRPC # $bitcoin
    use Continuum::Redis # $redis
    

    $bitcoin->GetBalance
        ->merge( $bitcoin->ValidateAddress( $address ) )
        ->merge( $redis->hget( ip => value ) )
        ->then( sub { 
            my ( $balance, $validation, $ip ) = @_;
            # This callback is called once all 3 asynchronous
            # operations above are completed
        });

To communicate with the Satoshi Bitcoin implementation, I wrote Continuum::BitcoinRPC. It is a simple JSON/RPC interface to bitcoind.

Installation

Upgrade to Perl v5.14 if you haven't already. This program requires some features that are only well supported from that version.

You will need the following Perl modules from github:

And at least the following modules from CPAN:

You may be missing upstream dependencies from CPAN. Just install them as you go.

You'll need to install bitcoind and configure it to use RPC:

bitcoin.org

The Faucet needs some configuration settings in the file mojocoin-faucet.conf at the root directory of the application. Look at mojocoin-faucet.conf.example.

Finally, install Redis.io and make it available on the localhost interface, port 6379 (default port). If you change the Redis network settings, you'll need to update the Faucet.pm file.

To launch the server, use the following commands from the project root:

Development

morbo script/mojocoin-faucet.pl -l http://127.0.0.1:3000

Production (single process)

script/mojocoin-faucet.pl daemon -l http://*:80

You can use Hypnotoad for a prefork Unix-optimized server, Although it has not been tested with the faucet yet. The default Mojolicious server should be enough since the application is optimized for asynchronous IO.

Bugs

Please report any bugs in the projects bug tracker:

http://github.com/plaprade/Mojocoin-Faucet/issues

You can also submit a patch.

Contributing

We're glad you want to contribute! It's simple:

  • Fork Mojocoin::Faucet
  • Create a branch git checkout -b my_branch
  • Commit your changes git commit -am 'comments'
  • Push the branch git push origin my_branch
  • Open a pull request

mojocoin-faucet's People

Contributors

plaprade avatar

Stargazers

 avatar Suriyaa Sundararuban avatar Raghav Gupta avatar Dave Menninger ⚡ avatar Roberto Acevedo avatar Blake Jakopovic avatar Louis avatar Richard Myers avatar Sung avatar Christian Mayer avatar Michael Williams avatar Kirill Fomichev avatar Aaron Caswell avatar  avatar Aleksandar Vidakovic avatar Luis Aranguren avatar Daniel Morante avatar Ryan Boone avatar Jonas Anton Östman avatar Gosha Spark avatar ZhaoYu avatar Tim Denisenko avatar Donncha Ó Cearbhaill avatar

Watchers

 avatar  avatar Ryan Boone avatar  avatar  avatar

mojocoin-faucet's Issues

Hangs on insufficient funds

I am trying this in my test environment. I have all but depleted my testing wallet, got it down to 0.0004 testcoins. I set the maximum withdrawal to be a hundred percent of what the wallet has. Now this is not enough to pay the minimum transaction fee. Since Continuum is not bubbling the errors up the chain, the faucet just hangs on the transaction forever. I'm going to try to work this particular case out without modifying Continuum.

Invalid bitcoin address error

Whenever I tried using the faucet, I got an "invalid bitcoin address" error, though I'm absolutely positive that it is in fact valid.

Can't boolify Continuum::Portal

Attempting to setup a faucet for an ALT coin (bitcoin clone)

$ cpanm Mojolicious
Mojolicious is up to date. (4.66)
$ perl -v

This is perl 5, version 16, subversion 3 (v5.16.3) built for x86_64-linux

$ morbo script/mojocoin-faucet.pl -l http://*:4000
[snipped]

[Tue Jan 7 11:42:51 2014] [debug] GET "/".
utf8 "\x83" does not map to Unicode at /home/jj/perl5/perlbrew/perls/perl-5.16.3/lib/site_perl/5.16.3/Mojo/Exception.pm line 97, <$handle> line 116.
[Tue Jan 7 11:42:51 2014] [debug] Routing to controller "Mojocoin::Faucet::Controller" and action "home".
Class::MOP::load_class is deprecated at /home/jj/perl5/perlbrew/perls/perl-5.16.3/lib/site_perl/5.16.3/x86_64-linux/Class/MOP.pm line 76.
Class::MOP::load_class('JSON::RPC::Common::Procedure::Call::Version_2_0') called at /home/jj/perl5/perlbrew/perls/perl-5.16.3/lib/site_perl/5.16.3/JSON/RPC/Common/Message.pm line 34
JSON::RPC::Common::Message::inflate('JSON::RPC::Common::Procedure::Call', 'version', 2.0, 'id', 1, 'method', 'getbalance', 'params', 'ARRAY(0x24bd188)', ...) called at /home/jj/perl5/perlbrew/perls/perl-5.16.3/lib/site_perl/5.16.3/AnyEvent/JSONRPC/HTTP/Client.pm line 61
AnyEvent::JSONRPC::HTTP::Client::call('AnyEvent::JSONRPC::HTTP::Client=HASH(0x36f1c48)', 'getbalance', 'faucet') called at /home/jj/perl5/perlbrew/perls/perl-5.16.3/lib/site_perl/5.16.3/Continuum/BitcoinRPC.pm line 46
Continuum::BitcoinRPC::AUTOLOAD('Continuum::BitcoinRPC=HASH(0x36f1ff0)', 'faucet') called at /home/jj/Mojocoin-Faucet/script/../lib/Mojocoin/Faucet/Controller.pm line 52
Mojocoin::Faucet::Controller::home('Mojocoin::Faucet::Controller=HASH(0x34d71f8)') called at /home/jj/perl5/perlbrew/perls/perl-5.16.3/lib/site_perl/5.16.3/Mojolicious.pm line 157
Mojolicious::ANON(undef, 'Mojocoin::Faucet::Controller=HASH(0x34d71f8)', 'CODE(0x34e0f80)', 1) called at /home/jj/perl5/perlbrew/perls/perl-5.16.3/lib/site_perl/5.16.3/Mojolicious/Plugins.pm line 20
Mojolicious::Plugins::ANON() called at /home/jj/perl5/perlbrew/perls/perl-5.16.3/lib/site_perl/5.16.3/Mojolicious/Plugins.pm line 23
Mojolicious::Plugins::emit_chain('Mojolicious::Plugins=HASH(0x3215368)', 'around_action', 'Mojocoin::Faucet::Controller=HASH(0x34d71f8)', 'CODE(0x34e0f80)', 1) called at /home/jj/perl5/perlbrew/perls/perl-5.16.3/lib/site_perl/5.16.3/Mojolicious/Routes.pm line 108
Mojolicious::Routes::_action('Mojocoin::Faucet=HASH(0x3214e28)', 'Mojocoin::Faucet::Controller=HASH(0x34d71f8)', 'CODE(0x34e0f80)', 1) called at /home/jj/perl5/perlbrew/perls/perl-5.16.3/lib/site_perl/5.16.3/Mojolicious/Routes.pm line 196
Mojolicious::Routes::_controller('Mojolicious::Routes=HASH(0x3214cc0)', 'Mojolicious::Controller=HASH(0x34cd838)', 'HASH(0x34d1f30)', 1) called at /home/jj/perl5/perlbrew/perls/perl-5.16.3/lib/site_perl/5.16.3/Mojolicious/Routes.pm line 43
Mojolicious::Routes::continue('Mojolicious::Routes=HASH(0x3214cc0)', 'Mojolicious::Controller=HASH(0x34cd838)') called at /home/jj/perl5/perlbrew/perls/perl-5.16.3/lib/site_perl/5.16.3/Mojolicious/Routes.pm line 84
Mojolicious::Routes::dispatch('Mojolicious::Routes=HASH(0x3214cc0)', 'Mojolicious::Controller=HASH(0x34cd838)') called at /home/jj/perl5/perlbrew/perls/perl-5.16.3/lib/site_perl/5.16.3/Mojolicious.pm line 137
Mojolicious::dispatch('Mojocoin::Faucet=HASH(0x3214e28)', 'Mojolicious::Controller=HASH(0x34cd838)') called at /home/jj/perl5/perlbrew/perls/perl-5.16.3/lib/site_perl/5.16.3/Mojolicious.pm line 158
Mojolicious::ANON(undef, 'Mojolicious::Controller=HASH(0x34cd838)') called at /home/jj/perl5/perlbrew/perls/perl-5.16.3/lib/site_perl/5.16.3/Mojolicious/Plugins.pm line 20
Mojolicious::Plugins::ANON() called at /home/jj/perl5/perlbrew/perls/perl-5.16.3/lib/site_perl/5.16.3/Mojolicious.pm line 202
eval {...} called at /home/jj/perl5/perlbrew/perls/perl-5.16.3/lib/site_perl/5.16.3/Mojolicious.pm line 202
Mojolicious::_exception('CODE(0x34cd940)', 'Mojolicious::Controller=HASH(0x34cd838)') called at /home/jj/perl5/perlbrew/perls/perl-5.16.3/lib/site_perl/5.16.3/Mojolicious/Plugins.pm line 20
Mojolicious::Plugins::ANON() called at /home/jj/perl5/perlbrew/perls/perl-5.16.3/lib/site_perl/5.16.3/Mojolicious/Plugins.pm line 23
Mojolicious::Plugins::emit_chain('Mojolicious::Plugins=HASH(0x3215368)', 'around_dispatch', 'Mojolicious::Controller=HASH(0x34cd838)') called at /home/jj/perl5/perlbrew/perls/perl-5.16.3/lib/site_perl/5.16.3/Mojolicious.pm line 162
Mojolicious::handler('Mojocoin::Faucet=HASH(0x3214e28)', 'Mojo::Transaction::HTTP=HASH(0x1aad2e8)') called at /home/jj/perl5/perlbrew/perls/perl-5.16.3/lib/site_perl/5.16.3/Mojo/Server.pm line 13
Mojo::Server::ANON('Mojo::Server::Daemon=HASH(0x16de520)', 'Mojo::Transaction::HTTP=HASH(0x1aad2e8)') called at /home/jj/perl5/perlbrew/perls/perl-5.16.3/lib/site_perl/5.16.3/Mojo/EventEmitter.pm line 13
Mojo::EventEmitter::emit('Mojo::Server::Daemon=HASH(0x16de520)', 'request', 'Mojo::Transaction::HTTP=HASH(0x1aad2e8)') called at /home/jj/perl5/perlbrew/perls/perl-5.16.3/lib/site_perl/5.16.3/Mojo/Server/Daemon.pm line 106
Mojo::Server::Daemon::ANON('Mojo::Transaction::HTTP=HASH(0x1aad2e8)') called at /home/jj/perl5/perlbrew/perls/perl-5.16.3/lib/site_perl/5.16.3/Mojo/EventEmitter.pm line 13
Mojo::EventEmitter::emit('Mojo::Transaction::HTTP=HASH(0x1aad2e8)', 'request') called at /home/jj/perl5/perlbrew/perls/perl-5.16.3/lib/site_perl/5.16.3/Mojo/Transaction/HTTP.pm line 64
Mojo::Transaction::HTTP::server_read('Mojo::Transaction::HTTP=HASH(0x1aad2e8)', 'GET / HTTP/1.1\x{d}\x{a}Host: 23.253.71.20:4000\x{d}\x{a}Connection: keep-ali...') called at /home/jj/perl5/perlbrew/perls/perl-5.16.3/lib/site_perl/5.16.3/Mojo/Server/Daemon.pm line 214
Mojo::Server::Daemon::_read('Mojo::Server::Daemon=HASH(0x16de520)', '58ea4f88e77f62dca5a3912766fb983e', 'GET / HTTP/1.1\x{d}\x{a}Host: 23.253.71.20:4000\x{d}\x{a}Connection: keep-ali...') called at /home/jj/perl5/perlbrew/perls/perl-5.16.3/lib/site_perl/5.16.3/Mojo/Server/Daemon.pm line 194
Mojo::Server::Daemon::ANON('Mojo::IOLoop::Stream=HASH(0x1d8f230)') called at /home/jj/perl5/perlbrew/perls/perl-5.16.3/lib/site_perl/5.16.3/Mojo/EventEmitter.pm line 31
eval {...} called at /home/jj/perl5/perlbrew/perls/perl-5.16.3/lib/site_perl/5.16.3/Mojo/EventEmitter.pm line 31
Mojo::EventEmitter::emit_safe('Mojo::IOLoop::Stream=HASH(0x1d8f230)', 'read', 'GET / HTTP/1.1\x{d}\x{a}Host: 23.253.71.20:4000\x{d}\x{a}Connection: keep-ali...') called at /home/jj/perl5/perlbrew/perls/perl-5.16.3/lib/site_perl/5.16.3/Mojo/IOLoop/Stream.pm line 118
Mojo::IOLoop::Stream::_read('Mojo::IOLoop::Stream=HASH(0x1d8f230)') called at /home/jj/perl5/perlbrew/perls/perl-5.16.3/lib/site_perl/5.16.3/Mojo/IOLoop/Stream.pm line 55
Mojo::IOLoop::Stream::ANON('Mojo::Reactor::EV=HASH(0x1c18950)') called at /home/jj/perl5/perlbrew/perls/perl-5.16.3/lib/site_perl/5.16.3/Mojo/Reactor/Poll.pm line 109
eval {...} called at /home/jj/perl5/perlbrew/perls/perl-5.16.3/lib/site_perl/5.16.3/Mojo/Reactor/Poll.pm line 109
Mojo::Reactor::Poll::_sandbox('Mojo::Reactor::EV=HASH(0x1c18950)', 'Read', 'CODE(0x328de10)', 0) called at /home/jj/perl5/perlbrew/perls/perl-5.16.3/lib/site_perl/5.16.3/Mojo/Reactor/EV.pm line 52
Mojo::Reactor::EV::_io('Mojo::Reactor::EV=HASH(0x1c18950)', 5, 'EV::IO=SCALAR(0x328e3b0)', 1) called at /home/jj/perl5/perlbrew/perls/perl-5.16.3/lib/site_perl/5.16.3/Mojo/Reactor/EV.pm line 43
Mojo::Reactor::EV::ANON('EV::IO=SCALAR(0x328e3b0)', 1) called at /home/jj/perl5/perlbrew/perls/perl-5.16.3/lib/site_perl/5.16.3/Mojo/Reactor/EV.pm line 24
eval {...} called at /home/jj/perl5/perlbrew/perls/perl-5.16.3/lib/site_perl/5.16.3/Mojo/Reactor/EV.pm line 24
Mojo::Reactor::EV::start('Mojo::Reactor::EV=HASH(0x1c18950)') called at /home/jj/perl5/perlbrew/perls/perl-5.16.3/lib/site_perl/5.16.3/Mojo/IOLoop.pm line 129
Mojo::IOLoop::start('Mojo::IOLoop=HASH(0x1c18740)') called at /home/jj/perl5/perlbrew/perls/perl-5.16.3/lib/site_perl/5.16.3/Mojo/Server/Morbo.pm line 97
Mojo::Server::Morbo::_spawn('Mojo::Server::Morbo=HASH(0x152db80)') called at /home/jj/perl5/perlbrew/perls/perl-5.16.3/lib/site_perl/5.16.3/Mojo/Server/Morbo.pm line 67
Mojo::Server::Morbo::_manage('Mojo::Server::Morbo=HASH(0x152db80)') called at /home/jj/perl5/perlbrew/perls/perl-5.16.3/lib/site_perl/5.16.3/Mojo/Server/Morbo.pm line 40
Mojo::Server::Morbo::run('Mojo::Server::Morbo=HASH(0x152db80)', 'script/mojocoin-faucet.pl') called at /home/jj/perl5/perlbrew/perls/perl-5.16.3/bin/morbo line 47
[Tue Jan 7 11:42:51 2014] [error] Can't boolify Continuum::Portal. You probably want to call ->recv or ->cb to read the value. at /home/jj/perl5/perlbrew/perls/perl-5.16.3/lib/site_perl/5.16.3/Mojolicious/Routes.pm line 196.

[Tue Jan 7 11:42:51 2014] [debug] Template "exception.development.html.ep" not found.
[Tue Jan 7 11:42:51 2014] [debug] Template "exception.html.ep" not found.
[Tue Jan 7 11:42:51 2014] [debug] Rendering inline template.
[Tue Jan 7 11:42:51 2014] [debug] Rendering inline template.
[Tue Jan 7 11:42:51 2014] [debug] 500 Internal Server Error (0.098302s, 10.173/s).
[Tue Jan 7 11:42:51 2014] [debug] Rendering template "/controller/home.html.ep".
[Tue Jan 7 11:42:51 2014] [debug] Rendering template "layouts/default.html.ep".
Can't call method "req" on an undefined value at /home/jj/perl5/perlbrew/perls/perl-5.16.3/lib/site_perl/5.16.3/Mojolicious/Controller.pm line 261.
256: }
257: $self->tx->resume;
258: return $self;
259: }
260:
261: sub req { shift->tx->req }
262: sub res { shift->tx->res }
263:
264: sub respond_to {
265: my $self = shift;
266: my $args = ref $[0] ? $[0] : {@_};

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.