bananocoin / bananojs Goto Github PK
View Code? Open in Web Editor NEWJavaScript utilities for the banano cryptocurrency.
License: MIT License
JavaScript utilities for the banano cryptocurrency.
License: MIT License
I am having the following problem
const bananojs = require("@bananocoin/bananojs");
bananojs.setBananodeApiUrl("https://vault.banano.cc/api/node-api");
const crypto = require("crypto");
const seed = crypto.randomBytes(32).toString("hex");
const privateKey = bananojs.getPrivateKey(seed, 0);
const publicKey = bananojs.getPublicKey(privateKey);
const account = bananojs.getAccount(publicKey, "ban_");
console.log(privateKey);
console.log(account);
It returns the following
612C182C801BF5A05A0A9BAB1095D672015DE10608C20EFE9D66438C866CC942
ban_1896u6uxu7gheaawx8p9azsardwtaypsaq5q1ysbk1ixai3551tzpxpwij6b
But when I use that private key in some wallet like Kalium, the address is totally diferent
After cloning the repo, editing the config.js file, running npm install and then running npm start I get this error:
> [email protected] start C:\Users\mhudg\Apps\banano\banano-p2w-runner
> node -max-old-space-size=1700 scripts/index.js
(node:39952) UnhandledPromiseRejectionWarning: TypeError: bananojs.getAccountFromSeed is not a function
at Object.init (C:\Users\mhudg\Apps\banano\banano-p2w-runner\scripts\game.js:37:29)
at init (C:\Users\mhudg\Apps\banano\banano-p2w-runner\scripts\index.js:45:8)
at Object.<anonymous> (C:\Users\mhudg\Apps\banano\banano-p2w-runner\scripts\index.js:127:1)
at Module._compile (internal/modules/cjs/loader.js:1063:30)
at Object.Module._extensions..js (internal/modules/cjs/loader.js:1092:10)
at Module.load (internal/modules/cjs/loader.js:928:32)
at Function.Module._load (internal/modules/cjs/loader.js:769:14)
at Function.executeUserEntryPoint [as runMain] (internal/modules/run_main.js:72:12)
at internal/main/run_main_module.js:17:47
^^
Sometimes services like Kalium go down and it causes quite a few outages - to mitigate this I am proposing a way to designate a back up rpc should requests to the first rpc fail. Will try and implement myself when I have time, but opening this issue to remind myself and ask for discussion on the idea.
Example from main.js:161
commands['ngetprivatekey'] = async (seed, seedIx) => {
const config = configs.nano;
bananodeApi.setUrl(config.bananodeUrl);
const privateKey = bananoUtil.getPrivateKey(seed, seedIx);
console.log('nano getprivatekey privateKey', privateKey);
};
If you comment the third line here everything seems to work the same. I was even worried: why would we need an API when generating private keys? Are they being sent anywhere? ๐ Isn't it better to remove that line to make people sleep better?
If I'm wrong, thank you for explanations ๐๐ป
If I call getBananoAccountFromSeed and forget to use await, I get a promise.
This is normal, but if I then pass that account to receiveBananoDepositsForSeed i get an error in getAccountPublicKey saying startsWith is not a function. Promises should be detected and handled in a more elegant way.
When trying to get the balance, occasionally this error is returned: The server's account info cannot be retrieved, please try again.
While its not exactly wrong, it makes it sound like the rpc node is offline or the request could not be made, when the problem could be that the account is unopened.
I encountered this specifically when trying to change represenative. The docs do not say you have to open the account before changing reps.
If the above is not my misunderstanding, I can submit a pr to fix this
It could be very great to get work using a nano work server URL. It is much more efficient because you can use a graphics card with it.
I am trying to make use of this in a typescript project, but I am having trouble making it work.
Typescript compiler tells me to create a "d.ts" file with decare module "@bananocoin/bananojs";
, but I cannot make it work.
Lots of functions (especially in app/scripts
do not have any JSDoc strings at all.
This is a big deal because:
bananoUtil.sendFromPrivateKey
, which is very useful to have.)Oh, and the @memberof
tag should be lowercase and not uppercase, because we don't call them in the code uppercase. For example BananoUtil
needs to become bananoUtil
.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.