coins
coins copied to clipboard
"privkey" must be a 32-byte Buffer
got this error when node wallet.js
Error: "privkey" must be a 32-byte Buffer
at new Wallet (/Users/shlee/dvlp/dApp/6Cosmos/Coins/coins/src/wallet.js:12:13)
at Function.WrapperClass [as wallet] (/Users/shlee/dvlp/dApp/6Cosmos/Coins/coins/node_modules/old/lib/index.js:13:12)
at main (/Users/shlee/dvlp/dApp/6Cosmos/Coins/wallet.js:10:30)
at <anonymous>
at process._tickCallback (internal/process/next_tick.js:182:7)
When you create private key you call: privateKey = randomBytes(32)
And put it to .coins file as privateKey.toString('hex')
Means to convert it back to 32-byte Buffer, you need:
privateKey = Buffer.from('youPrivKeyString', 'hex') const account = Wallet(privateKey, _)