XRPLF / xrpl.js

A JavaScript/TypeScript API for interacting with the XRP Ledger in Node.js and the browser
https://xrpl.org/
1.2k stars 511 forks source link

Signing with the "sign" method, error:BigNumber Error: new BigNumber() not a number: undefined #952

Closed litterGuy closed 5 years ago

litterGuy commented 5 years ago

Use code like that:

var txJSON = JSON.stringify(req.body.tx_json); var secret = req.body.secret.toString(); var rst = api.sign(txJSON, secret);

But got the following error

{ BigNumber Error: new BigNumber() not a number: undefined at raise (/home/xrp/node_modules/ripple-lib/node_modules/bignumber.js/bignumber.js:1190:25) at /home/xrp/node_modules/ripple-lib/node_modules/bignumber.js/bignumber.js:1178:33 at new BigNumber (/home/xrp/node_modules/ripple-lib/node_modules/bignumber.js/bignumber.js:193:67) at signWithKeypair (/home/xrp/node_modules/ripple-lib/dist/npm/transaction/sign.js:24:17) at RippleAPI.sign (/home/xrp/node_modules/ripple-lib/dist/npm/transaction/sign.js:53:16) at api.connect.then (/home/xrp/xrp_server.js:35:18) at name: 'BigNumber Error' }

How can I solve this problem?

litterGuy commented 5 years ago

Sry, i lost the paramter "Fee".But add this paramter got new error:

Error: unsupported value: 2000000 at Function.from (/home/xrp/node_modules/ripple-binary-codec/distrib/npm/types/amount.js:93:13) at /home/xrp/node_modules/ripple-binary-codec/distrib/npm/types/st-object.js:31:46 at /home/xrp/node_modules/lodash/lodash.js:13807:16 at /home/xrp/node_modules/lodash/lodash.js:4911:15 at baseForOwn (/home/xrp/node_modules/lodash/lodash.js:2996:24) at Function.transform (/home/xrp/node_modules/lodash/lodash.js:13806:43) at Function.from (/home/xrp/node_modules/ripple-binary-codec/distrib/npm/types/st-object.js:28:18) at serializeObject (/home/xrp/node_modules/ripple-binary-codec/distrib/npm/binary.js:23:18) at signingData (/home/xrp/node_modules/ripple-binary-codec/distrib/npm/binary.js:31:10) at Object.encodeForSigning (/home/xrp/node_modules/ripple-binary-codec/distrib/npm/index.js:40:21)

litterGuy commented 5 years ago

Emmmmmmm..... I set Amount and Fee to string, and got the right result.