Ejemplo n.º 1
0
def fullNode():
    global me
    global balance
    global actN
    global pkhs

    if me == None:
        me = nd.FullNode(blockchain)
        balance = me.getWallet().getBalance()
        actN = 'Full'
        pkhs = me.getWallet().getPubKeyHs()

    elif me.getType() != 'Full':
        flash('You must have a Full Node for this page to work!')
        return redirect('/home')

    connectedNodes = me.bchain.getNodes()
    form1 = RegisterNodeForm()
    form2 = SendToForm()
    form3 = RefreshBalance()
    if form1.submit1.data and form1.validate_on_submit():
        blockchain.registerNode(form1.nodeAddress.data)
        flash('You have added a the node {} to your network!'.format(
            form.nodeAddress.data))
        return redirect('/fullNode')
    if form2.submit2.data and form2.validate_on_submit():
        sendTransaction(form2.amount.data, form2.toAddress.data,
                        form2.txFee.data)
        flash('You have sent {} coins to the address {}!'.format(
            form2.amount.data, form2.toAddress.data))
        return redirect('/fullNode')
    if form3.submit4.data and form3.validate_on_submit():
        balance = me.getWallet().getBalance()
        flash('Your balance has been refreshed!')
        return redirect('/fullNode')
    return render_template('full.html',
                           title='Full',
                           nodes=connectedNodes,
                           keys=pkhs,
                           activeN=actN,
                           bal=balance,
                           reg_form=form1,
                           send_form=form2,
                           refresh_form=form3)