Merge branch 'litecoin'

This commit is contained in:
Martin Boehm 2018-06-12 17:20:44 +02:00
commit 7bce5ae4fd
41 changed files with 831 additions and 1 deletions

View File

@ -7,6 +7,7 @@ import (
"blockbook/bchain/coins/btg"
"blockbook/bchain/coins/dash"
"blockbook/bchain/coins/eth"
"blockbook/bchain/coins/litecoin"
"blockbook/bchain/coins/zec"
"blockbook/common"
"context"
@ -35,6 +36,8 @@ func init() {
blockChainFactories["Bgold"] = btg.NewBGoldRPC
blockChainFactories["Dash"] = dash.NewDashRPC
blockChainFactories["Dash Testnet"] = dash.NewDashRPC
blockChainFactories["Litecoin"] = litecoin.NewLitecoinRPC
blockChainFactories["Litecoin Testnet"] = litecoin.NewLitecoinRPC
}
// GetCoinNameFromConfig gets coin name from config file

View File

@ -0,0 +1,62 @@
package litecoin
import (
"blockbook/bchain/coins/btc"
"github.com/btcsuite/btcd/chaincfg"
"github.com/btcsuite/btcd/wire"
)
const (
MainnetMagic wire.BitcoinNet = 0xdbb6c0fb
TestnetMagic wire.BitcoinNet = 0xf1c8d2fd
RegtestMagic wire.BitcoinNet = 0xdab5bffa
)
var (
MainNetParams chaincfg.Params
TestNetParams chaincfg.Params
)
func init() {
MainNetParams = chaincfg.MainNetParams
MainNetParams.Net = MainnetMagic
MainNetParams.PubKeyHashAddrID = 48
MainNetParams.ScriptHashAddrID = 50
MainNetParams.Bech32HRPSegwit = "ltc"
TestNetParams = chaincfg.TestNet3Params
TestNetParams.Net = TestnetMagic
TestNetParams.PubKeyHashAddrID = 111
TestNetParams.ScriptHashAddrID = 58
TestNetParams.Bech32HRPSegwit = "tltc"
err := chaincfg.Register(&MainNetParams)
if err == nil {
err = chaincfg.Register(&TestNetParams)
}
if err != nil {
panic(err)
}
}
// LitecoinParser handle
type LitecoinParser struct {
*btc.BitcoinParser
}
// NewLitecoinParser returns new LitecoinParser instance
func NewLitecoinParser(params *chaincfg.Params, c *btc.Configuration) *LitecoinParser {
return &LitecoinParser{BitcoinParser: btc.NewBitcoinParser(params, c)}
}
// GetChainParams contains network parameters for the main Litecoin network,
// and the test Litecoin network
func GetChainParams(chain string) *chaincfg.Params {
switch chain {
case "test":
return &TestNetParams
default:
return &MainNetParams
}
}

View File

@ -0,0 +1,277 @@
package litecoin
import (
"blockbook/bchain"
"blockbook/bchain/coins/btc"
"encoding/hex"
"reflect"
"testing"
)
func TestAddressToOutputScript_Testnet(t *testing.T) {
type args struct {
address string
}
tests := []struct {
name string
args args
want string
wantErr bool
}{
{
name: "P2PKH1",
args: args{address: "mgPdTgEq6YqUJ4yzQgR8jH5TCX5c5yRwCP"},
want: "76a91409957dfdb3eb620a94b99857e13949551584c33688ac",
wantErr: false,
},
{
name: "P2SH1",
args: args{address: "2MvGVySztevmycxrSmMRjJaVj2iJin7qpap"},
want: "a9142126232e3f47ae0f1246ec5f05fc400d83c86a0d87",
wantErr: false,
},
{
name: "P2SH2",
args: args{address: "2N9a2TNzWz1FEKGFxUdMEh62V83URdZ5QAZ"},
want: "a914b31049e7ee51501fe19e3e0cdb803dc84cf99f9e87",
wantErr: false,
},
}
parser := NewLitecoinParser(GetChainParams("test"), &btc.Configuration{})
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
got, err := parser.AddressToOutputScript(tt.args.address)
if (err != nil) != tt.wantErr {
t.Errorf("AddressToOutputScript() error = %v, wantErr %v", err, tt.wantErr)
return
}
h := hex.EncodeToString(got)
if !reflect.DeepEqual(h, tt.want) {
t.Errorf("AddressToOutputScript() = %v, want %v", h, tt.want)
}
})
}
}
func TestAddressToOutputScript_Mainnet(t *testing.T) {
type args struct {
address string
}
tests := []struct {
name string
args args
want string
wantErr bool
}{
{
name: "P2PKH1",
args: args{address: "LgJGe7aKy1wfXESKhiKeRWj6z4KjzCfXNW"},
want: "76a914e72ba56ab6afccac045d696b979e3b5077e88d1988ac",
wantErr: false,
},
{
name: "P2PKH2",
args: args{address: "LiTVReQ6N8rWc2pNg2XMwCWq7A9P15teWg"},
want: "76a914feda50542e61108cf53b93dbffa0959f91ccb32588ac",
wantErr: false,
},
{
name: "P2SH1",
args: args{address: "MLTQ8niHMnpJLNvK72zBeY91hQmUtoo8nX"},
want: "a91489ba6cf45546f91f1bdf553e695d63fc6b8795bd87",
wantErr: false,
},
{
name: "P2SH2",
args: args{address: "MAVWzxXm8KGkZTesqLtqywzrvbs96FEoKy"},
want: "a9141c6fbaf46d64221e80cbae182c33ddf81b9294ac87",
wantErr: false,
},
{
name: "witness_v0_keyhash",
args: args{address: "ltc1q5fgkuac9s2ry56jka5s6zqsyfcugcchrqgz2yl"},
want: "0014a2516e770582864a6a56ed21a102044e388c62e3",
wantErr: false,
},
{
name: "witness_v0_scripthashx",
args: args{address: "ltc1qu9dgdg330r6r84g5mw7wqshg04exv2uttmw2elfwx74h5tgntuzsk3x5nd"},
want: "0020e15a86a23178f433d514dbbce042e87d72662b8b5edcacfd2e37ab7a2d135f05",
wantErr: false,
},
}
parser := NewLitecoinParser(GetChainParams("main"), &btc.Configuration{})
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
got, err := parser.AddressToOutputScript(tt.args.address)
if (err != nil) != tt.wantErr {
t.Errorf("AddressToOutputScript() error = %v, wantErr %v", err, tt.wantErr)
return
}
h := hex.EncodeToString(got)
if !reflect.DeepEqual(h, tt.want) {
t.Errorf("AddressToOutputScript() = %v, want %v", h, tt.want)
}
})
}
}
var (
testTx1 bchain.Tx
testTxPacked1 = "0001e4538ba8d7aa2002000000031e1977dc524bec5929e95d8d0946812944b7b5bda12f5b99fdf557773f2ee65e0100000000ffffffff8a398e44546dce0245452b90130e86832b21fd68f26662bc33aeb7c6c115d23c1900000000ffffffffb807ab93a7fcdff7af6d24581a4a18aa7c1db1ebecba2617a6805b009513940f0c00000000ffffffff020001a04a000000001976a9141ae882e788091732da6910595314447c9e38bd8d88ac27440f00000000001976a9146b474cbf0f6004329b630bdd4798f2c23d1751b688ac00000000"
)
func init() {
var (
addr1, addr2 bchain.Address
err error
)
addr1, err = bchain.NewBaseAddress("LMgENNXzzuPxp7vfMjDrCU44bsmrEMgqvc")
if err == nil {
addr2, err = bchain.NewBaseAddress("LV1ByjbJNFTHyFQqwqwdJXKJznYDzXzg4B")
}
if err != nil {
panic(err)
}
testTx1 = bchain.Tx{
Hex: "02000000031e1977dc524bec5929e95d8d0946812944b7b5bda12f5b99fdf557773f2ee65e0100000000ffffffff8a398e44546dce0245452b90130e86832b21fd68f26662bc33aeb7c6c115d23c1900000000ffffffffb807ab93a7fcdff7af6d24581a4a18aa7c1db1ebecba2617a6805b009513940f0c00000000ffffffff020001a04a000000001976a9141ae882e788091732da6910595314447c9e38bd8d88ac27440f00000000001976a9146b474cbf0f6004329b630bdd4798f2c23d1751b688ac00000000",
Blocktime: 1519053456,
Txid: "1c50c1770374d7de2f81a87463a5225bb620d25fd467536223a5b715a47c9e32",
LockTime: 0,
Vin: []bchain.Vin{
{
ScriptSig: bchain.ScriptSig{
Hex: "",
},
Txid: "5ee62e3f7757f5fd995b2fa1bdb5b744298146098d5de92959ec4b52dc77191e",
Vout: 1,
Sequence: 4294967295,
},
{
ScriptSig: bchain.ScriptSig{
Hex: "",
},
Txid: "3cd215c1c6b7ae33bc6266f268fd212b83860e13902b454502ce6d54448e398a",
Vout: 25,
Sequence: 4294967295,
},
{
ScriptSig: bchain.ScriptSig{
Hex: "",
},
Txid: "0f941395005b80a61726baecebb11d7caa184a1a58246daff7dffca793ab07b8",
Vout: 12,
Sequence: 4294967295,
},
},
Vout: []bchain.Vout{
{
Value: 12.52000000,
N: 0,
ScriptPubKey: bchain.ScriptPubKey{
Hex: "76a9141ae882e788091732da6910595314447c9e38bd8d88ac",
Addresses: []string{
"LMgENNXzzuPxp7vfMjDrCU44bsmrEMgqvc",
},
},
Address: addr1,
},
{
Value: 0.01000487,
N: 1,
ScriptPubKey: bchain.ScriptPubKey{
Hex: "76a9146b474cbf0f6004329b630bdd4798f2c23d1751b688ac",
Addresses: []string{
"LV1ByjbJNFTHyFQqwqwdJXKJznYDzXzg4B",
},
},
Address: addr2,
},
},
}
}
func Test_PackTx(t *testing.T) {
type args struct {
tx bchain.Tx
height uint32
blockTime int64
parser *LitecoinParser
}
tests := []struct {
name string
args args
want string
wantErr bool
}{
{
name: "litecoin-1",
args: args{
tx: testTx1,
height: 123987,
blockTime: 1519053456,
parser: NewLitecoinParser(GetChainParams("main"), &btc.Configuration{}),
},
want: testTxPacked1,
wantErr: false,
},
}
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
got, err := tt.args.parser.PackTx(&tt.args.tx, tt.args.height, tt.args.blockTime)
if (err != nil) != tt.wantErr {
t.Errorf("packTx() error = %v, wantErr %v", err, tt.wantErr)
return
}
h := hex.EncodeToString(got)
if !reflect.DeepEqual(h, tt.want) {
t.Errorf("packTx() = %v, want %v", h, tt.want)
}
})
}
}
func Test_UnpackTx(t *testing.T) {
type args struct {
packedTx string
parser *LitecoinParser
}
tests := []struct {
name string
args args
want *bchain.Tx
want1 uint32
wantErr bool
}{
{
name: "litecoin-1",
args: args{
packedTx: testTxPacked1,
parser: NewLitecoinParser(GetChainParams("main"), &btc.Configuration{}),
},
want: &testTx1,
want1: 123987,
wantErr: false,
},
}
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
b, _ := hex.DecodeString(tt.args.packedTx)
got, got1, err := tt.args.parser.UnpackTx(b)
if (err != nil) != tt.wantErr {
t.Errorf("unpackTx() error = %v, wantErr %v", err, tt.wantErr)
return
}
if !reflect.DeepEqual(got, tt.want) {
t.Errorf("unpackTx() got = %v, want %v", got, tt.want)
}
if got1 != tt.want1 {
t.Errorf("unpackTx() got1 = %v, want %v", got1, tt.want1)
}
})
}
}

View File

@ -0,0 +1,56 @@
package litecoin
import (
"blockbook/bchain"
"blockbook/bchain/coins/btc"
"encoding/json"
"github.com/golang/glog"
)
// LitecoinRPC is an interface to JSON-RPC bitcoind service.
type LitecoinRPC struct {
*btc.BitcoinRPC
}
// NewLitecoinRPC returns new LitecoinRPC instance.
func NewLitecoinRPC(config json.RawMessage, pushHandler func(bchain.NotificationType)) (bchain.BlockChain, error) {
b, err := btc.NewBitcoinRPC(config, pushHandler)
if err != nil {
return nil, err
}
s := &LitecoinRPC{
b.(*btc.BitcoinRPC),
}
s.RPCMarshaler = btc.JSONMarshalerV2{}
return s, nil
}
// Initialize initializes LitecoinRPC instance.
func (b *LitecoinRPC) Initialize() error {
chainName, err := b.GetChainInfoAndInitializeMempool(b)
if err != nil {
return err
}
glog.Info("Chain name ", chainName)
params := GetChainParams(chainName)
// always create parser
b.Parser = NewLitecoinParser(params, b.ChainConfig)
// parameters for getInfo request
if params.Net == MainnetMagic {
b.Testnet = false
b.Network = "livenet"
} else {
b.Testnet = true
b.Network = "testnet"
}
glog.Info("rpc: block chain ", params.Name)
return nil
}

