Example #1
0
def initialisedb(db):
    #get current TN block:
    tnlatestBlock = tnCalls(config).currentBlock()
    db.insHeights(tnlatestBlock, 'TN')

    #get current ETH block:
    ethlatestBlock = otherCalls(config).currentBlock()
    db.insHeights(ethlatestBlock, 'ETH')
Example #2
0
async def api_checktxs(tnAddress: str):
    if not tnCalls(config, dbc).validateaddress(tnAddress):
        temp = cTxs(error='invalid address')
    else:
        result = dbc.checkTXs(address=tnAddress)

        if 'error' in result:
            temp = cTxs(error=result['error'])
        else:
            temp = cTxs(transactions=result)

    return temp
    def __init__(self, config, db=None):
        self.config = config

        if db == None:
            if self.config['main']['use-pg']:
                self.db = dbPGCalls(config)
            else:
                self.db = dbCalls(config)
        else:
            self.db = db

        self.tnc = tnCalls(config, self.db)
        self.otc = otherCalls(config, self.db)
Example #4
0
    def __init__(self, config):
        self.config = config
        self.tnc = tnCalls(config)

        if self.config['main']['use-pg']:
            self.db = dbPGCalls(config)
        else:
            self.db = dbCalls(config)

        if self.config['other']['etherscan-on']:
            self.otc = etherscanCalls(config)
        else:
            self.otc = otherCalls(config)
Example #5
0
def initialisedb():
    #get current TN block:
    tnlatestBlock = tnCalls(config).currentBlock()
    if config['main']['use-pg']:
        dbPGCalls(config).insHeights(tnlatestBlock, 'TN')
    else:
        dbCalls(config).insHeights(tnlatestBlock, 'TN')

    #get current ETH block:
    ethlatestBlock = otherCalls(config).currentBlock()
    if config['main']['use-pg']:
        dbPGCalls(config).insHeights(ethlatestBlock, 'ETH')
    else:
        dbCalls(config).insHeights(ethlatestBlock, 'ETH')
Example #6
0
    def __init__(self, config, db = None):
        self.config = config

        if db == None:
            if self.config['main']['use-pg']:
                self.db = dbPGCalls(config)
            else:
                self.db = dbCalls(config)
        else:
            self.db = db

        self.tnc = tnCalls(config, self.db)
        self.verifier = verifier(config, self.db)

        self.lastScannedBlock = self.db.lastScannedBlock("TN")
Example #7
0
    def __init__(self, config):
        self.config = config
        self.tnc = tnCalls(config)
        self.verifier = verifier(config)

        if self.config['other']['etherscan-on']:
            self.otc = etherscanCalls(config)
        else:
            self.otc = otherCalls(config)

        if self.config['main']['use-pg']:
            self.db = dbPGCalls(config)
        else:
            self.db = dbCalls(config)

        self.lastScannedBlock = self.db.lastScannedBlock("ETH")
Example #8
0
    def __init__(self, config, db=None):
        self.config = config

        if db == None:
            if self.config['main']['use-pg']:
                self.db = dbPGCalls(config)
            else:
                self.db = dbCalls(config)
        else:
            self.db = db

        self.tnc = tnCalls(config, self.db)
        self.verifier = verifier(config, self.db)

        if self.config['other']['etherscan-on']:
            self.otc = etherscanCalls(config, self.db)
        else:
            self.otc = otherCalls(config, self.db)
Example #9
0
async def createTunnel(targetAddress: str):
    targetAddress = re.sub('[\W_]+', '', targetAddress)

    if not tnCalls(config, dbc).validateaddress(targetAddress):
        return cExecResult(successful=0, address='')

    if targetAddress == config['tn']['gatewayAddress']:
        return {'successful': '0'}

    result = dbc.getSourceAddress(targetAddress)
    if len(result) == 0:
        sourceAddress = otherCalls(config, dbc).getNewAddress()

        dbc.insTunnel("created", sourceAddress, targetAddress)
        print("INFO: tunnel created")
        return cExecResult(successful=1, address=sourceAddress)
    else:
        return cExecResult(successful=2, address=result[0][0])
Example #10
0
    allow_headers=["*"],
)

security = HTTPBasic()
app.mount("/static", StaticFiles(directory="static"), name="static")
templates = Jinja2Templates(directory="templates")

with open('config.json') as json_file:
    config = json.load(json_file)

if config['main']['use-pg']:
    dbc = dbPGCalls(config)
else:
    dbc = dbCalls(config)

tnc = tnCalls(config, dbc)
#otc = otherCalls(config, dbc)
checkit = verifier(config, dbc)


def get_current_username(credentials: HTTPBasicCredentials = Depends(security)):
    correct_username = secrets.compare_digest(credentials.username, config["main"]["admin-username"])
    correct_password = secrets.compare_digest(credentials.password, config["main"]["admin-password"])
    if not (correct_username and correct_password):
        print("ERROR: invalid logon details")
        raise HTTPException(
            status_code=HTTP_401_UNAUTHORIZED,
            detail="Incorrect email or password",
            headers={"WWW-Authenticate": "Basic"},
        )
    return credentials.username
app.add_middleware(
    CORSMiddleware,
    allow_origins=["*"],
    allow_credentials=True,
    allow_methods=["*"],
    allow_headers=["*"],
)

security = HTTPBasic()
app.mount("/static", StaticFiles(directory="static"), name="static")
templates = Jinja2Templates(directory="templates")

with open('config.json') as json_file:
    config = json.load(json_file)

tnc = tnCalls(config)

if config['other']['etherscan-on']:
    otc = etherscanCalls(config)
else:
    otc = otherCalls(config)

if config['main']['use-pg']:
    dbc = dbPGCalls(config)
else:
    dbc = dbCalls(config)

checkit = verifier(config)


def get_current_username(
Example #12
0
def get_tnBalance():
    return tnCalls(config, dbc).currentBalance()