Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Transactions are not validated for balance amount #42

Open
HourGlss opened this issue Sep 8, 2018 · 3 comments
Open

Transactions are not validated for balance amount #42

HourGlss opened this issue Sep 8, 2018 · 3 comments

Comments

@HourGlss
Copy link

HourGlss commented Sep 8, 2018

a user can give any number of "coins" because a balance is never checked. This is a core feature of any currency. Due to the fact that this is education, it is pivotal.

@HourGlss
Copy link
Author

HourGlss commented Sep 9, 2018

@node.route('/balances', methods=['GET'])
def get_balance():
    global BLOCKCHAIN
    working = BLOCKCHAIN
    balances = {}
    balances_json = []

    for block in working:
        if block.data['transactions'] is not None:
            for transaction in block.data['transactions']:
                to = transaction['to']
                source = transaction['from']
                amount = transaction['amount']

                if type(amount) == type("string"):
                    amount = eval(amount)

                if to in balances:
                    balances[to] += amount
                else:
                    balances[to] = amount
                if source != "network":
                    balances[source] -= amount

    for k,v in balances.items():
        account = {
            "address": str(k),
            "amount": str(v)
        }
        balances_json.append(account)

    return json.dumps(balances_json)

This can be used to check all balances for accounts

@Jolosin4
Copy link

How to implent it in the code? Can you copy the entire code with balance amount? Or how do I get this in the wallet file?

@HourGlss
Copy link
Author

HourGlss commented Sep 18, 2018

I’m working on it. Check my repo, I pulled apart this code and I’m trying to make something that actually works.

This code doesn’t actually work for getting a chain from someone else. Nor are transactions logically evaluated or verifiable from other users. Not only is it not secure, it’s not a cryptocurrency.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants