Code Monkey home page Code Monkey logo

bananojs's People

Contributors

0x5ca1ab1e avatar airtune avatar alessiocarrafa avatar constsandvars avatar coranos avatar davidlr99 avatar dependabot[bot] avatar dev-ptera avatar jeje avatar kaibrockelt avatar kasparnau avatar ludwignagelhus avatar omahs avatar randomblock1 avatar skyfallwastaken avatar stjet avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

bananojs's Issues

The account address differs when import the private key

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

TypeError: bananojs.getAccountFromSeed is not a function when running npm start

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

Feature request: back up RPC urls

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.

Why is bananode API URL defined for get private key methods?

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 ๐Ÿ™๐Ÿป

passing in promises causes obscure error

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.

Misleading and unhelpful error message

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

Typescript support.

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 missing function documentation

Lots of functions (especially in app/scripts do not have any JSDoc strings at all.

This is a big deal because:

  1. the README claims that ALL functions are documented: "complete documentation of all functions".
  2. the CLI uses a lot of functions that are not in the documentation (for example, bananoUtil.sendFromPrivateKey, which is very useful to have.)
  3. TypeScript automatic definition generation really really needs accurate documentation, and the PR I opened generates TypeScript definitions from the documentation. (Once I'm done with my current Booster project I'd like to convert this to TypeScript.)

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.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.