Giter VIP home page Giter VIP logo

nanode's People

Contributors

fu5ha avatar mikepaszkiewicz avatar rawrmaan 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  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

nanode's Issues

Converting from raw to Nano results in a rounded up number

The converter does this to go from raw to Nano.

return value.shiftedBy(-30).toFixed(15)

I was using the nano.accounts.getNanoBalance() function to get the full balance, and then try to do a send of that balance, and was getting an Insufficient balance response, because the function uses the converter to turn the resulting raw balance into Nano.

Is there a reason that we're not using .toFixed(30)? My use case seems like it would be a pretty common one and it essentially leaves it impossible (without doing my own conversion) to use the top-level send function to send the full balance.

data: { error: 'Bad amount number' } } }

Getting the above error when trying to send 0.5 NANO. Below is all my code. I have confirm that I have the required amount in the sending account.

var Nano = require("nanode")
const API_KEY = "API_KEY"
const nano = new Nano({
   apiKey: API_KEY
})
const nanoAccount = nano.account("PRIVATE_KEY")
nanoAccount.nanoBalance().then(balance => {
    console.log(balance)
})
var recievingAddress = "xrb_388ff1fzd3rhf5ijidqxo8jt6dj37izwa47t131c4cykpzhg4uured9qyxiz"
var sendAmount = 0.5
nanoAccount.send(sendAmount, recievingAddress).then(output => {
    console.log(output)
})
  .catch(err => {
    console.error(err)
  })

Private key and seed can be sent to the node

There is no security issue when the node is local:
const nano = new Nano({url: 'http://localhost:7076'})
But when the node is not local, such as when the Nanode API is used:
const nano = new Nano({ apiKey: 'xyzzy' })
the private key and seed can be sent to the remote node and so are no longer secret.

These appear to be the API calls in question:

  • open, account.open and blocks.createOpen
  • send, account.send and blocks.createSend
  • receive, account.receive and blocks.createReceive
  • change, account.change and blocks.createChange
  • key.create
  • key.expand
  • deterministicKey

These calls can be made to sign blocks and generate keys locally using the nacl and blake2b packages that are already part of this repository.

I have submitted pull request #23 which resolves this issue.

Issue with nano.send - converter returns raw amount with decimals

I'm using the nano.send(privateKey, amount, address) function, which converts the amount in Nano to Raw.

The generated raw amount that is sent via RPC ends up with decimals. E.g. here's the request it generates:

{
  "type":"send",
  "key":"redacted",
  "destination":"redacted",
  "balance":"10000000000000000000000000000",
  "amount":"10000000000000000000000000000.000000",
  "previous":"redacted",
  "work":"4f8c3af1a67aab51",
  "action":"block_create"
}

This results in a 500 error back from the Nanode API with the message...

data: { error: 'Bad amount number' } }

Cannot find ./util/util.js

Before getting to #8, I originally got a

Error: Cannot find module './util/util.js'

This was solved by changing line 47 of dist/index.js from

var accountPair = require('./util/util.js').accountPair;

to

var accountPair = require('../util/util.js').accountPair;

Dude why nanode have no contact infomation so I can solve a refund problem?!

The question is, why are you removing alias that we paid for without any notice (you have our emails), and without receiving any refund

my account got renamed to banned_fraud##### (each # is a number)

that's fucking absurd, I have this account linked to nanode on my website and a client had to say to me how he won't find me on nanowallet.io alias and how my account have a bad name when looked up on nanode

that's fucked up

Support for payments?

As far as I see there is no support for handling payments?

It seems e.g. the brainblocks api makes use of the payments part of the nano rpc protocol.

How would I for instance implement something like a user depositing nano into my system?

Would I need to handle all the logic myself of generating new adress and waiting for sufficient amount of nano received?

Creating api without apiKey and no authorization fails

For example:

const Nano = require('nanode')
const nano = new Nano({url: "http://127.0.0.1:7076"});

nano.available().then((result) => {
    console.log(result);
}).catch((err) => {
    console.log(err);
});

Fails with:

Error: "value" required in setHeader("Authorization", value)
    at validateHeader (_http_outgoing.js:492:11)
    at ClientRequest.setHeader (_http_outgoing.js:501:3)
    at new ClientRequest (_http_client.js:173:14)
    at Object.request (http.js:38:10)
    at RedirectableRequest._performRequest (C:\Users\Gray\Code\nanodetest\node_modules\follow-redirects\index.js:128:24)
    at new RedirectableRequest (C:\Users\Gray\Code\nanodetest\node_modules\follow-redirects\index.js:54:8)
    at Object.wrappedProtocol.request (C:\Users\Gray\Code\nanodetest\node_modules\follow-redirects\index.js:252:14)
    at dispatchHttpRequest (C:\Users\Gray\Code\nanodetest\node_modules\axios\lib\adapters\http.js:131:25)
    at new Promise (<anonymous>)
    at httpAdapter (C:\Users\Gray\Code\nanodetest\node_modules\axios\lib\adapters\http.js:18:10)

You can solve this by passing fake authorization details in the url:

const nano = new Nano({url: "http://u:[email protected]:7076"});

Support CommonJS modules

Currently, this package does not work out of the box with latest Node.js.

const Nano = require('nanode')
const nano = new Nano({url: '...'})
TypeError: Nano is not a constructor

ES6 Module support must be shimmed in order for it to work:

$ yarn add @std/esm
$ node -r @std/esm index.js

This is also solved by simply adding

module.exports = Node;

To the end of dist/index.js.

I think support for Node's default CommonJS modules is pretty essential here.

npm install nanode fails

Comand from README.md

$ npm install nanode
npm ERR! code ENOSELF
npm ERR! Refusing to install package with name "nanode" under a package
npm ERR! also called "nanode". Did you name your project the same
npm ERR! as the dependency you're installing?
npm ERR! 
npm ERR! For more information, see:
npm ERR!     <https://docs.npmjs.com/cli/install#limitations-of-npms-install-algorithm>

npm ERR! A complete log of this run can be found in:
npm ERR!     /home/stef/.npm/_logs/2018-03-03T10_07_26_554Z-debug.log
$ npm install 
npm WARN prepublish-on-install As of npm@5, `prepublish` scripts are deprecated.
npm WARN prepublish-on-install Use `prepare` for build steps and `prepublishOnly` for upload-only.
npm WARN prepublish-on-install See the deprecation note in `npm help scripts` for more information.

> [email protected] prepublish /home/stef/git/nanode
> tsc && copyfiles util/*.js dist

added 167 packages in 23.012s


Allow customizing RPC clients

Add rpcClient config option that takes a function of the signature (params: any) => Promise<any> to support RPC calls through clients other than axios.

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.