How to Send Money Dogecoin With NodeJS? - javascript

I'm learning to make a simple Dogecoin wallet terminal for personal use. I managed to generate a private key and public address (using coinkey). And success check balance Dogecoin (using API Dogechain).
But, I'm still confused about sending Dogecoin from the private key that I generated. Is there a NodeJS module that can be used to send Dogecoin from a private key? Or maybe anyone has an example?

You'll need a running instance of dogecoind to connect with. If you're running Debian/Ubuntu, this worked for me: http://www.dogeco.in/wiki/index.php/Dogecoind
Then, install the node-dogecoin NPM package. (https://github.com/countable/node-dogecoin)
npm install node-dogecoin
var dogecoin = require('node-dogecoin')()
dogecoin
.auth('MyUserName', 'mypassword')
.getNewAddress()
.getBalance()

You could use node - dogecoin. is a simple wrapper for dogecoin wallet (and i think that is compatible with all Litecoin-compatible wallet, but not tested yet).
In this way you can generate private key, check balance, send coins and so on within a unique nodejs module

Related

web3.js encrypt and decrypt keystore v3 standard

Im using the javascript version of web3 and want to import a private key from a Web3 Secret Storage Definition file (old wiki: Passphrase protected key store spec
). According to the docs there is a decrypt and encrypt funtion:
keystoreJsonV3 = web3.eth.accounts.encrypt(privateKey, password);
privateKey = web3.eth.accounts.decrypt(keystoreJsonV3, password);
But I get an 'Uncaught TypeError: web3.eth.accounts.decrypt is not a function'. What is wrong? Is the docs wrong or is my web3.js the wrong version or something similar? How do I encrypt/decrypt keystore files.
I built my web3.js file from this source
git clone -b develop https://github.com/ethereum/web3.js.git
Those functions are not implemented yet. The functions you relate to are mostly described in the 1.0.0 version of web3 which has not been release yet.
Right now, web3.eth.accounts just retrieves an array of available accounts loaded from testrpc/ganache-cli/geth instance running on your machine.

Node.js - encrypt hard coded password with CSPRNG

I am using Node.js and Express.js to expose some APIs. Some passwords needs to be stored in a config file (json) which would then be used to connect to some other servers. Examples,
module.exports = {
connection: {
server: "abc"
user: "user1",
password: "p123"
}
};
For security reasons, these passwords need to be encrypted (and subsequently decrypted by the service deployed in Express.js to connect to another server).
I looked at some Node.js encryption packages and found several npm packages like crypto-js, cryptr, simple-encryptor etc.
Now, the IT team has shared some security requirements which go as -
'Ensure that CSPRNG and not PRNG is used for JavaScript cryptography'
When I looked at these packages, I could not find whether they use CSPRNG or PRNG. Can someone please help me understand what exactly is the difference and which encryption/decryption package uses CSPRNG instead of PRNG?
I believe your IT team is asking you to generate salts for when you encrypt the passwords. Bcrypt is probably the best crypto library. I dont think it will make a difference if you use PRNG or CSPRNG for generating the hash. See this post. https://crypto.stackexchange.com/questions/35576/do-i-need-to-use-a-csprng-when-creating-salts-for-user-accounts

Invalid JSON RPC response: undefined

I'm trying to create an Ethereum account through Node.js. This is my code:
export async function createNewAccount() {
var web3Instance = new Web3(new Web3.providers.HttpProvider("http://localhost:8545"));
return web3Instance.eth.accounts.create();
}
But I'm getting the following error (from 'create' function):
Invalid JSON RPC response: undefined
I have installed web3.js in my project.
What other step have I missed?
BTW opening the browser on address http://localhost:8545 returns 404. Is there anything I need to install in order to make it work? Is that the testrpc?
Notice that I want to work against the real blockchain, not a test one.
Web3.js is only a javascript interface that can deal with a real node, in order to conduct RPC requests you must have an ethereum node running this can be either
TestRPC , Parity , Geth. additionally, since you are pointing to localhost you will need to run it on your own
The easiest for you to test with will be testRPC install and run it will. By default give you 10 accounts. in order to create a new account with testRPC you will need to run it with --unlock option

Can I send commands using node.js?

I'm running a node.js server using Terminal (Mac) and want to be able to emit messages to the client via the command line. Is this possible? I could code the messages part of it no problem, it's more how I can send something directly from the server to the client rather than from the client-server-client relationship I only understand at the moment.
This is probably what you're after if not let me know and I'll delete answer.
Look into a module called Commander found here.
It will allow you to build up a cli that you can then hook into your methods/prototypes etc.
For Matt :)
var program = require('commander');
program.option('-s, --send', 'Send command');

phonegap Facebook login button hash key issue

I'm using facebook connect plugin for using facebook api to login into my app so I used a sample project and created a simple facebook app to get the app ID and the API was Ok till I came with a message in facebook dialog saying the key "AWiYld2HXlJFTSeTlXo9NY-CTAU" doesnt match any hashed keys into your app.
So I went to facebook app and added that for android hash key that still didnt worked so what can I do to make this working, so could you help me I'm really locked up.
Thank you for helping me in advance.
I fixed this by uninstalling my test app, and then reinstalling it.
I'm pretty sure "AWiYld2HXlJFTSeTlXo9NY-CTAU" means that you don't have a key assigned.. because that was mine too, when I originally built the app without an android key.. I kept trying to add a key, and rebuild it.. with hydration on.. and kept getting this error saying my key "AWiYld2HXlJFTSeTlXo9NY-CTAU" wasn't found in my FB app settings.
Here is the solution: - create your own keystore
you need the keytool of java (jre)
open the terminal and type:
keytool -genkey -v -keystore example.keystore -alias example -keyalg RSA -keysize 2048 -validity 10000
follow the steps (passwords, name, location)
then type:
keytool -exportcert -alias example -keystore C:\example.keystore | openssl sha1 -binary | openssl base64
then in phonegap build add your new autosigned key
https://build.phonegap.com/people/edit#new-android-key
thats all
reference:
http://circlecube.com/2013/02/keystore-for-android-app-development/

Categories