View File

@ -0,0 +1 @@
/opt/coins/blockbook/litecoin_testnet/config/blockchaincfg.json

View File

@ -0,0 +1,2 @@
#!/bin/sh
/opt/coins/blockbook/litecoin_testnet/bin/logrotate.sh

View File

@ -0,0 +1,2 @@
/opt/coins/data/litecoin_testnet/blockbook
/opt/coins/blockbook/litecoin_testnet/logs

View File

@ -0,0 +1,6 @@
#!/usr/bin/dh-exec
blockbook /opt/coins/blockbook/litecoin_testnet/bin
cert /opt/coins/blockbook/litecoin_testnet
static /opt/coins/blockbook/litecoin_testnet
configs/litecoin_testnet.json => /opt/coins/blockbook/litecoin_testnet/config/blockchaincfg.json
logrotate.sh /opt/coins/blockbook/litecoin_testnet/bin

View File

@ -0,0 +1,2 @@
/opt/coins/blockbook/litecoin_testnet/cert/testcert.crt /opt/coins/blockbook/litecoin_testnet/cert/blockbook.crt
/opt/coins/blockbook/litecoin_testnet/cert/testcert.key /opt/coins/blockbook/litecoin_testnet/cert/blockbook.key

View File

@ -0,0 +1,23 @@
#!/bin/bash
set -e
case "$1" in
configure)
if ! id -u blockbook-litecoin &> /dev/null
then
useradd --system -M -U blockbook-litecoin -s /bin/false
fi
for dir in /opt/coins/data/litecoin_testnet/blockbook /opt/coins/blockbook/litecoin_testnet/logs
do
if [ "$(stat -c '%U' $dir)" != "blockbook-litecoin" ]
then
chown -R blockbook-litecoin:blockbook-litecoin $dir
fi
done
;;
esac
#DEBHELPER#

