Skip to content

Commit

Permalink
Init2
Browse files Browse the repository at this point in the history
  • Loading branch information
Christian Knöpke committed Aug 15, 2017
1 parent a4b492e commit c80fcc1
Show file tree
Hide file tree
Showing 82 changed files with 4,107 additions and 70 deletions.
18 changes: 1 addition & 17 deletions .gitattributes
Original file line number Diff line number Diff line change
@@ -1,17 +1 @@
# Auto detect text files and perform LF normalization
* text=auto

# Custom for Visual Studio
*.cs diff=csharp

# Standard to msysgit
*.doc diff=astextplain
*.DOC diff=astextplain
*.docx diff=astextplain
*.DOCX diff=astextplain
*.dot diff=astextplain
*.DOT diff=astextplain
*.pdf diff=astextplain
*.PDF diff=astextplain
*.rtf diff=astextplain
*.RTF diff=astextplain
src/clientversion.cpp export-subst
154 changes: 115 additions & 39 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,47 +1,123 @@
# Windows image file caches
Thumbs.db
ehthumbs.db
.gitignore
*.sublime-project
*.sublime-workspace
todo.txt
reset-files.bash

# Folder config file
Desktop.ini
*.tar.gz

# Recycle Bin used on file shares
$RECYCLE.BIN/
*.exe
src/bitcloud
src/bitcloudd
src/bitcloud-cli
src/bitcloud-tx
src/test/test_bitcloud
src/qt/test/test_bitcloud-qt

# Windows Installer files
*.cab
*.msi
*.msm
*.msp
# autoreconf
Makefile.in
aclocal.m4
autom4te.cache/
build-aux/config.guess
build-aux/config.sub
build-aux/depcomp
build-aux/install-sh
build-aux/ltmain.sh
build-aux/m4/libtool.m4
build-aux/m4/lt~obsolete.m4
build-aux/m4/ltoptions.m4
build-aux/m4/ltsugar.m4
build-aux/m4/ltversion.m4
build-aux/missing
build-aux/compile
build-aux/test-driver
config.log
config.status
configure
libtool
src/config/bitcloud-config.h
src/config/bitcloud-config.h.in
src/config/stamp-h1
share/setup.nsi
share/qt/Info.plist
contrib/devtools/split-debug.sh

# Windows shortcuts
*.lnk
src/univalue/gen

# =========================
# Operating System Files
# =========================
src/qt/*.moc
src/qt/moc_*.cpp
src/qt/forms/ui_*.h

# OSX
# =========================
src/qt/test/moc*.cpp

.deps
.dirstamp
.libs
.*.swp
*.*~*
*.bak
*.rej
*.orig
*.pyc
*.o
*.o-*
*.patch
.bitcloud
*.a
*.pb.cc
*.pb.h

*.log
*.trs
*.dmg

*.json.h
*.raw.h

#libtool object files
*.lo
*.la

# Compilation and Qt preprocessor part
*.qm
Makefile
bitcloud-qt
BTDX-Qt.app

# Unit-tests
Makefile.test
bitcloud-qt_test
src/test/buildenv.py

# Resources cpp
qrc_*.cpp

# Qt creator
*.pro.user

# Mac specific
.DS_Store
.AppleDouble
.LSOverride

# Thumbnails
._*

# Files that might appear in the root of a volume
.DocumentRevisions-V100
.fseventsd
.Spotlight-V100
.TemporaryItems
.Trashes
.VolumeIcon.icns

# Directories potentially created on remote AFP share
.AppleDB
.AppleDesktop
Network Trash Folder
Temporary Items
.apdisk
build

#lcov
*.gcno
/*.info
test_bitcloud.coverage/
total.coverage/
coverage_percent.txt

#build tests
linux-coverage-build
linux-build
win32-build
qa/pull-tester/run-bitcoind-for-test.sh
qa/pull-tester/tests-config.sh
qa/pull-tester/cache/*
qa/pull-tester/test.*/*

!src/leveldb*/Makefile

.cproject
.project
/doc/doxygen/
/nbproject/
4 changes: 2 additions & 2 deletions configure.ac
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
dnl require autoconf 2.60 (AS_ECHO/AS_ECHO_N)
AC_PREREQ([2.60])
define(_CLIENT_VERSION_MAJOR, 2)
define(_CLIENT_VERSION_MAJOR, 3)
define(_CLIENT_VERSION_MINOR, 0)
define(_CLIENT_VERSION_REVISION, 0)
define(_CLIENT_VERSION_BUILD, 0)
define(_CLIENT_VERSION_BUILD, 4)
define(_CLIENT_VERSION_IS_RELEASE, true)
define(_COPYRIGHT_YEAR, 2017)
AC_INIT([Diamond Core],[_CLIENT_VERSION_MAJOR._CLIENT_VERSION_MINOR._CLIENT_VERSION_REVISION],[http://bit.bitclouds],[bitcloud])
Expand Down
113 changes: 113 additions & 0 deletions src/Darksend-relay.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,113 @@

#include "Darksend-relay.h"


CDarKsendRelay::CDarKsendRelay()
{
vinMasternode = CTxIn();
nBlockHeight = 0;
nRelayType = 0;
in = CTxIn();
out = CTxOut();
}

CDarKsendRelay::CDarKsendRelay(CTxIn& vinMasternodeIn, vector<unsigned char>& vchSigIn, int nBlockHeightIn, int nRelayTypeIn, CTxIn& in2, CTxOut& out2)
{
vinMasternode = vinMasternodeIn;
vchSig = vchSigIn;
nBlockHeight = nBlockHeightIn;
nRelayType = nRelayTypeIn;
in = in2;
out = out2;
}

std::string CDarKsendRelay::ToString()
{
std::ostringstream info;

info << "vin: " << vinMasternode.ToString() << " nBlockHeight: " << (int)nBlockHeight << " nRelayType: " << (int)nRelayType << " in " << in.ToString() << " out " << out.ToString();

return info.str();
}

bool CDarKsendRelay::Sign(std::string strSharedKey)
{
std::string strMessage = in.ToString() + out.ToString();

CKey key2;
CPubKey pubkey2;
std::string errorMessage = "";

if (!DarKsendSigner.SetKey(strSharedKey, errorMessage, key2, pubkey2)) {
LogPrintf("CDarKsendRelay():Sign - ERROR: Invalid shared key: '%s'\n", errorMessage.c_str());
return false;
}

if (!DarKsendSigner.SignMessage(strMessage, errorMessage, vchSig2, key2)) {
LogPrintf("CDarKsendRelay():Sign - Sign message failed\n");
return false;
}

if (!DarKsendSigner.VerifyMessage(pubkey2, vchSig2, strMessage, errorMessage)) {
LogPrintf("CDarKsendRelay():Sign - Verify message failed\n");
return false;
}

return true;
}

bool CDarKsendRelay::VerifyMessage(std::string strSharedKey)
{
std::string strMessage = in.ToString() + out.ToString();

CKey key2;
CPubKey pubkey2;
std::string errorMessage = "";

if (!DarKsendSigner.SetKey(strSharedKey, errorMessage, key2, pubkey2)) {
LogPrintf("CDarKsendRelay()::VerifyMessage - ERROR: Invalid shared key: '%s'\n", errorMessage.c_str());
return false;
}

if (!DarKsendSigner.VerifyMessage(pubkey2, vchSig2, strMessage, errorMessage)) {
LogPrintf("CDarKsendRelay()::VerifyMessage - Verify message failed\n");
return false;
}

return true;
}

void CDarKsendRelay::Relay()
{
int nCount = std::min(mnodeman.CountEnabled(ActiveProtocol()), 20);
int nRank1 = (rand() % nCount) + 1;
int nRank2 = (rand() % nCount) + 1;

//keep picking another second number till we get one that doesn't match
while (nRank1 == nRank2)
nRank2 = (rand() % nCount) + 1;

//printf("rank 1 - rank2 %d %d \n", nRank1, nRank2);

//relay this message through 2 separate nodes for redundancy
RelayThroughNode(nRank1);
RelayThroughNode(nRank2);
}

void CDarKsendRelay::RelayThroughNode(int nRank)
{
CMasternode* pmn = mnodeman.GetMasternodeByRank(nRank, nBlockHeight, ActiveProtocol());

if (pmn != NULL) {
//printf("RelayThroughNode %s\n", pmn->addr.ToString().c_str());
CNode* pnode = ConnectNode((CAddress)pmn->addr, NULL, false);
if (pnode) {
//printf("Connected\n");
pnode->PushMessage("dsr", (*this));
pnode->Release();
return;
}
} else {
//printf("RelayThroughNode NULL\n");
}
}
52 changes: 52 additions & 0 deletions src/Darksend-relay.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@

// Copyright (c) 2014-2015 The Dash developers
// Copyright (c) 2015-2017 The BTDX developers
// Distributed under the MIT/X11 software license, see the accompanying
// file COPYING or http://www.opensource.org/licenses/mit-license.php.

#ifndef DARKSEND_RELAY_H
#define DARKSEND_RELAY_H

#include "activemasternode.h"
#include "main.h"
#include "masternodeman.h"


class CDarKsendRelay
{
public:
CTxIn vinMasternode;
vector<unsigned char> vchSig;
vector<unsigned char> vchSig2;
int nBlockHeight;
int nRelayType;
CTxIn in;
CTxOut out;

CDarKsendRelay();
CDarKsendRelay(CTxIn& vinMasternodeIn, vector<unsigned char>& vchSigIn, int nBlockHeightIn, int nRelayTypeIn, CTxIn& in2, CTxOut& out2);

ADD_SERIALIZE_METHODS;

template <typename Stream, typename Operation>
inline void SerializationOp(Stream& s, Operation ser_action, int nType, int nVersion)
{
READWRITE(vinMasternode);
READWRITE(vchSig);
READWRITE(vchSig2);
READWRITE(nBlockHeight);
READWRITE(nRelayType);
READWRITE(in);
READWRITE(out);
}

std::string ToString();

bool Sign(std::string strSharedKey);
bool VerifyMessage(std::string strSharedKey);
void Relay();
void RelayThroughNode(int nRank);
};


#endif
Loading

0 comments on commit c80fcc1

Please sign in to comment.