From c138a663e195fb9b42f0cb818dac255696430dea Mon Sep 17 00:00:00 2001 From: Josh Rickmar Date: Wed, 13 Nov 2013 17:25:50 -0500 Subject: [PATCH] Return errors if rand.Read fails. --- wallet/wallet.go | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/wallet/wallet.go b/wallet/wallet.go index 9a59c80..18a5c91 100644 --- a/wallet/wallet.go +++ b/wallet/wallet.go @@ -383,8 +383,12 @@ func NewWallet(name, desc string, passphrase []byte, net btcwire.BitcoinNet, cre // Randomly-generate rootkey and chaincode. rootkey, chaincode := make([]byte, 32), make([]byte, 32) - rand.Read(rootkey) - rand.Read(chaincode) + if _, err := rand.Read(rootkey); err != nil { + return nil, err + } + if _, err := rand.Read(chaincode); err != nil { + return nil, err + } // Create new root address from key and chaincode. root, err := newRootBtcAddress(rootkey, nil, chaincode, createdAt)