code: func (g *BlkTmplGenerator) UpdateExtraNonce(msgBlock *wire.MsgBlock, blockHeight int32, extraNonce uint64) error {
  	coinbaseScript, err := standardCoinbaseScript(blockHeight, extraNonce)
  	if err != nil {
  		return err
  	}
  	if len(coinbaseScript) > blockchain.MaxCoinbaseScriptLen {
  		return fmt.Errorf("coinbase transaction script length "+
  			"of %d is out of range (min: %d, max: %d)",
  			len(coinbaseScript), blockchain.MinCoinbaseScriptLen,
  			blockchain.MaxCoinbaseScriptLen)
  	}
  	msgBlock.Transactions[0].TxIn[0].SignatureScript = coinbaseScript
  
  	// TODO(davec): A btcutil.Block should use saved in the state to avoid
  	// recalculating all of the other transaction hashes.
  	// block.Transactions[0].InvalidateCache()
  
  	// Recalculate the merkle root with the updated extra nonce.
  	block := btcutil.NewBlock(msgBlock)
  	merkles := blockchain.BuildMerkleTreeStore(block.Transactions(), false)
  	msgBlock.Header.MerkleRoot = *merkles[len(merkles)-1]
  	return nil
  }
docs: // UpdateExtraNonce updates the extra nonce in the coinbase script of the passed
  // block by regenerating the coinbase script with the passed value and block
  // height.  It also recalculates and updates the new merkle root that results
  // from changing the coinbase script.