View File

@ -0,0 +1,43 @@
# It is not recommended to modify this file in-place, because it will
# be overwritten during package upgrades. If you want to add further
# options or overwrite existing ones then use
# $ systemctl edit blockbook-litecoin-testnet.service
# See "man systemd.service" for details.
[Unit]
Description=Blockbook daemon (Litecoin testnet)
After=network.target
Wants=backend-litecoin-testnet.service
[Service]
ExecStart=/opt/coins/blockbook/litecoin_testnet/bin/blockbook -blockchaincfg=/opt/coins/blockbook/litecoin_testnet/config/blockchaincfg.json -datadir=/opt/coins/data/litecoin_testnet/blockbook/db -sync -httpserver=:19034 -socketio=:19134 -certfile=/opt/coins/blockbook/litecoin_testnet/cert/blockbook -explorer=https://ltc-explorer.trezor.io/ -log_dir=/opt/coins/blockbook/litecoin_testnet/logs
User=blockbook-litecoin
Type=simple
Restart=on-failure
WorkingDirectory=/opt/coins/blockbook/litecoin_testnet
# Resource limits
LimitNOFILE=500000
# Hardening measures
####################
# Provide a private /tmp and /var/tmp.
PrivateTmp=true
# Mount /usr, /boot/ and /etc read-only for the process.
ProtectSystem=full
# Disallow the process and all of its children to gain
# new privileges through execve().
NoNewPrivileges=true
# Use a new /dev namespace only populated with API pseudo devices
# such as /dev/null, /dev/zero and /dev/random.
PrivateDevices=true
# Deny the creation of writable and executable memory mappings.
MemoryDenyWriteExecute=true
[Install]
WantedBy=multi-user.target

View File

@ -0,0 +1 @@
/opt/coins/blockbook/litecoin/config/blockchaincfg.json

View File

@ -0,0 +1,2 @@
#!/bin/sh
/opt/coins/blockbook/litecoin/bin/logrotate.sh

View File

@ -0,0 +1,2 @@
/opt/coins/data/litecoin/blockbook
/opt/coins/blockbook/litecoin/logs

View File

@ -0,0 +1,6 @@
#!/usr/bin/dh-exec
blockbook /opt/coins/blockbook/litecoin/bin
cert /opt/coins/blockbook/litecoin
static /opt/coins/blockbook/litecoin
configs/litecoin.json => /opt/coins/blockbook/litecoin/config/blockchaincfg.json
logrotate.sh /opt/coins/blockbook/litecoin/bin

View File

@ -0,0 +1,2 @@
/opt/coins/blockbook/litecoin/cert/testcert.crt /opt/coins/blockbook/litecoin/cert/blockbook.crt
/opt/coins/blockbook/litecoin/cert/testcert.key /opt/coins/blockbook/litecoin/cert/blockbook.key

View File

@ -0,0 +1,23 @@
#!/bin/bash
set -e
case "$1" in
configure)
if ! id -u blockbook-litecoin &> /dev/null
then
useradd --system -M -U blockbook-litecoin -s /bin/false
fi
for dir in /opt/coins/data/litecoin/blockbook /opt/coins/blockbook/litecoin/logs
do
if [ "$(stat -c '%U' $dir)" != "blockbook-litecoin" ]
then
chown -R blockbook-litecoin:blockbook-litecoin $dir
fi
done
;;
esac
#DEBHELPER#

View File

@ -0,0 +1,43 @@
# It is not recommended to modify this file in-place, because it will
# be overwritten during package upgrades. If you want to add further
# options or overwrite existing ones then use
# $ systemctl edit blockbook-litecoin.service
# See "man systemd.service" for details.
[Unit]
Description=Blockbook daemon (Litecoin mainnet)
After=network.target
Wants=backend-litecoin.service
[Service]
ExecStart=/opt/coins/blockbook/litecoin/bin/blockbook -blockchaincfg=/opt/coins/blockbook/litecoin/config/blockchaincfg.json -datadir=/opt/coins/data/litecoin/blockbook/db -sync -httpserver=:9034 -socketio=:9134 -certfile=/opt/coins/blockbook/litecoin/cert/blockbook -explorer=https://ltc-explorer.trezor.io/ -log_dir=/opt/coins/blockbook/litecoin/logs
User=blockbook-litecoin
Type=simple
Restart=on-failure
WorkingDirectory=/opt/coins/blockbook/litecoin
# Resource limits
LimitNOFILE=500000
# Hardening measures
####################
# Provide a private /tmp and /var/tmp.
PrivateTmp=true
# Mount /usr, /boot/ and /etc read-only for the process.
ProtectSystem=full
# Disallow the process and all of its children to gain
# new privileges through execve().
NoNewPrivileges=true
# Use a new /dev namespace only populated with API pseudo devices
# such as /dev/null, /dev/zero and /dev/random.
PrivateDevices=true
# Deny the creation of writable and executable memory mappings.
MemoryDenyWriteExecute=true
[Install]
WantedBy=multi-user.target

View File

@ -54,3 +54,13 @@ Package: blockbook-dash-testnet
Architecture: amd64
Depends: ${shlibs:Depends}, ${misc:Depends}, coreutils, passwd, findutils, psmisc, backend-dash-testnet
Description: Satoshilabs blockbook server (Dash testnet)
Package: blockbook-litecoin
Architecture: amd64
Depends: ${shlibs:Depends}, ${misc:Depends}, coreutils, passwd, findutils, psmisc, backend-litecoin
Description: Satoshilabs blockbook server (Litecoin mainnet)
Package: blockbook-litecoin-testnet
Architecture: amd64
Depends: ${shlibs:Depends}, ${misc:Depends}, coreutils, passwd, findutils, psmisc, backend-litecoin-testnet
Description: Satoshilabs blockbook server (Litecoin testnet)

12
configs/litecoin.json Normal file
View File

@ -0,0 +1,12 @@
{
"coin_name": "Litecoin",
"rpcURL": "http://localhost:8034",
"rpcUser": "rpc",
"rpcPass": "rpc",
"rpcTimeout": 25,
"parse": true,
"zeroMQBinding": "tcp://localhost:38334",
"mempoolWorkers": 8,
"mempoolSubWorkers": 2,
"blockAddressesToKeep": 300
}

