conradoqg / naivecoin

A cryptocurrency implementation in less than 1500 lines of code
Apache License 2.0
1.22k stars 319 forks source link

Transactions issue #54

Closed neurofluxation closed 6 years ago

neurofluxation commented 6 years ago

When doing the first transaction by an address under a wallet id, I get the successful result of: info - 1: Transaction added: 754c5c2d811034e50b12f7560417d3f830fa7595af8814db3a9b404c5ed6ab13

But when I do the second transaction (regardless of the last transaction being confirmed or not and regardless of the amount or fee), all I get is this:

2018-10-08T10:44:05.802Z - info - 1: Transaction added: dea617c20bace2ac294cf45a9740bd2b4b799e42dd619114ceb1d064cbb8f17d
2018-10-08T10:44:05.809Z - info - 1: Syncing with peers
#
# Fatal error in , line 0
# unreachable code
#
#
#
#FailureMessage Object: 0xb53ef4d8Illegal instruction

Then the Node just stops working. Nothing in logs.
Restarting the Node exe allows ONE more transaction to succeed, then fails on any subsequent ones again. Any idea what could be causing that off the top of your head? :/

Edit: Confirmed this happens regardless of whether I run my modified version or the version straight from the repo :/

Edit 2: I've narrowed it down to AFTER this section of code:

let inputs = R.map((utxo) => {
            let txiHash = CryptoUtil.hash({
                transaction: utxo.transaction,
                index: utxo.index,
                address: utxo.address
            });
            utxo.signature = CryptoEdDSAUtil.signHash(CryptoEdDSAUtil.generateKeyPairFromSecret(self.secretKey), txiHash);
            return utxo;
        }, this.listOfUTXO);

It seems this will execute ONCE, but not again until you restart the Node exe?

neurofluxation commented 6 years ago

@conradoqg bump perhaps? Sorry to page you directly.. It's killing me here :(

conradoqg commented 6 years ago

This is interesting. It looks like its something related to node or the library that CryptoUtil.hash use. Could you inform your node version, os, and architecture? I will try to reproduce it here.

I've never encountered a node error like this.

Another point. Did you debug to see if the content that is being hashed or the secretKey is empty or has something odd in it?

neurofluxation commented 6 years ago

Thanks for the response, the hashing and keys all look fine.. I'm running on a Raspberry Pi Model B.
NodeJS version = 10.0.0

So, curiously this may be a RPi thing as my code seems to work fine on Windows... Which is a pain in the arse as I don't have a spare Windows machine.. I'm guessing that the CryptoUtil functions fall over on ARM (Raspbian Debian distro) or something?