Coder Social home page Coder Social logo

electrum-hashcash's Introduction

Proof of work for Electrum protocol

This script adds proof of work to the Electrum protocol.

The idea is that the Electrum network can fight the spam in a similar manner as was proposed for email with hashcash.

Written by Luca Venturini, based on an idea of Guido Dassori, sprouted on Telegram Channel Bitcoin Italia.

The script is adapted from tcp-proxy.pl by Peteris Krumins

Strategy

Instead of changing Electrum client or Electrum server, we put a proxy between the client and the Internet, and between the Internet and the server. The proxy on the client side calculates the proof of work and embeds it in the JSON request. The proxy on the server side checks the POW field, strips it away and sends to the server the same request that the client originally sent.

Electrum

Electrum diagram

Electrum-hashcash

Electrum-hashcash diagram

Required libraries

On Debian:

apt-get install libjson-perl libdigest-sha-perl libstring-random-perl \
                libio-socket-ip-perl

Install on server side

  • Install ElectrumX
  • Start ElectrumX on port 40001:
TCP_PORT=40001 COIN=Bitcoin DB_DIRECTORY=path/to/db DAEMON_URL='http://user:[email protected]:8332/' ./electrumx_server
  • Start the proxy, listening on port 30001:
git clone https://github.com/lucayepa/electrum-hashcash
cd electrum-hashcash
./hashcash-proxy-server.pl --listen_port=30001 --target_host=127.0.0.1 --target_port=40001

Install on client side with only one server

  • Install Electrum
  • Start the proxy, listening on port 50001:
git clone https://github.com/lucayepa/electrum-hashcash
cd electrum-hashcash
./hashcash-proxy-client.pl --listen_port=50001 --target_host=my.personal.server --target_port=30001
  • Start Electrum, using only one server, localhost on port 50001:
electrum -1 --server localhost:50001:t

IPv6

The program listens on IPv6 by using the option --listen_ipv6 on command line, and sends the connection to an IPv6 address by using the option --target_ipv6 on command line.

Readme sources and links

Electrum

@startuml
title Electrum
node "Client" #wheat {
  left to right direction
  object RPC_client {
    Generates request
  }
}
cloud "Internet" #silver {
  object TCP {
    JSON
  }
}
node "Server" #wheat {
  object RPC_server {
    Receives request
  }
}
RPC_client --> TCP : request
TCP --> RPC_server : request
@enduml

Electrum-hashcash

@startuml
title Electrum-hashcash
node "Client" #wheat {
  left to right direction
  object RPC_client {
    Generates request
  }
  object proxy_client #coral {
    Adds POW
  }
}
cloud "Internet" #silver {
  object TCP {
    JSON
  }
}
node "Server" #wheat {
  object proxy_server #coral {
    Checks POW
  }
  object RPC_server {
    Receives request
  }
}
RPC_client --> proxy_client : request
proxy_client --> TCP : request with POW
TCP --> proxy_server : request with POW
proxy_server --> RPC_server : request
@enduml

electrum-hashcash's People

Contributors

lucayepa avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

Forkers

isghe nedludd0

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.