mikepaszkiewicz / nanode Goto Github PK
View Code? Open in Web Editor NEWDead simple, promise-based client for interacting and building services with the NANO network.
Home Page: https://nanode.co
Dead simple, promise-based client for interacting and building services with the NANO network.
Home Page: https://nanode.co
Make sure it checks the param types and adds a return type based on the action
param, if possible
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.
Open
Send
Receive
Change
x accounts
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)
})
Here's the deterministicKey function.
deterministicKey(seed: string, index?: number) {
return this.rpc('deterministic_key', {
seed,
index: '0'
})
}
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:
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.
Nanode.accounts(private_key).open(rep?, hash?).
Choose Nanode by default
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' } }
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;
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
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?
https://www.nanode.co/node-api I read that:
Node API will permanently shut down on June 15, 2018.
So this will only be intended to work with our own instance of a node?
Can any public node made available for tests?
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"});
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.
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
Add rpcClient
config option that takes a function of the signature (params: any) => Promise<any>
to support RPC calls through clients other than axios.
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.