View File

@ -0,0 +1,12 @@
{
"coin_name": "Litecoin Testnet",
"rpcURL": "http://localhost:18034",
"rpcUser": "rpc",
"rpcPass": "rpc",
"rpcTimeout": 25,
"parse": true,
"zeroMQBinding": "tcp://localhost:48334",
"mempoolWorkers": 8,
"mempoolSubWorkers": 2,
"blockAddressesToKeep": 300
}

View File

@ -1,4 +1,4 @@
TARGETS = bitcoin zcash bcash ethereum bgold dash
TARGETS = bitcoin zcash bcash ethereum bgold dash litecoin
IMAGE = blockbook-backend-build-deb
NO_CACHE = false

View File

@ -0,0 +1,13 @@
LITECOIN_VERSION := 0.16.0
all:
wget https://download.litecoin.org/litecoin-${LITECOIN_VERSION}/linux/litecoin-${LITECOIN_VERSION}-x86_64-linux-gnu.tar.gz
tar -xf litecoin-${LITECOIN_VERSION}-x86_64-linux-gnu.tar.gz
mv litecoin-${LITECOIN_VERSION} litecoin
rm litecoin/bin/litecoin-qt
rm litecoin/bin/test_litecoin
clean:
rm -rf litecoin
rm -f litecoin-${LITECOIN_VERSION}-x86_64-linux-gnu.tar.gz

View File

@ -0,0 +1 @@
/opt/coins/nodes/litecoin_testnet/litecoin_testnet.conf

View File

@ -0,0 +1 @@
/opt/coins/data/litecoin_testnet/backend

View File

