coins icon indicating copy to clipboard operation
coins copied to clipboard

"privkey" must be a 32-byte Buffer

Open san-lee-ai opened this issue 7 years ago • 1 comments

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)

san-lee-ai avatar Apr 25 '18 21:04 san-lee-ai

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, _)

yoozzeek avatar Aug 13 '18 08:08 yoozzeek