Commit 124bbb84 authored by TonyFord's avatar TonyFord
Browse files

add electrumfair wallet support

parent 6b6dda05
...@@ -24,8 +24,10 @@ build: ...@@ -24,8 +24,10 @@ build:
script: script:
- docker-compose down - docker-compose down
- docker-compose build faircoin - docker-compose build faircoin
- docker-compose up -d faircoin - docker-compose build electrumfairchainsx
- docker-compose up -d php-server - docker-compose up -d --remove-orphans faircoin
- docker-compose up -d --remove-orphans electrumfairchainsx
- docker-compose up -d --remove-orphans php-server
after_script: after_script:
- docker-compose down - docker-compose down
......
...@@ -21,14 +21,23 @@ Enter variable name **CMD** ...@@ -21,14 +21,23 @@ Enter variable name **CMD**
#### CMD - commands #### CMD - commands
Container commands:
~~~ ~~~
build build
start # start container ( changes of scripts ) start # start container ( changes of scripts )
stop # stop container stop # stop container
uninstall # remove container uninstall # remove container
remove remove
~~~ ~~~
Wallet commands:
~~~
create wallet # create new electrumfair wallet
load wallet # load wallet ( make it hot )
close wallet # close wallet ( make it cold )
walletinfo # get electrumfair wallet info
~~~
#### CI/CD Settings #### CI/CD Settings
Go Gitlab **Settings** -> **CI/CD** -> **Variables** Go Gitlab **Settings** -> **CI/CD** -> **Variables**
...@@ -38,11 +47,33 @@ Go Gitlab **Settings** -> **CI/CD** -> **Variables** ...@@ -38,11 +47,33 @@ Go Gitlab **Settings** -> **CI/CD** -> **Variables**
LH_PORT_jsonrpc # php -S 0.0.0.0:${LH_PORT} LH_PORT_jsonrpc # php -S 0.0.0.0:${LH_PORT}
~~~ ~~~
Pipeline variables:
~~~
CMD = create wallet
WALLET = <new wallet name> # optional specify the wallets name
PASSPHRASE = <new wallet passphrase> # passphrase make your seed more secure
PASSWORD = <new wallet password> # password encrypts all wallets data on your drive
~~~
~~~
CMD = load wallet
WALLET = <wallet name> # optional specify the wallets name
PASSWORD = <wallet password> # password encrypts all wallets data on your drive
~~~
~~~
CMD = close wallet
WALLET = <wallet name> # optional specify the wallets name
PASSWORD = <wallet password> # password encrypts all wallets data on your drive
~~~
## Manual usage ## Manual usage
set localhost port env var change localhost port in setenv.sh
and run setenv.sh to init env vars
~~~ ~~~
export LH_PORT_jsonrpc=4000 . ./setenv.sh
~~~ ~~~
follow the commands in the .gitlab-ci.yml and do the same steps as the gitlab-runner would do. follow the commands in the .gitlab-ci.yml and do the same steps as the gitlab-runner would do.
...@@ -56,3 +87,13 @@ follow the commands in the .gitlab-ci.yml and do the same steps as the gitlab-ru ...@@ -56,3 +87,13 @@ follow the commands in the .gitlab-ci.yml and do the same steps as the gitlab-ru
## Nginx server setup ## Nginx server setup
follow the instructions on https://git.fairkom.net/faircoin.co/admin/-/blob/master/SERVERSETUP.md#configure-server-host follow the instructions on https://git.fairkom.net/faircoin.co/admin/-/blob/master/SERVERSETUP.md#configure-server-host
## Wallet
~~~
./run_electrumfair create --passphrase test123 --password test123 --wallet /home/faircoin/.electrumfair/wallets/test
~~~
...@@ -7,6 +7,8 @@ services: ...@@ -7,6 +7,8 @@ services:
container_name: faircoin-php container_name: faircoin-php
image: php:7 image: php:7
command: php -S 0.0.0.0:4000 -t /var/www/html command: php -S 0.0.0.0:4000 -t /var/www/html
environment:
PASSWORD: ${PASSWORD:-password}
ports: ports:
- ${LH_PORT_jsonrpc}:4000 - ${LH_PORT_jsonrpc}:4000
volumes: volumes:
...@@ -14,11 +16,11 @@ services: ...@@ -14,11 +16,11 @@ services:
faircoin: faircoin:
build: build:
context: ./faircoin context: ./faircoin/faircoin
args: args:
RUNNER_UID: ${RUNNER_UID:-1000} RUNNER_UID: ${RUNNER_UID:-1000}
RUNNER_GID: ${RUNNER_GID:-1000} RUNNER_GID: ${RUNNER_GID:-1000}
container_name: faircoin-services container_name: faircoin-faircoind-electrumfair
restart: always restart: always
command: ./start_faircoin_services.sh command: ./start_faircoin_services.sh
user: "${RUNNER_UID:-1000}:${RUNNER_GID:-1000}" user: "${RUNNER_UID:-1000}:${RUNNER_GID:-1000}"
...@@ -26,6 +28,24 @@ services: ...@@ -26,6 +28,24 @@ services:
- faircoin2:/home/faircoin/.faircoin2 - faircoin2:/home/faircoin/.faircoin2
- electrumfair:/home/faircoin/.electrumfair - electrumfair:/home/faircoin/.electrumfair
electrumfairchainsx:
build:
context: ./faircoin/electrumfairchainsx
args:
RUNNER_UID: "${RUNNER_UID}"
RUNNER_GID: "${RUNNER_GID}"
depends_on:
- faircoin
container_name: faircoin-electrumfairchainsx
restart: always
command: sleep inf
user: "${RUNNER_UID:-1000}:${RUNNER_GID:-1000}"
volumes:
- faircoin2:/home/faircoin/.faircoin2
- fairchains:/home/faircoin/.fairchains
volumes: volumes:
faircoin2: faircoin2:
fairchains:
electrumfair: electrumfair:
{
"PEER_DEFAULT_PORTS" :
{
"t": "51811",
"s": "51812"
},
"PEERS" :
{
"electrum.faircoin.world": {
"pruning": "-",
"s": "51812",
"t": "51811",
"version": "1.4"
},
"electrumfair.punto0.org": {
"pruning": "-",
"s": "51812",
"t": "51811",
"version": "1.4.2"
},
"electrum.faircoin.co": {
"pruning": "-",
"s": "51812",
"t": "51811",
"version": "1.4"
}
},
"SERVICES" : [
"rpc://0.0.0.0:8002",
"tcp://0.0.0.0:51811"
],
"REPORT_SERVICES" :
[
"ssl://electrum.faircoin.co:51812"
]
}
{
"data": {
"jsonVersion": 1,
"chainName": "main",
"currencyName": "FairCoin",
"currencySymbol": "FAIR",
"maxMoney": 53193831.467966,
"networkMagic": "0xfabfb5da",
"alertPubKey": "04b06af4982ca3edc2c040cc2cde05fa5b33264af4a98712ceb29d196e7390b4753eb7264dc5f383f29a44d63e70dbbd8d9e46a0a60f80ef62fd1911291ec388e4",
"defaultPort": 40404,
"seedNodes": [
"faircoin2-seed1.fair-coin.org",
"faircoin2-seed2.fair-coin.org"
],
"fixedSeeds": [
{
"ipAddress": "00000000000000000000ffff33FE7367",
"port": 40404
}
],
"pubKeyAddrVersion": 95,
"scriptAddrVersion": 36,
"secretKeyVersion": 223,
"extPubKeyPrefix": "0x0488b21e",
"extSecretPrefix": "0x0488ade4",
"requireStandardTx": true,
"blockchainStartTime": 1462293889,
"genesisCvnID": "0xc001d00d",
"genesisAdminID": "0xad000001",
"genesisCvnPubKey": "65aaaf2147d0de94d1d307de8817076c55111d42cc5f185c0f8d2b5e9ad29bf62c26b1d86a4bb1f8ba32345eefb01ac3f568af9243486e578fac0d9a645ad72a",
"genesisAdminPubKey": "363d7f305589549a832e92a43d009ad9c9adb7fe648280c08763be7dcba5bf1c80f59f97042066c2e3f95a75e3f3cdfd75309f4c86ec6086847e7676fae69f5f",
"dynamicChainParams": {
"minAdminSigs": 1,
"maxAdminSigs": 11,
"blockSpacing": 180,
"blockSpacingGracePeriod": 60,
"transactionFee": 0,
"dustThreshold": 0,
"minSuccessiveSignatures": 1,
"blocksToConsiderForSigCheck": 1,
"percentageOfSignaturesMean": 70,
"maxBlockSize": 1500000,
"blockPropagationWaitTime": 50,
"retryNewSigSetInterval": 15,
"coinbaseMaturity": 10,
"description": "#00001 https://fair-coin.org/ The genesis dynamic chain parameters"
},
"merkleRoot": "7c27ade2c28e67ed3077f8f77b8ea6d36d4f5eba04c099be3c9faa9a4a04c046",
"chainMultiSig": "14dc4f77f9d59ece2b3aa02cc4df99954d47fa2719be207d1b5010745aec419e451f01a8749cd16f22a727d0deba5110d2ce7e44ff86f0efdea58db4efdb92cd",
"adminMultiSig": "591039a3b2e2c5ca8cd491e940263c9f2515a43b5085d4451dbdf8c09acb3d1fe7001957ebeda65a3cd26f1d19fb3db3b06baf5dc41cdcd3412728c8b57edaf5",
"payloadHash": "2b7ab86ef7189614d4bccb2576bffe834b7c0e6d3fd63539ea9fbbca45d26c0e",
"blockHash": "beed44fa5e96150d95d56ebd5d2625781825a9407a5215dd7eda723373a0a1d7",
"creatorSignature": "ced5d4d4f5967b80ca774324a5d9ab0569ec1f1608dfef6c1e439094dc3467d50b2116fa02f3e89753033e94628668298f61b43df046881c9312f3bccde46a3f"
},
"hash": "a54c7600d0493126a5865e295d96654762e544ce134e13265a5e981fcd14db9f",
"sign": {
"comment": "",
"signature": "",
"signedhash": ""
}
}
rpcconnect=faircoin
rpcallowip=0.0.0.0/0
rpcport=8332
rpcuser=user
rpcpassword=password
txindex=1
netname=FairCoinChain
# Pull base image.
FROM ubuntu:18.04@sha256:5f4bdc3467537cbbe563e80db2c3ec95d548a9145d64453b06939c4592d67b6d
ENV LC_ALL=C.UTF-8 LANG=C.UTF-8
#####################################################################################root##
### install base libraries and dependencies for faircoin daemon ###########################
RUN apt-get update -q && \
apt-get install -qy \
net-tools \
git \
python3-pyqt5 \
openssl
#####################################################################################root##
### install nano commandline editor [optional] ( to edit faircoin.conf later if necessary )
RUN apt-get install -qy nano
#####################################################################################root##
### install python packages
RUN apt-get install -qy python3-pip
RUN apt-get install -qy libleveldb-dev
RUN python3 -m pip install \
aiorpcx \
attrs \
plyvel \
pylru \
aiohttp
#####################################################################################root##
### system cleanup ########################################################################
RUN rm -rf /var/lib/apt/lists/* && \
apt-get autoremove -y && \
apt-get clean
#####################################################################################root##
### create and run user account to image ##################################################
ARG RUNNER_GID
ARG RUNNER_UID
ENV USER=faircoin
ENV FAIRCHAINS_PATH=/home/faircoin/.faircoin2/
RUN groupadd -g $RUNNER_GID faircoin
RUN useradd --create-home --shell /bin/bash faircoin --uid $RUNNER_UID --gid $RUNNER_GID
RUN mkdir -p /home/faircoin/.fairchains
RUN chown -R faircoin:faircoin /home/faircoin/.fairchains
COPY .faircoin2/fairchains.conf /home/faircoin/.faircoin2/fairchains.conf
RUN chown faircoin:faircoin /home/faircoin/.faircoin2/fairchains.conf
COPY .faircoin2/FairCoinChain.electrumx.json /home/faircoin/.faircoin2/FairCoinChain.electrumx.json
RUN chown faircoin:faircoin /home/faircoin/.faircoin2/FairCoinChain.electrumx.json
COPY .faircoin2/FairCoinChain.json /home/faircoin/.faircoin2/FairCoinChain.json
RUN chown faircoin:faircoin /home/faircoin/.faircoin2/FairCoinChain.json
USER faircoin
#################################################################################faircoin##
### download electrumfairchainsx & build ##################################################
WORKDIR /home/faircoin
RUN git clone https://github.com/fairchainsx/electrumfairchainsx.git
WORKDIR /home/faircoin/electrumfairchainsx
RUN python3 setup.py build
WORKDIR /home/faircoin/.fairchains
RUN openssl genrsa -out electrumx.key 2048
RUN openssl req -new -key electrumx.key -out electrumx.csr -subj "/C=GB/ST=London/L=London/O=electrumfairchainsx/OU=electrumfairchainsx/CN=faircoin.co"
RUN openssl x509 -req -days 1825 -in electrumx.csr -signkey electrumx.key -out electrumx.crt
WORKDIR /home/faircoin/electrumfairchainsx
{ {
"auto_connect": false,
"config_version": 3, "config_version": 3,
"rpchost": "0.0.0.0", "rpchost": "0.0.0.0",
"rpcpassword": "password", "rpcpassword": "password",
"rpcport": 7777, "rpcport": 7777,
"rpcuser": "user" "rpcuser": "user",
"server": "electrumfairchainsx:51811:t"
} }
...@@ -58,7 +58,7 @@ COPY .faircoin2/faircoin.conf /home/faircoin/.faircoin2/faircoin.conf ...@@ -58,7 +58,7 @@ COPY .faircoin2/faircoin.conf /home/faircoin/.faircoin2/faircoin.conf
RUN chown -R faircoin:faircoin /home/faircoin/.faircoin2 RUN chown -R faircoin:faircoin /home/faircoin/.faircoin2
COPY .electrumfair/config /home/faircoin/.electrumfair/config COPY .electrumfair/config /home/faircoin/.electrumfair/config
RUN chown -R faircoin:faircoin /home/faircoin/.electrumfair/config RUN chown faircoin:faircoin /home/faircoin/.electrumfair/config
COPY ./start_faircoin_services.sh /home/faircoin/start_faircoin_services.sh COPY ./start_faircoin_services.sh /home/faircoin/start_faircoin_services.sh
RUN chown faircoin:faircoin /home/faircoin/start_faircoin_services.sh RUN chown faircoin:faircoin /home/faircoin/start_faircoin_services.sh
......
{
"electrumfairchainsx": {
"pruning": "-",
"t": "51811",
"version": "1.4"
}
}
#!/bin/bash #!/bin/bash
if [ ! -d ./electrumfair/packages ]; then ./electrumfair/contrib/make_packages; fi if [ ! -d ./electrumfair/packages ]; then ./electrumfair/contrib/make_packages; fi
rm ./electrumfair/electrumfair/servers.json
cp ./.electrumfair/servers.json ./electrumfair/electrumfair/
./electrumfair/run_electrumfair daemon start ./electrumfair/run_electrumfair daemon start
./faircoind ./faircoind
...@@ -187,6 +187,25 @@ class electrumfair ...@@ -187,6 +187,25 @@ class electrumfair
} }
### electrumfair methods / messages ### ### electrumfair methods / messages ###
/*
encrypt decrypt still not working by jsonrpc or commandline
function decrypt($pubkey, $encrypted){
$this->param['method']=__FUNCTION__;
$this->param['params']=Array( 'pubkey' => $pubkey, 'encrypted' => $encrypted, 'password' => getenv('PASSWORD') );
return json_decode( $this->electrumfair(), true )['result'];
}
function encrypt($pubkey, $message){
$this->param['method']=__FUNCTION__;
$this->param['params']=Array( 'pubkey' => $pubkey, 'message' => $message );
return json_decode( $this->electrumfair(), true )['result'];
}
*/
function signmessage($address, $message){
$this->param['method']=__FUNCTION__;
$this->param['params']=Array( 'address' => $address, 'message' => $message, 'password' => getenv('PASSWORD') );
return json_decode( $this->electrumfair(), true )['result'];
}
function verifymessage($address, $message, $signature){ function verifymessage($address, $message, $signature){
$this->param['method']=__FUNCTION__; $this->param['method']=__FUNCTION__;
$this->param['params']=Array( 'address' => $address, 'message' => $message, 'signature' => $signature ); $this->param['params']=Array( 'address' => $address, 'message' => $message, 'signature' => $signature );
...@@ -213,6 +232,12 @@ class electrumfair ...@@ -213,6 +232,12 @@ class electrumfair
} }
### electrumfair methods / transaction ### ### electrumfair methods / transaction ###
function serialize($tx_json){
$this->param['method']=__FUNCTION__;
$this->param['params']=Array( 'jsontx' => $tx_json );
$result=json_decode( $this->electrumfair(), true )['result'];
return $result;
}
function deserialize($tx_hex){ function deserialize($tx_hex){
$this->param['method']=__FUNCTION__; $this->param['method']=__FUNCTION__;
$this->param['params']=Array( 'tx' => $tx_hex ); $this->param['params']=Array( 'tx' => $tx_hex );
...@@ -241,11 +266,133 @@ class electrumfair ...@@ -241,11 +266,133 @@ class electrumfair
} }
### electrumfair methods / util ### ### electrumfair methods / util ###
function is_synchronized(){
$this->param['method']=__FUNCTION__;
$this->param['params']=Array();
return json_decode( $this->electrumfair(), true )['result'];
}
function validateaddress($address){ function validateaddress($address){
$this->param['method']=__FUNCTION__; $this->param['method']=__FUNCTION__;
$this->param['params']=Array($address); $this->param['params']=Array($address);
return json_decode( $this->electrumfair(), true )['result']; return json_decode( $this->electrumfair(), true )['result'];
} }
function version(){
$this->param['method']=__FUNCTION__;
$this->param['params']=Array();
return json_decode( $this->electrumfair(), true )['result'];
}
### electrumfair methods / wallet ###
function addrequest($amount,$memo){
$this->param['method']=__FUNCTION__;
$this->param['params']=Array('amount' => $amount, 'memo' => $memo);
return json_decode( $this->electrumfair(), true )['result'];
}
function getrequest($request){
$this->param['method']=__FUNCTION__;
$this->param['params']=Array($request);
return json_decode( $this->electrumfair(), true )['result'];
}
function listrequests(){
$this->param['method']=__FUNCTION__;
$this->param['params']=Array();
return json_decode( $this->electrumfair(), true )['result'];
}
function rmrequest($address){
$this->param['method']=__FUNCTION__;
$this->param['params']=Array('address' => $address);
return json_decode( $this->electrumfair(), true )['result'];
}
function clearrequests(){
$this->param['method']=__FUNCTION__;
$this->param['params']=Array();
return json_decode( $this->electrumfair(), true )['result'];
}
function createnewaddress(){
$this->param['method']=__FUNCTION__;
$this->param['params']=Array();
return json_decode( $this->electrumfair(), true )['result'];
}
function getunusedaddress(){
$this->param['method']=__FUNCTION__;
$this->param['params']=Array();
return json_decode( $this->electrumfair(), true )['result'];
}
function ismine($address){
$this->param['method']=__FUNCTION__;
$this->param['params']=Array('address' => $address);
return json_decode( $this->electrumfair(), true )['result'];
}
function listaddresses(){
$this->param['method']=__FUNCTION__;
$this->param['params']=Array();
return json_decode( $this->electrumfair(), true )['result'];
}
function listunspent(){
$this->param['method']=__FUNCTION__;
$this->param['params']=Array();
return json_decode( $this->electrumfair(), true )['result'];
}
function freeze($address){
$this->param['method']=__FUNCTION__;
$this->param['params']=Array('address' => $address);
return json_decode( $this->electrumfair(), true )['result'];
}
function unfreeze($address){
$this->param['method']=__FUNCTION__;
$this->param['params']=Array('address' => $address);
return json_decode( $this->electrumfair(), true )['result'];
}
function notify($address, $URL){
$this->param['method']=__FUNCTION__;
$this->param['params']=Array('address' => $address, 'URL' => $URL );
return json_decode( $this->electrumfair(), true )['result'];
}
function getbalance(){
$this->param['method']=__FUNCTION__;
$this->param['params']=Array();
return json_decode( $this->electrumfair(), true )['result'];
}
function history(){
$this->param['method']=__FUNCTION__;
$this->param['params']=Array();
return json_decode( $this->electrumfair(), true )['result'];
}
function getmpk(){
$this->param['method']=__FUNCTION__;
$this->param['params']=Array();
return json_decode( $this->electrumfair(), true )['result'];
}
function getpubkeys($address){
$this->param['method']=__FUNCTION__;
$this->param['params']=Array('address' => $address);
return json_decode( $this->electrumfair(), true )['result'];
}
function payto($address, $amount){
$this->param['method']=__FUNCTION__;
$this->param['params']=Array('destination' => $address, 'amount' => $amount );
return json_decode( $this->electrumfair(), true )['result'];
}
function paytomany($Payment){
$this->param['method']=__FUNCTION__;
$this->param['params']=Array($Payment);
return json_decode( $this->electrumfair(), true )['result'];
}
function signtransaction($serialized_tx){
$this->param['method']=__FUNCTION__;
$this->param['params']=Array('tx' => $serialized_tx);
return json_decode( $this->electrumfair(), true )['result'];
}
function broadcast($serialized_tx){
$this->param['method']=__FUNCTION__;
$this->param['params']=Array('tx' => $serialized_tx);
return json_decode( $this->electrumfair(), true )['result'];
}
} }
...@@ -261,5 +408,5 @@ class Faircoin ...@@ -261,5 +408,5 @@ class Faircoin
$this->electrumfair = new electrumfair(); $this->electrumfair = new electrumfair();
$this->online = !empty( $this->electrumfair->getservers() ); $this->online = !empty( $this->electrumfair->getservers() );
} }
} }
...@@ -11,13 +11,14 @@ ...@@ -11,13 +11,14 @@