@ -0,0 +1,2 @@
litecoin/* /opt/coins/nodes/litecoin_testnet
litecoin_testnet.conf /opt/coins/nodes/litecoin_testnet

View File

@ -0,0 +1,10 @@
/opt/coins/data/litecoin_testnet/backend/testnet4/debug.log
/opt/coins/data/litecoin_testnet/backend/testnet4/db.log
{
rotate 7
daily
compress
missingok
notifempty
copytruncate
}

View File

@ -0,0 +1,20 @@
#!/bin/bash
set -e
case "$1" in
configure)
if ! id -u litecoin &> /dev/null
then
useradd --system -M -U litecoin -s /bin/false
fi
if [ "$(stat -c '%U' /opt/coins/data/litecoin_testnet/backend)" != "litecoin" ]
then
chown -R litecoin:litecoin /opt/coins/data/litecoin_testnet/backend
fi
;;
esac
#DEBHELPER#

View File

@ -0,0 +1,47 @@
# It is not recommended to modify this file in-place, because it will
# be overwritten during package upgrades. If you want to add further
# options or overwrite existing ones then use
# $ systemctl edit litecoin-testnet.service
# See "man systemd.service" for details.
# Note that almost all daemon options could be specified in
# /opt/coins/nodes/litecoin_testnet/litecoin_testnet.conf
[Unit]
Description=litecoin daemon (testnet)
After=network.target
[Service]
ExecStart=/opt/coins/nodes/litecoin_testnet/bin/litecoind -datadir=/opt/coins/data/litecoin_testnet/backend -conf=/opt/coins/nodes/litecoin_testnet/litecoin_testnet.conf -pid=/run/litecoind/litecoin_testnet.pid
# Creates /run/litecoind owned by litecoin
RuntimeDirectory=litecoind
User=litecoin
Type=forking
PIDFile=/run/litecoind/litecoin_testnet.pid
Restart=on-failure
# Resource limits
LimitNOFILE=500000
# Hardening measures
####################
# Provide a private /tmp and /var/tmp.
PrivateTmp=true
# Mount /usr, /boot/ and /etc read-only for the process.
ProtectSystem=full
# Disallow the process and all of its children to gain
# new privileges through execve().
NoNewPrivileges=true
# Use a new /dev namespace only populated with API pseudo devices
# such as /dev/null, /dev/zero and /dev/random.
PrivateDevices=true
# Deny the creation of writable and executable memory mappings.
MemoryDenyWriteExecute=true
[Install]
WantedBy=multi-user.target

View File

@ -0,0 +1 @@
/opt/coins/nodes/litecoin/litecoin.conf

View File

@ -0,0 +1 @@
/opt/coins/data/litecoin/backend

View File

@ -0,0 +1,2 @@
litecoin/* /opt/coins/nodes/litecoin
litecoin.conf /opt/coins/nodes/litecoin

View File

@ -0,0 +1,10 @@
/opt/coins/data/litecoin/backend/debug.log
/opt/coins/data/litecoin/backend/db.log
{
rotate 7
daily
compress
missingok
notifempty
copytruncate
}

View File

@ -0,0 +1,20 @@
#!/bin/bash
set -e
case "$1" in
configure)
if ! id -u litecoin &> /dev/null
then
useradd --system -M -U litecoin -s /bin/false
fi
if [ "$(stat -c '%U' /opt/coins/data/litecoin/backend)" != "litecoin" ]
then
chown -R litecoin:litecoin /opt/coins/data/litecoin/backend
fi
;;
esac
#DEBHELPER#

View File

@ -0,0 +1,47 @@
# It is not recommended to modify this file in-place, because it will
# be overwritten during package upgrades. If you want to add further
# options or overwrite existing ones then use
# $ systemctl edit litecoin.service
# See "man systemd.service" for details.
# Note that almost all daemon options could be specified in
# /opt/coins/nodes/litecoin/litecoin.conf
[Unit]
Description=litecoin daemon (mainnet)
After=network.target
[Service]
ExecStart=/opt/coins/nodes/litecoin/bin/litecoind -datadir=/opt/coins/data/litecoin/backend -conf=/opt/coins/nodes/litecoin/litecoin.conf -pid=/run/litecoind/litecoin.pid
# Creates /run/litecoind owned by litecoin
RuntimeDirectory=litecoind
User=litecoin
Type=forking
PIDFile=/run/litecoind/litecoin.pid
Restart=on-failure
# Resource limits
LimitNOFILE=500000
# Hardening measures
####################
# Provide a private /tmp and /var/tmp.
PrivateTmp=true
# Mount /usr, /boot/ and /etc read-only for the process.
ProtectSystem=full
# Disallow the process and all of its children to gain
# new privileges through execve().
NoNewPrivileges=true
# Use a new /dev namespace only populated with API pseudo devices
# such as /dev/null, /dev/zero and /dev/random.
PrivateDevices=true
# Deny the creation of writable and executable memory mappings.
MemoryDenyWriteExecute=true
[Install]
WantedBy=multi-user.target

View File

@ -0,0 +1,5 @@
litecoin (0.16.0-satoshilabs1) unstable; urgency=medium
* Initial build
-- Martin Bohm <martin.bohm@satoshilabs.com> Mon, 11 Jun 2018 11:12:13 +0200

View File

@ -0,0 +1 @@
9

View File

@ -0,0 +1,16 @@
Source: litecoin
Section: satoshilabs
Priority: optional
Maintainer: martin.bohm@satoshilabs.com
Build-Depends: debhelper, wget, tar, gzip, make, dh-systemd, dh-exec
Standards-Version: 3.9.5
Package: backend-litecoin
Architecture: amd64
Depends: ${shlibs:Depends}, ${misc:Depends}, logrotate
Description: Satoshilabs packaged litecoin server
Package: backend-litecoin-testnet
Architecture: amd64
Depends: ${shlibs:Depends}, ${misc:Depends}, logrotate
Description: Satoshilabs packaged litecoin server

View File

@ -0,0 +1,11 @@
#!/usr/bin/make -f
DH_VERBOSE = 1
%:
dh $@ --with=systemd
override_dh_systemd_start:
dh_systemd_start --no-start
override_dh_installinit:

View File

@ -0,0 +1,17 @@
daemon=1
server=1
nolisten=1
rpcuser=rpc
rpcpassword=rpc
rpcport=8034
txindex=1
whitelist=127.0.0.1
zmqpubhashtx=tcp://127.0.0.1:38334
zmqpubhashblock=tcp://127.0.0.1:38334
rpcworkqueue=1100
maxmempool=2000
dbcache=1000

View File

@ -0,0 +1,15 @@
daemon=1
server=1
testnet=1
nolisten=1
rpcuser=rpc
rpcpassword=rpc
rpcport=18034
txindex=1
zmqpubhashtx=tcp://127.0.0.1:48334
zmqpubhashblock=tcp://127.0.0.1:48334
rpcworkqueue=1100
maxmempool=2000
dbcache=1000